authorizer/server/test/forgot_password_test.go

37 lines
1.0 KiB
Go
Raw Normal View History

package test
import (
"testing"
2022-01-17 06:02:13 +00:00
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/graph/model"
"github.com/authorizerdev/authorizer/server/resolvers"
"github.com/stretchr/testify/assert"
)
2022-01-17 06:02:13 +00:00
func forgotPasswordTest(t *testing.T, s TestSetup) {
t.Helper()
2021-12-24 00:57:39 +00:00
t.Run(`should run forgot password`, func(t *testing.T) {
_, ctx := createContext(s)
email := "forgot_password." + s.TestInfo.Email
2022-01-17 06:02:13 +00:00
_, err := resolvers.SignupResolver(ctx, model.SignUpInput{
2021-12-24 00:57:39 +00:00
Email: email,
Password: s.TestInfo.Password,
ConfirmPassword: s.TestInfo.Password,
})
2022-01-17 06:02:13 +00:00
_, err = resolvers.ForgotPasswordResolver(ctx, model.ForgotPasswordInput{
2021-12-24 00:57:39 +00:00
Email: email,
})
assert.Nil(t, err, "no errors for forgot password")
2022-01-17 06:02:13 +00:00
verificationRequest, err := db.Mgr.GetVerificationByEmail(email, constants.VerificationTypeForgotPassword)
2021-12-24 00:57:39 +00:00
assert.Nil(t, err)
2022-01-17 06:02:13 +00:00
assert.Equal(t, verificationRequest.Identifier, constants.VerificationTypeForgotPassword)
2021-12-24 00:57:39 +00:00
cleanData(email)
})
}