Skip to content

Commit

Permalink
Comment out test cases and check for error on reseller
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Jun 5, 2024
1 parent e748876 commit ac2b56e
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 96 deletions.
4 changes: 3 additions & 1 deletion internalsdk/pro/pro.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ func (c *proClient) RedeemResellerCode(ctx context.Context, req *protos.RedeemRe
log.Errorf("Failed to redeem reseller code: %v", err)
return nil, err
}

if resp.Error != "" {
return nil, errors.New("error redeeming reseller code: %v", resp.Error)
}
return &resp, nil
}

Expand Down
182 changes: 87 additions & 95 deletions internalsdk/pro/pro_test.go
Original file line number Diff line number Diff line change
@@ -1,99 +1,91 @@
package pro

import (
"context"
"net/http"
"testing"
// Todo
// @Paul we might need to find way to use mock here rather calling actual api
// Using actual api will be slow and also it will created redundant data in db
// func TestClient(t *testing.T) {
// log := golog.LoggerFor("pro-http-test")
// client := NewClient("https://api.getiantem.org", &Opts{
// // Just use the default transport since otherwise test setup is difficult.
// // This means it does not actually touch the proxying code, but that should
// // be tested separately.
// HttpClient: &http.Client{},
// UserConfig: func() common.UserConfig {
// return common.NewUserConfig(
// "Lantern",
// "device123", // deviceID
// 123, // userID
// "token", // token
// nil,
// "en", // language
// )
// },
// })
// res, e := client.Plans(context.Background())
// if !assert.NoError(t, e) {
// return
// }
// log.Debugf("Got response: %v", res)
// assert.NotNil(t, res)
// }

"github.com/getlantern/golog"
"github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/protos"
"github.com/stretchr/testify/assert"
)
// func TestLinkValidate(t *testing.T) {
// log := golog.LoggerFor("pro-http-test")
// client := NewClient("https://api.getiantem.org", &Opts{
// // Just use the default transport since otherwise test setup is difficult.
// // This means it does not actually touch the proxying code, but that should
// // be tested separately.
// HttpClient: &http.Client{},
// UserConfig: func() common.UserConfig {
// return common.NewUserConfig(
// "Lantern",
// "device123", // deviceID
// 123, // userID
// "token", // token
// nil,
// "en", // language
// )
// },
// })
// prepareRequestBody := &protos.ValidateRecoveryCodeRequest{
// Email: "[email protected]",
// Code: "123456",
// }
// res, e := client.ValidateEmailRecoveryCode(context.Background(), prepareRequestBody)
// if !assert.NoError(t, e) {
// return
// }
// log.Debugf("Got response: %v", res)
// assert.NotNil(t, res)
// }

func TestClient(t *testing.T) {
log := golog.LoggerFor("pro-http-test")
client := NewClient("https://api.getiantem.org", &Opts{
// Just use the default transport since otherwise test setup is difficult.
// This means it does not actually touch the proxying code, but that should
// be tested separately.
HttpClient: &http.Client{},
UserConfig: func() common.UserConfig {
return common.NewUserConfig(
"Lantern",
"device123", // deviceID
123, // userID
"token", // token
nil,
"en", // language
)
},
})
res, e := client.Plans(context.Background())
if !assert.NoError(t, e) {
return
}
log.Debugf("Got response: %v", res)
assert.NotNil(t, res)
}

func TestLinkValidate(t *testing.T) {
log := golog.LoggerFor("pro-http-test")
client := NewClient("https://api.getiantem.org", &Opts{
// Just use the default transport since otherwise test setup is difficult.
// This means it does not actually touch the proxying code, but that should
// be tested separately.
HttpClient: &http.Client{},
UserConfig: func() common.UserConfig {
return common.NewUserConfig(
"Lantern",
"device123", // deviceID
123, // userID
"token", // token
nil,
"en", // language
)
},
})
prepareRequestBody := &protos.ValidateRecoveryCodeRequest{
Email: "[email protected]",
Code: "123456",
}
res, e := client.ValidateEmailRecoveryCode(context.Background(), prepareRequestBody)
if !assert.NoError(t, e) {
return
}
log.Debugf("Got response: %v", res)
assert.NotNil(t, res)
}

