-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f08095
commit 86307e3
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -668,3 +668,42 @@ func TestSMTPOverrideEmailVerifyForEmailPasswordUser(t *testing.T) { | |
assert.Equal(t, getContentCalled, true) | ||
assert.Equal(t, sendRawEmailCalled, true) | ||
} | ||
|
||
func TestSendResetPassworEmailFunction(t *testing.T) { | ||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
|
||
resetLink := "" | ||
|
||
testServer := supertokensInitForTest(t, | ||
session.Init(&sessmodels.TypeInput{ | ||
GetTokenTransferMethod: func(req *http.Request, forCreateNewSession bool, userContext supertokens.UserContext) sessmodels.TokenTransferMethod { | ||
return sessmodels.CookieTransferMethod | ||
}, | ||
}), | ||
Init(&epmodels.TypeInput{ | ||
EmailDelivery: &emaildelivery.TypeInput{ | ||
Override: func(originalImplementation emaildelivery.EmailDeliveryInterface) emaildelivery.EmailDeliveryInterface { | ||
*originalImplementation.SendEmail = func(input emaildelivery.EmailType, userContext supertokens.UserContext) error { | ||
resetLink = input.PasswordReset.PasswordResetLink | ||
return nil | ||
} | ||
return originalImplementation | ||
}, | ||
}, | ||
}), | ||
) | ||
defer testServer.Close() | ||
|
||
user, err := SignUp("public", "[email protected]", "pass1234") | ||
assert.NoError(t, err) | ||
|
||
resp, err := SendResetPasswordEmail("public", user.OK.User.ID) | ||
assert.NoError(t, err) | ||
assert.True(t, resp.OK != nil) | ||
|
||
assert.Contains(t, resetLink, "rid=emailpassword") | ||
assert.Contains(t, resetLink, "tenantId=public") | ||
assert.Contains(t, resetLink, "token=") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -927,3 +927,42 @@ func TestSMTPOverrideEmailVerifyForThirdpartyUser(t *testing.T) { | |
assert.Equal(t, getContentCalled, true) | ||
assert.Equal(t, sendRawEmailCalled, true) | ||
} | ||
|
||
func TestSendResetPassworEmailFunction(t *testing.T) { | ||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
|
||
resetLink := "" | ||
|
||
testServer := supertokensInitForTest(t, | ||
session.Init(&sessmodels.TypeInput{ | ||
GetTokenTransferMethod: func(req *http.Request, forCreateNewSession bool, userContext supertokens.UserContext) sessmodels.TokenTransferMethod { | ||
return sessmodels.CookieTransferMethod | ||
}, | ||
}), | ||
Init(&tpepmodels.TypeInput{ | ||
EmailDelivery: &emaildelivery.TypeInput{ | ||
Override: func(originalImplementation emaildelivery.EmailDeliveryInterface) emaildelivery.EmailDeliveryInterface { | ||
*originalImplementation.SendEmail = func(input emaildelivery.EmailType, userContext supertokens.UserContext) error { | ||
resetLink = input.PasswordReset.PasswordResetLink | ||
return nil | ||
} | ||
return originalImplementation | ||
}, | ||
}, | ||
}), | ||
) | ||
defer testServer.Close() | ||
|
||
user, err := EmailPasswordSignUp("public", "[email protected]", "pass1234") | ||
assert.NoError(t, err) | ||
|
||
resp, err := SendResetPasswordEmail("public", user.OK.User.ID) | ||
assert.NoError(t, err) | ||
assert.True(t, resp.OK != nil) | ||
|
||
assert.Contains(t, resetLink, "rid=thirdpartyemailpassword") | ||
assert.Contains(t, resetLink, "tenantId=public") | ||
assert.Contains(t, resetLink, "token=") | ||
} |