Example #1
0
        public async Task CanAddClient()
        {
            // arrange
            var httpClient     = new ClientsHttpClient(this.Authority, this.Handler);
            var expectedClient = new Client
            {
                Id                          = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture),
                Name                        = $"{nameof(ClientManagement)}.{nameof(this.CanAddClient)} (integration test)",
                Secret                      = "secret",
                AllowedCorsOrigins          = { "http://localhost:5005" },
                RedirectUris                = { "http://localhost:5005/redirect" },
                PostLogoutRedirectUris      = { "http://localhost:5005/post-logout-redirect" },
                AllowedScopes               = { "role", "name" },
                AccessTokenType             = "Reference",
                AllowedGrantTypes           = { "implicit", "custom" },
                AllowAccessTokensViaBrowser = true,
                AllowOfflineAccess          = true,
                RequireClientSecret         = false,
                RequirePkce                 = true,
                RequireConsent              = false,
                Enabled                     = false,
            };

            // act
            await httpClient.AddClientAsync(expectedClient).ConfigureAwait(false);

            // assert
            var actualClient = await httpClient.GetClientAsync(expectedClient.Id).ConfigureAwait(false);

            actualClient.Should().NotBeNull();
            actualClient.Should().BeEquivalentTo(expectedClient, options => options.Excluding(client => client.Secret));
        }
Example #2
0
        public async Task CanAddClientMinimum()
        {
            // arrange
            var httpClient     = new ClientsHttpClient(this.Authority, this.Handler);
            var expectedClient = new Client
            {
                Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture),
            };

            // act
            await httpClient.AddClientAsync(expectedClient).ConfigureAwait(false);

            // assert
            var actualClient = await httpClient.GetClientAsync(expectedClient.Id).ConfigureAwait(false);

            actualClient.Should().NotBeNull();
            actualClient.Id.Should().Be(expectedClient.Id);
        }