public void Catch_and_log_exception_when_createclient_with_invalid_string_url(string url) { // Act try { var result = _provider.CreateClient(url); Assert.Fail(); } catch (Exception) { } // Assert _loggerProvider.Verify(m => m.Log(It.IsAny <Exception>()), Times.Once); }
public async Task ShouldNotGetTokenForNonExistingClient() { var httpClient = HttpClientProvider.CreateClient(); var discoveryDocument = await HttpClientProvider.GetDiscoveryDocumentAsync(); var token = await httpClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest() { Address = discoveryDocument.TokenEndpoint, ClientId = "non-existing-client", ClientSecret = "non-existing-client-secret" }); token.IsError.Should().BeTrue(); }
public async Task ShouldBeAbleToGetTokenForClient() { var httpClient = HttpClientProvider.CreateClient(); var discoveryDocument = await HttpClientProvider.GetDiscoveryDocumentAsync(); var token = await httpClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest() { Address = discoveryDocument.TokenEndpoint, ClientId = "modular-monolith-client", ClientSecret = "modular-monolith-client-secret" }); token.IsError.Should().BeFalse(); token.AccessToken.Should().NotBeNullOrWhiteSpace(); }