Skip to content

Commit

Permalink
Merge branch 'sprint-1.11' into feat/authorizer-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kishan-Dhakan authored Oct 27, 2023
2 parents 7ab97af + 49e9a3f commit 54d14b5
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions tests/api_tests/0box_referral_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ func Test0BoxReferral(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
t.SetSmokeTests("Post referrals with correct CSRF should work properly")

var firebaseToken *model.FirebaseToken
var firebaseTokens []*model.FirebaseToken

t.TestSetup("Autenticate with firebase", func() {
firebaseToken = authenticateWithFirebase(t, zboxClient.DefaultPhoneNumber)
firebaseTokens = append(firebaseTokens, authenticateWithFirebase(t, zboxClient.DefaultPhoneNumber))
})

t.RunSequentially("Get referral code with correct CSRF and private auth should work properly", func(t *test.SystemTest) {
teardown(t, firebaseToken.IdToken, zboxClient.DefaultPhoneNumber)
teardown(t, firebaseTokens[0].IdToken, zboxClient.DefaultPhoneNumber)
csrfToken := createCsrfToken(t, zboxClient.DefaultPhoneNumber)

zboxRferral, response, err := zboxClient.GetReferralCode(t,
csrfToken,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
zboxClient.DefaultPhoneNumber,
)

Expand All @@ -35,12 +36,12 @@ func Test0BoxReferral(testSetup *testing.T) {
})

t.RunSequentially("Rank referrals with correct CSRF should work properly", func(t *test.SystemTest) {
teardown(t, firebaseToken.IdToken, zboxClient.DefaultPhoneNumber)
teardown(t, firebaseTokens[0].IdToken, zboxClient.DefaultPhoneNumber)
csrfToken := createCsrfToken(t, zboxClient.DefaultPhoneNumber)

zboxRferral, response, err := zboxClient.GetReferralRank(t,
csrfToken,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
zboxClient.DefaultPhoneNumber,
)

Expand All @@ -54,18 +55,18 @@ func Test0BoxReferral(testSetup *testing.T) {
})

t.RunSequentially("Create wallet for first time with the referral code should work", func(t *test.SystemTest) {
teardown(t, firebaseToken.IdToken, zboxClient.DefaultPhoneNumber)
teardown(t, firebaseTokens[0].IdToken, zboxClient.DefaultPhoneNumber)
csrfToken := createCsrfToken(t, zboxClient.DefaultPhoneNumber)

firebaseToken = authenticateWithFirebase(t, zboxClient.DefaultPhoneNumber)
firebaseTokens[0] = authenticateWithFirebase(t, zboxClient.DefaultPhoneNumber)

description := "wallet created as part of " + t.Name()
walletName := "wallet_name"
zboxWallet, response, err := zboxClient.PostWallet(t,
zboxClient.DefaultMnemonic,
walletName,
description,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
csrfToken,
zboxClient.DefaultPhoneNumber,
"blimp",
Expand All @@ -77,26 +78,24 @@ func Test0BoxReferral(testSetup *testing.T) {

zboxRferral, response, err := zboxClient.GetReferralCode(t,
csrfToken,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
zboxClient.DefaultPhoneNumber,
)

require.NoError(t, err)
require.NotNil(t, zboxRferral)
require.Equal(t, 200, response.StatusCode(), "Response status code does not match expected. Output: [%v]", response.String())

teardown(t, firebaseToken.IdToken, zboxClient.DefaultPhoneNumber)

description = "wallet created as part of " + t.Name()
walletName = "wallet_name1"
firebaseToken = authenticateWithFirebase(t, "+919876543210")
firebaseTokens = append(firebaseTokens, authenticateWithFirebase(t, "+919876543210"))
referralMnemonic := "total today fortune output enjoy season desert tool transfer awkward post disease junk offer wedding wire brown broccoli size banana harsh stove raise skull"

zboxWallet, response, err = zboxClient.PostWalletWithReferralCode(t,
referralMnemonic,
walletName,
description,
firebaseToken.IdToken,
firebaseTokens[1].IdToken,
csrfToken,
"+919876543210",
"blimp",
Expand All @@ -110,7 +109,7 @@ func Test0BoxReferral(testSetup *testing.T) {

zboxRferrals, responses, errs := zboxClient.GetReferralCount(t,
csrfToken,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
zboxClient.DefaultPhoneNumber,
)

Expand All @@ -127,16 +126,15 @@ func Test0BoxReferralLeaderBoard(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
t.SetSmokeTests("Testing LeaderBoard")

var firebaseToken *model.FirebaseToken
var firebaseToken2 *model.FirebaseToken
var firebaseTokens []*model.FirebaseToken

t.TestSetup("Autenticate with firebase", func() {
firebaseToken = authenticateWithFirebase(t, zboxClient.DefaultPhoneNumber)
firebaseToken2 = authenticateWithFirebase(t, "+919876543210")
firebaseTokens = append(firebaseTokens, authenticateWithFirebase(t, zboxClient.DefaultPhoneNumber), authenticateWithFirebase(t, "+919876543210"))
})

t.RunSequentially("Testing LeaderBoard", func(t *test.SystemTest) {
teardown(t, firebaseToken.IdToken, zboxClient.DefaultPhoneNumber)
teardown(t, firebaseToken2.IdToken, "+919876543210")
teardown(t, firebaseTokens[0].IdToken, zboxClient.DefaultPhoneNumber)
teardown(t, firebaseTokens[1].IdToken, "+919876543210")

csrfToken := createCsrfToken(t, zboxClient.DefaultPhoneNumber)

Expand All @@ -146,7 +144,7 @@ func Test0BoxReferralLeaderBoard(testSetup *testing.T) {
zboxClient.DefaultMnemonic,
walletName,
description,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
csrfToken,
zboxClient.DefaultPhoneNumber,
"blimp",
Expand All @@ -157,7 +155,7 @@ func Test0BoxReferralLeaderBoard(testSetup *testing.T) {

zboxRferral, response, err := zboxClient.GetReferralCode(t,
csrfToken,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
zboxClient.DefaultPhoneNumber,
)
require.NoError(t, err)
Expand All @@ -171,7 +169,7 @@ func Test0BoxReferralLeaderBoard(testSetup *testing.T) {
referralMnemonic,
walletName,
description,
firebaseToken2.IdToken,
firebaseTokens[1].IdToken,
csrfToken,
"+919876543210",
"blimp",
Expand All @@ -184,7 +182,7 @@ func Test0BoxReferralLeaderBoard(testSetup *testing.T) {

zboxRferrals, responses, errs := zboxClient.GetLeaderBoard(t,
csrfToken,
firebaseToken.IdToken,
firebaseTokens[0].IdToken,
zboxClient.DefaultPhoneNumber,
)
require.NoError(t, errs)
Expand Down

0 comments on commit 54d14b5

Please sign in to comment.