-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from EOS-Nation/feature/unlink_user_identity
Add method to unlink a users identity
- Loading branch information
Showing
2 changed files
with
65 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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ package management | |
|
||
import ( | ||
"encoding/json" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
|
@@ -371,6 +372,62 @@ func TestUser(t *testing.T) { | |
m.User.Delete(batman.GetID()) | ||
}) | ||
}) | ||
|
||
t.Run("Unlink", func(t *testing.T) { | ||
cs, err := m.Connection.ReadByName("Username-Password-Authentication") | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
mainUser := &User{ | ||
Email: auth0.String("[email protected]"), | ||
Username: auth0.String("main_user"), | ||
Password: auth0.String("NF2QZxci3Z5NikLRoHcAu3H5"), | ||
Connection: cs.Name, | ||
} | ||
if err := m.User.Create(mainUser); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
secondaryUser := &User{ | ||
Email: auth0.String("[email protected]"), | ||
Username: auth0.String("secondary_user"), | ||
Password: auth0.String("Ta9Y95PNbiCummJ3zpzCtEYy"), | ||
Connection: cs.Name, | ||
} | ||
if err := m.User.Create(secondaryUser); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
linkedIdentities, err := m.User.Link(mainUser.GetID(), &UserIdentityLink{ | ||
Provider: auth0.String("auth0"), | ||
UserID: secondaryUser.ID, | ||
ConnectionID: cs.ID, | ||
}) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
jsonLinkedIdentities, err := json.Marshal(linkedIdentities) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Logf("%v\n", string(jsonLinkedIdentities)) | ||
|
||
unlinkedIdentities, err := m.User.Unlink(mainUser.GetID(), "auth0", strings.TrimPrefix(secondaryUser.GetID(), "auth0|")) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
jsonUnlinkedIdentities, err := json.Marshal(unlinkedIdentities) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
t.Logf("%v\n", string(jsonUnlinkedIdentities)) | ||
|
||
t.Cleanup(func() { | ||
m.User.Delete(mainUser.GetID()) | ||
m.User.Delete(secondaryUser.GetID()) | ||
}) | ||
}) | ||
} | ||
|
||
func TestUserIdentity(t *testing.T) { | ||
|