func TestSignUp(t *testing.T) {
log := golog.LoggerFor("pro-http-test")
client := NewClient("https://api.getiantem.org", &Opts{
// Just use the default transport since otherwise test setup is difficult.
// This means it does not actually touch the proxying code, but that should
// be tested separately.
HttpClient: &http.Client{},
UserConfig: func() common.UserConfig {
return common.NewUserConfig(
"Lantern",
"device123", // deviceID
123, // userID
"token", // token
nil,
"en", // language
)
},
})
prepareRequestBody := &protos.SignupRequest{
Email: "[email protected]",
Salt: []byte("salt"),
Verifier: []byte("verifier"),
}
res, e := client.SignUp(context.Background(), prepareRequestBody)
if !assert.NoError(t, e) {
return
}
log.Debugf("Got response: %v", res)
assert.NotNil(t, res)
}
// func TestSignUp(t *testing.T) {
// log := golog.LoggerFor("pro-http-test")
// client := NewClient("https://api.getiantem.org", &Opts{
// // Just use the default transport since otherwise test setup is difficult.
// // This means it does not actually touch the proxying code, but that should
// // be tested separately.
// HttpClient: &http.Client{},
// UserConfig: func() common.UserConfig {
// return common.NewUserConfig(
// "Lantern",
// "device123", // deviceID
// 123, // userID
// "token", // token
// nil,
// "en", // language
// )
// },
// })
// prepareRequestBody := &protos.SignupRequest{
// Email: "[email protected]",
// Salt: []byte("salt"),
// Verifier: []byte("verifier"),
// }
// res, e := client.SignUp(context.Background(), prepareRequestBody)
// if !assert.NoError(t, e) {
// return
// }
// log.Debugf("Got response: %v", res)
// assert.NotNil(t, res)
// }
19 changes: 19 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ PODS:
- DKImagePickerController/PhotoGallery
- Flutter
- Flutter (1.0.0)
- flutter_image_compress_common (1.0.0):
- Flutter
- Mantle
- SDWebImage
- SDWebImageWebPCoder
- flutter_inappwebview_ios (0.0.1):
- Flutter
- flutter_inappwebview_ios/Core (= 0.0.1)
Expand Down Expand Up @@ -92,6 +97,9 @@ PODS:
- libwebp/sharpyuv (1.3.2)
- libwebp/webp (1.3.2):
- libwebp/sharpyuv
- Mantle (2.2.0):
- Mantle/extobjc (= 2.2.0)
- Mantle/extobjc (2.2.0)
- MTBBarcodeScanner (5.0.11)
- OrderedSet (5.0.0)
- package_info_plus (0.4.5):
Expand All @@ -107,6 +115,9 @@ PODS:
- SDWebImage (5.19.2):
- SDWebImage/Core (= 5.19.2)
- SDWebImage/Core (5.19.2)
- SDWebImageWebPCoder (0.14.6):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.17)
- Sentry/HybridSDK (8.21.0):
- SentryPrivate (= 8.21.0)
- sentry_flutter (0.0.1):
Expand Down Expand Up @@ -145,6 +156,7 @@ DEPENDENCIES:
- emoji_picker_flutter (from `.symlinks/plugins/emoji_picker_flutter/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_image_compress_common (from `.symlinks/plugins/flutter_image_compress_common/ios`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
Expand Down Expand Up @@ -181,9 +193,11 @@ SPEC REPOS:
- Google-Mobile-Ads-SDK
- GoogleUserMessagingPlatform
- libwebp
- Mantle
- MTBBarcodeScanner
- OrderedSet
- SDWebImage
- SDWebImageWebPCoder
- Sentry
- SentryPrivate
- SwiftyGif
Expand All @@ -203,6 +217,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/file_picker/ios"
Flutter:
:path: Flutter
flutter_image_compress_common:
:path: ".symlinks/plugins/flutter_image_compress_common/ios"
flutter_inappwebview_ios:
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
flutter_keyboard_visibility:
Expand Down Expand Up @@ -261,6 +277,7 @@ SPEC CHECKSUMS:
emoji_picker_flutter: fe2e6151c5b548e975d546e6eeb567daf0962a58
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
Expand All @@ -275,13 +292,15 @@ SPEC CHECKSUMS:
in_app_purchase_storekit: 4fb7ee9e824b1f09107fbfbbce8c4b276366dc43
integration_test: 13825b8a9334a850581300559b8839134b124670
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
Sentry: ebc12276bd17613a114ab359074096b6b3725203
sentry_flutter: dff1df05dc39c83d04f9330b36360fc374574c5e
SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe
Expand Down

0 comments on commit ac2b56e

Please sign in to comment.