-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* API changed a bit before release, readmefile, version bump * updated tests * updated tests * small code cleanup
- Loading branch information
Showing
6 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/QAToolKit.Auth.Test/Keycloak/KeycloakAuthenticatorTests.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,41 @@ | ||
using NSubstitute; | ||
using QAToolKit.Core.Interfaces; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace QAToolKit.Auth.Test.Keycloak | ||
{ | ||
public class KeycloakAuthenticatorTests | ||
{ | ||
[Fact] | ||
public async Task CreateAuthenticatonServiceTest_Success() | ||
{ | ||
var authenticator = Substitute.For<IAuthenticationService>(); | ||
await authenticator.GetAccessToken(); | ||
Assert.Single(authenticator.ReceivedCalls()); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateAuthenticatonServiceWithReturnsTest_Success() | ||
{ | ||
var authenticator = Substitute.For<IAuthenticationService>(); | ||
authenticator.GetAccessToken().Returns(args => "12345"); | ||
|
||
Assert.Equal("12345", await authenticator.GetAccessToken()); | ||
Assert.Single(authenticator.ReceivedCalls()); | ||
} | ||
|
||
[Fact] | ||
public void CreateKeycloakOptionsTest_Success() | ||
{ | ||
var options = new KeycloakOptions(); | ||
options.AddClientCredentialFlowParameters(new Uri("https://api.com/token"), "12345", "12345"); | ||
options.AddUserNameForImpersonation("myemail@email.com"); | ||
|
||
var keycloakOptions = Substitute.For<Action<KeycloakOptions>>(); | ||
keycloakOptions.Invoke(options); | ||
Assert.Single(keycloakOptions.ReceivedCalls()); | ||
} | ||
} | ||
} |
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