Update tests
This commit is contained in:
@@ -28,9 +28,11 @@ func loginTests(t *testing.T, s TestSetup) {
|
||||
Email: refs.NewStringRef(email),
|
||||
Password: s.TestInfo.Password,
|
||||
})
|
||||
|
||||
assert.NotNil(t, err, "should fail because email is not verified")
|
||||
assert.Nil(t, res)
|
||||
// access token should be empty as email is not verified
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, res)
|
||||
assert.Nil(t, res.AccessToken)
|
||||
assert.NotEmpty(t, res.Message)
|
||||
verificationRequest, err := db.Provider.GetVerificationRequestByEmail(ctx, email, constants.VerificationTypeBasicAuthSignup)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, verificationRequest)
|
||||
|
@@ -33,8 +33,12 @@ func mobileLoginTests(t *testing.T, s TestSetup) {
|
||||
PhoneNumber: refs.NewStringRef(phoneNumber),
|
||||
Password: s.TestInfo.Password,
|
||||
})
|
||||
assert.NotNil(t, err, "should fail because phone is not verified")
|
||||
assert.Nil(t, res)
|
||||
// access token should be empty as email is not verified
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, res)
|
||||
assert.Nil(t, res.AccessToken)
|
||||
assert.NotEmpty(t, res.Message)
|
||||
assert.True(t, *res.ShouldShowMobileOtpScreen)
|
||||
smsRequest, err := db.Provider.GetOTPByPhoneNumber(ctx, phoneNumber)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, smsRequest.Otp)
|
||||
|
@@ -35,8 +35,11 @@ func resendOTPTest(t *testing.T, s TestSetup) {
|
||||
Email: refs.NewStringRef(email),
|
||||
Password: s.TestInfo.Password,
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, loginRes)
|
||||
// access token should be empty as email is not verified
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, loginRes)
|
||||
assert.Nil(t, loginRes.AccessToken)
|
||||
assert.NotEmpty(t, loginRes.Message)
|
||||
verificationRequest, err := db.Provider.GetVerificationRequestByEmail(ctx, email, constants.VerificationTypeBasicAuthSignup)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, email, verificationRequest.Email)
|
||||
@@ -57,13 +60,6 @@ func resendOTPTest(t *testing.T, s TestSetup) {
|
||||
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyDisableMailOTPLogin, false)
|
||||
memorystore.Provider.UpdateEnvVariable(constants.EnvKeyDisableTOTPLogin, true)
|
||||
|
||||
// Resend otp should return error as no initial opt is being sent
|
||||
resendOtpRes, err := resolvers.ResendOTPResolver(ctx, model.ResendOTPRequest{
|
||||
Email: refs.NewStringRef(email),
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, resendOtpRes)
|
||||
|
||||
// Login should not return error but access token should be empty as otp should have been sent
|
||||
loginRes, err = resolvers.LoginResolver(ctx, model.LoginInput{
|
||||
Email: refs.NewStringRef(email),
|
||||
@@ -79,7 +75,7 @@ func resendOTPTest(t *testing.T, s TestSetup) {
|
||||
assert.NotEmpty(t, otp.Otp)
|
||||
|
||||
// resend otp
|
||||
resendOtpRes, err = resolvers.ResendOTPResolver(ctx, model.ResendOTPRequest{
|
||||
resendOtpRes, err := resolvers.ResendOTPResolver(ctx, model.ResendOTPRequest{
|
||||
Email: refs.NewStringRef(email),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
@@ -42,8 +42,11 @@ func totpLoginTest(t *testing.T, s TestSetup) {
|
||||
Email: &email,
|
||||
Password: s.TestInfo.Password,
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, loginRes)
|
||||
// access token should be empty as email is not verified
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, loginRes)
|
||||
assert.Nil(t, loginRes.AccessToken)
|
||||
assert.NotEmpty(t, loginRes.Message)
|
||||
verificationRequest, err := db.Provider.GetVerificationRequestByEmail(ctx, email, constants.VerificationTypeBasicAuthSignup)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, email, verificationRequest.Email)
|
||||
|
@@ -47,8 +47,10 @@ func verifyOTPTest(t *testing.T, s TestSetup) {
|
||||
Email: refs.NewStringRef(email),
|
||||
Password: s.TestInfo.Password,
|
||||
})
|
||||
assert.NotNil(t, err, "email is not verified")
|
||||
assert.Nil(t, loginRes)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, loginRes)
|
||||
assert.Nil(t, loginRes.AccessToken)
|
||||
assert.NotEmpty(t, loginRes.Message)
|
||||
|
||||
// Verify the email
|
||||
verificationRequest, err := db.Provider.GetVerificationRequestByEmail(ctx, email, constants.VerificationTypeBasicAuthSignup)
|
||||
|
Reference in New Issue
Block a user