public async Task PlatformServiceSuccess() { var tokenRefresherMock = new Mock <ITokenRefresher>(); const string platformJwt = "platform-dancing"; tokenRefresherMock .Setup(x => x.GetJwtTokenAsync(It.IsAny <CancellationToken>())) .ReturnsAsync(new AuthenticationToken { Type = "Bearer", AccessToken = platformJwt, ExpiresOn = DateTimeOffset.UtcNow.AddHours(1) }); var helper = new ServiceAuthenticationHelper(tokenRefresherMock.Object); var auth = new ClientAuthorizationSettings { AuthorizationType = ClientAuthorizationSettings.AuthorizationTypeEnum.NexusPlatformService }; var result = await helper.GetAuthorizationForClientAsync(Tenant, auth, ClientName); Assert.IsNotNull(result, JsonConvert.SerializeObject(auth, Formatting.Indented)); Assert.AreEqual("bearer", result.Type.ToLowerInvariant()); Assert.AreEqual(platformJwt, result.Token, result.Token); }
public async Task DefaultType() { var result = await _authenticationHelper.GetAuthorizationForClientAsync(Tenant, LeverConfiguration, "unknown-client"); Assert.IsNull(result); }
public async Task BearerTokenSuccess() { var auth = new ClientAuthorizationSettings { AuthorizationType = ClientAuthorizationSettings.AuthorizationTypeEnum.BearerToken, Token = Jwt }; var result = await _authenticationHelper.GetAuthorizationForClientAsync(Tenant, auth, ClientName); Assert.IsNotNull(result, JsonConvert.SerializeObject(auth, Formatting.Indented)); Assert.AreEqual("bearer", result.Type.ToLowerInvariant()); Assert.AreEqual(Jwt, result.Token, result.Token); }