Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
        }