-
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
d9018de
commit 061d0bb
Showing
1 changed file
with
58 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -1134,7 +1134,7 @@ func TestLinkAccountFailureAccountInfoAlreadyAssociatedWithAnotherPrimaryUser(t | |
|
||
} | ||
|
||
func TestUnLinkAccountsSuccess(t *testing.T) { | ||
func TestUnlinkAccountsSuccess(t *testing.T) { | ||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
|
@@ -1222,6 +1222,63 @@ func TestUnLinkAccountsSuccess(t *testing.T) { | |
assert.Len(t, sessions, 0) | ||
} | ||
|
||
func TestUnlinkAccountsWithDeleteUserSuccess(t *testing.T) { | ||
BeforeEach() | ||
unittesting.StartUpST("localhost", "8080") | ||
defer AfterEach() | ||
telemetry := false | ||
supertokens.Init(supertokens.TypeInput{ | ||
Supertokens: &supertokens.ConnectionInfo{ | ||
ConnectionURI: "http://localhost:8080", | ||
}, | ||
AppInfo: supertokens.AppInfo{ | ||
AppName: "Testing", | ||
Origin: "http://localhost:3000", | ||
APIDomain: "http://localhost:3001", | ||
}, | ||
Telemetry: &telemetry, | ||
RecipeList: []supertokens.Recipe{ | ||
session.Init(nil), | ||
Init(nil), | ||
supertokens.InitAccountLinking(nil), | ||
}, | ||
}) | ||
|
||
epuser, err := SignUp("public", "[email protected]", "pass123") | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
|
||
user1 := convertEpUserToSuperTokensUser(epuser.OK.User) | ||
assert.False(t, user1.IsPrimaryUser) | ||
supertokens.CreatePrimaryUser(user1.LoginMethods[0].RecipeUserID) | ||
|
||
epuser2, err := SignUp("public", "[email protected]", "pass123") | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
|
||
user2 := convertEpUserToSuperTokensUser(epuser2.OK.User) | ||
assert.False(t, user2.IsPrimaryUser) | ||
|
||
linkAccountResponse, err := supertokens.LinkAccounts(user2.LoginMethods[0].RecipeUserID, user1.ID) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
assert.False(t, linkAccountResponse.OK.AccountsAlreadyLinked) | ||
|
||
unlinkResponse, err := supertokens.UnlinkAccounts(user1.LoginMethods[0].RecipeUserID) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
assert.True(t, unlinkResponse.WasRecipeUserDeleted) | ||
assert.True(t, unlinkResponse.WasLinked) | ||
} | ||
|
||
// TODO: remove this function | ||
func convertEpUserToSuperTokensUser(epuser epmodels.User) supertokens.User { | ||
rUId, err := supertokens.NewRecipeUserID(epuser.ID) | ||
|