-
Notifications
You must be signed in to change notification settings - Fork 977
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding persister impl for identifier search
- Loading branch information
Ajay Kelkar
committed
Feb 8, 2023
1 parent
5a78fd4
commit 969a909
Showing
14 changed files
with
77 additions
and
33 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 |
---|---|---|
|
@@ -600,7 +600,7 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
require.NoError(t, p.CreateIdentity(ctx, expected)) | ||
createdIDs = append(createdIDs, expected.ID) | ||
|
||
actual, creds, err := p.FindByCredentialsIdentifier(ctx, identity.CredentialsTypePassword, "[email protected]") | ||
actual, creds, err := p.FindByCredentialsTypeAndIdentifier(ctx, identity.CredentialsTypePassword, "[email protected]") | ||
require.NoError(t, err) | ||
|
||
assert.EqualValues(t, expected.Credentials[identity.CredentialsTypePassword].ID, creds.ID) | ||
|
@@ -614,7 +614,7 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
|
||
t.Run("not if on another network", func(t *testing.T) { | ||
_, p := testhelpers.NewNetwork(t, ctx, p) | ||
_, _, err := p.FindByCredentialsIdentifier(ctx, identity.CredentialsTypePassword, "[email protected]") | ||
_, _, err := p.FindByCredentialsTypeAndIdentifier(ctx, identity.CredentialsTypePassword, "[email protected]") | ||
require.ErrorIs(t, err, sqlcon.ErrNoRows) | ||
}) | ||
}) | ||
|
@@ -643,10 +643,10 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
identity.CredentialsTypeLookup, | ||
} { | ||
t.Run(ct.String(), func(t *testing.T) { | ||
_, _, err := p.FindByCredentialsIdentifier(ctx, ct, caseInsensitiveWithSpaces) | ||
_, _, err := p.FindByCredentialsTypeAndIdentifier(ctx, ct, caseInsensitiveWithSpaces) | ||
require.Error(t, err) | ||
|
||
actual, creds, err := p.FindByCredentialsIdentifier(ctx, ct, caseSensitive) | ||
actual, creds, err := p.FindByCredentialsTypeAndIdentifier(ctx, ct, caseSensitive) | ||
require.NoError(t, err) | ||
assertx.EqualAsJSONExcept(t, expected.Credentials[ct], creds, []string{"created_at", "updated_at", "id"}) | ||
assertx.EqualAsJSONExcept(t, expected, actual, []string{"created_at", "state_changed_at", "updated_at", "id"}) | ||
|
@@ -661,7 +661,7 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
} { | ||
t.Run(ct.String(), func(t *testing.T) { | ||
for _, cs := range []string{caseSensitive, caseInsensitiveWithSpaces} { | ||
actual, creds, err := p.FindByCredentialsIdentifier(ctx, ct, cs) | ||
actual, creds, err := p.FindByCredentialsTypeAndIdentifier(ctx, ct, cs) | ||
require.NoError(t, err) | ||
ec := expected.Credentials[ct] | ||
ec.Identifiers = []string{strings.ToLower(caseSensitive)} | ||
|
@@ -681,7 +681,7 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
require.NoError(t, p.CreateIdentity(ctx, expected)) | ||
createdIDs = append(createdIDs, expected.ID) | ||
|
||
actual, creds, err := p.FindByCredentialsIdentifier(ctx, identity.CredentialsTypePassword, identifier) | ||
actual, creds, err := p.FindByCredentialsTypeAndIdentifier(ctx, identity.CredentialsTypePassword, identifier) | ||
require.NoError(t, err) | ||
|
||
assert.EqualValues(t, expected.Credentials[identity.CredentialsTypePassword].ID, creds.ID) | ||
|
@@ -693,7 +693,7 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
|
||
t.Run("not if on another network", func(t *testing.T) { | ||
_, p := testhelpers.NewNetwork(t, ctx, p) | ||
_, _, err := p.FindByCredentialsIdentifier(ctx, identity.CredentialsTypePassword, identifier) | ||
_, _, err := p.FindByCredentialsTypeAndIdentifier(ctx, identity.CredentialsTypePassword, identifier) | ||
require.ErrorIs(t, err, sqlcon.ErrNoRows) | ||
}) | ||
}) | ||
|
@@ -1009,12 +1009,12 @@ func TestPool(ctx context.Context, conf *config.Config, p interface { | |
_, err = p.GetIdentityConfidential(ctx, nid1) | ||
require.ErrorIs(t, err, sqlcon.ErrNoRows) | ||
|
||
i, c, err := p.FindByCredentialsIdentifier(ctx, m[0].Name, "nid1") | ||
i, c, err := p.FindByCredentialsTypeAndIdentifier(ctx, m[0].Name, "nid1") | ||
require.NoError(t, err) | ||
assert.Equal(t, "nid1", c.Identifiers[0]) | ||
require.Len(t, i.Credentials, 0) | ||
|
||
_, _, err = p.FindByCredentialsIdentifier(ctx, m[0].Name, "nid2") | ||
_, _, err = p.FindByCredentialsTypeAndIdentifier(ctx, m[0].Name, "nid2") | ||
require.ErrorIs(t, err, sqlcon.ErrNoRows) | ||
|
||
i, err = p.GetIdentityConfidential(ctx, iid) | ||
|
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
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
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
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
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
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