-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MFA support for PasswordCredentials. Closes #52
- Loading branch information
1 parent
570b894
commit f1be55d
Showing
41 changed files
with
780 additions
and
323 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
140 changes: 91 additions & 49 deletions
140
docs/design-principles/0090-authentication-authorization.md
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
65 changes: 65 additions & 0 deletions
65
src/IdentityApplication.UnitTests/IdentityApplicationSpec.cs
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,65 @@ | ||
using Application.Interfaces; | ||
using Application.Resources.Shared; | ||
using Common; | ||
using FluentAssertions; | ||
using IdentityApplication.ApplicationServices; | ||
using Moq; | ||
using UnitTesting.Common; | ||
using Xunit; | ||
|
||
namespace IdentityApplication.UnitTests; | ||
|
||
[Trait("Category", "Unit")] | ||
public class IdentityApplicationSpec | ||
{ | ||
private readonly IdentityApplication _application; | ||
private readonly Mock<ICallerContext> _caller; | ||
private readonly Mock<IPasswordCredentialsService> _passwordCredentialsService; | ||
|
||
public IdentityApplicationSpec() | ||
{ | ||
_caller = new Mock<ICallerContext>(); | ||
_caller.Setup(c => c.CallerId) | ||
.Returns("acallerid"); | ||
_passwordCredentialsService = new Mock<IPasswordCredentialsService>(); | ||
_application = new IdentityApplication(_passwordCredentialsService.Object); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenGetIdentityAsyncAndCredentialNotExist_ThenReturnsIdentity() | ||
{ | ||
_passwordCredentialsService.Setup(pcs => | ||
pcs.GetCredentialsPrivateAsync(It.IsAny<ICallerContext>(), It.IsAny<CancellationToken>())) | ||
.ReturnsAsync(Error.EntityNotFound()); | ||
|
||
var result = await _application.GetIdentityAsync(_caller.Object, CancellationToken.None); | ||
|
||
result.Should().BeSuccess(); | ||
result.Value.Id.Should().Be("acallerid"); | ||
result.Value.IsMfaEnabled.Should().BeFalse(); | ||
result.Value.HasCredentials.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenGetIdentityAsyncAndCredentialExists_ThenReturnsIdentity() | ||
{ | ||
_passwordCredentialsService.Setup(pcs => | ||
pcs.GetCredentialsPrivateAsync(It.IsAny<ICallerContext>(), It.IsAny<CancellationToken>())) | ||
.ReturnsAsync(new PasswordCredential | ||
{ | ||
Id = "auserid", | ||
User = new EndUser | ||
{ | ||
Id = "auserid" | ||
}, | ||
IsMfaEnabled = true | ||
}); | ||
|
||
var result = await _application.GetIdentityAsync(_caller.Object, CancellationToken.None); | ||
|
||
result.Should().BeSuccess(); | ||
result.Value.Id.Should().Be("acallerid"); | ||
result.Value.IsMfaEnabled.Should().BeTrue(); | ||
result.Value.HasCredentials.Should().BeTrue(); | ||
} | ||
} |
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
Oops, something went wrong.