-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OKTA-595075 password warn fix (#210)
### Features * Add IdxClientBuilder to simplify configuration of IdxClient. * Add PasswordWarnStateResolver to account for password warn state. * Add CustomPasswordWarnStateResolver enabling custom resolution of password warn state. ### Bug Fixes * Check password warn state on skip to prevent exception.
- Loading branch information
1 parent
a30a78a
commit 9fceec7
Showing
9 changed files
with
1,013 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using FluentAssertions; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Okta.Idx.Sdk.Configuration; | ||
|
||
namespace Okta.Idx.Sdk.UnitTests | ||
{ | ||
public class IdxClientBuilderShould | ||
{ | ||
[Fact] | ||
public async Task UseConfiguration() | ||
{ | ||
string testIssuer = "http://fake.com"; | ||
string testClientId = Guid.NewGuid().ToString(); | ||
string testRedirectUri = "http://fake.com/callback"; | ||
IdxClient client = new IdxClientBuilder() | ||
.UseConfiguration(new IdxConfiguration | ||
{ | ||
Issuer = testIssuer, | ||
ClientId = testClientId, | ||
RedirectUri = testRedirectUri | ||
}) | ||
.Build(); | ||
|
||
client.Should().NotBeNull(); | ||
client.Configuration.Issuer.Should().Be(testIssuer); | ||
client.Configuration.ClientId.Should().Be(testClientId); | ||
client.Configuration.RedirectUri.Should().Be(testRedirectUri); | ||
} | ||
|
||
[Fact] | ||
public async Task BuildClient() | ||
{ | ||
string testIssuer = "http://fake.com"; | ||
string testClientId = Guid.NewGuid().ToString(); | ||
string testRedirectUri = "http://fake.com/callback"; | ||
IdxClient client = new IdxClientBuilder() | ||
.UseConfiguration(new IdxConfiguration | ||
{ | ||
Issuer = testIssuer, | ||
ClientId = testClientId, | ||
RedirectUri = testRedirectUri | ||
}) | ||
.Build(); | ||
|
||
client.Should().NotBeNull(); | ||
client.PasswordWarnStateResolver.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task UsePasswordWarnStateResolver() | ||
{ | ||
string testIssuer = "http://fake.com"; | ||
string testClientId = Guid.NewGuid().ToString(); | ||
string testRedirectUri = "http://fake.com/callback"; | ||
IdxClient client = new IdxClientBuilder() | ||
.UseConfiguration(new IdxConfiguration | ||
{ | ||
Issuer = testIssuer, | ||
ClientId = testClientId, | ||
RedirectUri = testRedirectUri | ||
}) | ||
.UsePasswordWarnStateResolver((idxResponse) => true) | ||
.Build(); | ||
|
||
client.Should().NotBeNull(); | ||
client.PasswordWarnStateResolver.Should().NotBeNull(); | ||
client.PasswordWarnStateResolver.GetType().Should().Be(typeof(CustomPasswordWarnStateResolver)); | ||
} | ||
} | ||
} |
Oops, something went wrong.