feat:
* test cases totp
This commit is contained in:
parent
a3fa0eb6cd
commit
0e931d6e65
|
@ -1,32 +1,36 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"github.com/authorizerdev/authorizer/server/db"
|
||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||
"github.com/authorizerdev/authorizer/server/resolvers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func verifyTOTPTest(t *testing.T, s TestSetup) {
|
||||
//t.Helper()
|
||||
//t.Run(`should verify totp`, func(t *testing.T) {
|
||||
// req, ctx := createContext(s)
|
||||
// email := "verify_otp." + s.TestInfo.Email
|
||||
// res, err := resolvers.SignupResolver(ctx, model.SignUpInput{
|
||||
// Email: email,
|
||||
// Password: s.TestInfo.Password,
|
||||
// ConfirmPassword: s.TestInfo.Password,
|
||||
// })
|
||||
// assert.NoError(t, err)
|
||||
// assert.NotNil(t, res)
|
||||
//
|
||||
// // Login should fail as email is not verified
|
||||
// loginRes, err := resolvers.LoginResolver(ctx, model.LoginInput{
|
||||
// Email: email,
|
||||
// Password: s.TestInfo.Password,
|
||||
// })
|
||||
// assert.Error(t, err)
|
||||
// assert.Nil(t, loginRes)
|
||||
// verificationRequest, err := db.Provider.GenerateTotp(ctx, loginRes.User.ID)
|
||||
// assert.Nil(t, err)
|
||||
// assert.Equal(t, email, verificationRequest.Email)
|
||||
t.Helper()
|
||||
t.Run(`should verify totp`, func(t *testing.T) {
|
||||
_, ctx := createContext(s)
|
||||
email := "verify_otp." + s.TestInfo.Email
|
||||
res, err := resolvers.SignupResolver(ctx, model.SignUpInput{
|
||||
Email: email,
|
||||
Password: s.TestInfo.Password,
|
||||
ConfirmPassword: s.TestInfo.Password,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, res)
|
||||
|
||||
// Login should fail as email is not verified
|
||||
loginRes, err := resolvers.LoginResolver(ctx, model.LoginInput{
|
||||
Email: email,
|
||||
Password: s.TestInfo.Password,
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, loginRes)
|
||||
_, err = db.Provider.GenerateTotp(ctx, loginRes.User.ID)
|
||||
assert.Nil(t, err)
|
||||
//assert.Equal(t, ??, string)
|
||||
// verifyRes, err := resolvers.VerifyEmailResolver(ctx, model.VerifyEmailInput{
|
||||
// Token: verificationRequest.Token,
|
||||
// })
|
||||
|
@ -73,4 +77,5 @@ func verifyTOTPTest(t *testing.T, s TestSetup) {
|
|||
// assert.NotEqual(t, verifyOtpRes.AccessToken, "", "access token should not be empty")
|
||||
// cleanData(email)
|
||||
//})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user