Skip to content

Commit

Permalink
OKTA-595075 password warn fix (#210)
Browse files Browse the repository at this point in the history
### 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
bryanapellanes-okta authored Oct 2, 2023
1 parent a30a78a commit 9fceec7
Show file tree
Hide file tree
Showing 9 changed files with 1,013 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 2.4.0

### Additions

* 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.

## 2.3.2

### Bug Fixes
Expand Down
75 changes: 75 additions & 0 deletions src/Okta.Idx.Sdk.UnitTests/IdxClientBuilderShould.cs
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));
}
}
}
Loading

0 comments on commit 9fceec7

Please sign in to comment.