public void When_Passing_Null_Parameters_To_ClientSecretJwtAuth_Then_Exceptions_Are_Thrown() { // ARRANGE InitializeFakeObjects(); // ACT & ASSERT Assert.Throws <ArgumentNullException>(() => _clientAuthSelector.UseClientSecretJwtAuth(null, null)); Assert.Throws <ArgumentNullException>(() => _clientAuthSelector.UseClientSecretJwtAuth("client_id", null)); }
public async Task When_Using_ClientSecretJwtAuthentication_Then_AccessToken_Is_Returned() { // ARRANGE InitializeFakeObjects(); _httpClientFactoryStub.Setup(h => h.GetHttpClient()).Returns(_server.Client); var payload = new JwsPayload { { StandardClaimNames.Issuer, "jwt_client" }, { Core.Jwt.Constants.StandardResourceOwnerClaimNames.Subject, "jwt_client" }, { StandardClaimNames.Audiences, new [] { "http://localhost:5000" } }, { StandardClaimNames.ExpirationTime, DateTime.UtcNow.AddHours(1).ConvertToUnixTimestamp() } }; var jws = _jwsGenerator.Generate(payload, JwsAlg.RS256, _server.SharedCtx.SignatureKey); var jwe = _jweGenerator.GenerateJweByUsingSymmetricPassword(jws, JweAlg.RSA1_5, JweEnc.A128CBC_HS256, _server.SharedCtx.EncryptionKey, "jwt_client"); // ACT var token = await _clientAuthSelector.UseClientSecretJwtAuth(jwe, "jwt_client") .UseClientCredentials("api1") .ResolveAsync(baseUrl + "/.well-known/openid-configuration"); // ASSERTS Assert.NotNull(token); }