Exemple #1
0
        public async Task CanModifyClient()
        {
            // arrange
            var httpClient     = new ClientsHttpClient(this.Authority, this.Handler);
            var originalClient = new Client
            {
                Id                          = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture),
                Name                        = $"{nameof(ClientManagement)}.{nameof(this.CanModifyClient)} (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,
            };

            var expectedClient = new Client
            {
                Id   = originalClient.Id,
                Name = $"{nameof(ClientManagement)}.{nameof(this.CanModifyClient)} (integration test) #2",
                AllowedCorsOrigins          = { "http://localhost:5006" },
                RedirectUris                = { "http://localhost:5006/redirect" },
                PostLogoutRedirectUris      = { "http://localhost:5006/post-logout-redirect" },
                AllowedScopes               = { "profile" },
                AccessTokenType             = "Jwt",
                AllowedGrantTypes           = { "hybrid" },
                AllowAccessTokensViaBrowser = false,
                AllowOfflineAccess          = false,
                RequireClientSecret         = true,
                RequirePkce    = false,
                RequireConsent = true,
                Enabled        = true,
            };

            await httpClient.AddClientAsync(originalClient).ConfigureAwait(false);

            // act
            await httpClient.ModifyClientAsync(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));
        }
Exemple #2
0
        public void CannotModifyAuthorizationServerManagementConsole()
        {
            // arrange
            var httpClient = new ClientsHttpClient(this.Authority, this.Handler);
            var client     = new Client
            {
                Id            = "auth_console",
                AllowedScopes = { "openid" },
            };

            // act
            Func <Task> func = async() => await httpClient.ModifyClientAsync(client).ConfigureAwait(false);

            // assert
            func.Should().Throw <HttpException>().And.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }