-
-
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.
Associate and Disassociate MFA factors for OOBSMS, OOBEmail and TOTP …
…Authenticator
- Loading branch information
1 parent
547b2ea
commit 0bb86d1
Showing
31 changed files
with
889 additions
and
464 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -592,6 +592,44 @@ await _application.AssociateMfaAuthenticatorAsync(_caller.Object, null, | |
"anoobcode", It.IsAny<IReadOnlyList<string>>(), It.IsAny<CancellationToken>())); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenAssociateMfaAuthenticatorAsyncForSecondAuthenticator_ThenAssociatesWithoutRecoveryCodes() | ||
{ | ||
_caller.Setup(cc => cc.IsAuthenticated) | ||
.Returns(true); | ||
_caller.Setup(cc => cc.CallId) | ||
.Returns("acallid"); | ||
_caller.Setup(cc => cc.CallerId) | ||
.Returns("auserid"); | ||
var credential = CreateVerifiedCredential(); | ||
credential.ChangeMfaEnabled("auserid".ToId(), true); | ||
credential.InitiateMfaAuthentication(); | ||
_repository.Setup(s => | ||
s.FindCredentialsByUserIdAsync(It.IsAny<Identifier>(), It.IsAny<CancellationToken>())) | ||
.ReturnsAsync(credential.ToOptional()); | ||
await _application.AssociateMfaAuthenticatorAsync(_caller.Object, null, | ||
PasswordCredentialMfaAuthenticatorType.OobSms, "[email protected]", | ||
CancellationToken.None); | ||
|
||
var result = | ||
await _application.AssociateMfaAuthenticatorAsync(_caller.Object, null, | ||
PasswordCredentialMfaAuthenticatorType.OobEmail, null, | ||
CancellationToken.None); | ||
|
||
result.Should().BeSuccess(); | ||
result.Value.Type.Should().Be(PasswordCredentialMfaAuthenticatorType.OobEmail); | ||
result.Value.RecoveryCodes.Should().BeNull(); | ||
_endUsersService.Verify(eus => | ||
eus.GetUserPrivateAsync(_caller.Object, "auserid", | ||
It.IsAny<CancellationToken>())); | ||
_userProfilesService.Verify(ups => | ||
ups.GetProfilePrivateAsync(It.Is<ICallerContext>(cc => cc.CallId == "acallid"), "auserid", | ||
It.IsAny<CancellationToken>())); | ||
_userNotificationsService.Verify(ns => | ||
ns.NotifyPasswordMfaOobEmailAsync(_caller.Object, "[email protected]", | ||
"anoobcode", It.IsAny<IReadOnlyList<string>>(), It.IsAny<CancellationToken>())); | ||
} | ||
|
||
private PasswordCredentialRoot CreateUnVerifiedCredential() | ||
{ | ||
var credential = CreateCredential(); | ||
|
Oops, something went wrong.