Пример #1
0
 /// <summary>
 /// Updates a client grant
 /// </summary>
 /// <param name="id">The identifier of the client grant to update.</param>
 /// <param name="request">The <see cref="ClientGrantUpdateRequest"/> containing the properties to update.</param>
 /// <returns></returns>
 public Task <ClientGrant> UpdateAsync(string id, ClientGrantUpdateRequest request)
 {
     return(Connection.PatchAsync <ClientGrant>("client-grants/{id}", request, new Dictionary <string, string>
     {
         { "id", id }
     }));
 }
Пример #2
0
        public async Task Test_client_credentials_crud_sequence()
        {
            // Get all the current client grants
            var clientGrantsBefore = await _apiClient.ClientGrants.GetAllAsync();

            // Add a new client grant
            var newClientGrantRequest = new ClientGrantCreateRequest
            {
                ClientId = _client.ClientId,
                Audience = _resourceServer.Identifier,
                Scope    = new List <string>
                {
                    "scope1",
                    "scope2"
                }
            };
            var newClientGrantResponse = await _apiClient.ClientGrants.CreateAsync(newClientGrantRequest);

            newClientGrantResponse.Should().NotBeNull();
            newClientGrantResponse.ShouldBeEquivalentTo(newClientGrantRequest,
                                                        options => options.Excluding(cg => cg.Id));

            // Get all the client grants again, and verify we have one more
            var clientGrantsAfter = await _apiClient.ClientGrants.GetAllAsync();

            clientGrantsAfter.Count.Should().Be(clientGrantsBefore.Count + 1);

            // Update the client grant
            var updateClientGrantRequest = new ClientGrantUpdateRequest
            {
                Scope = new List <string>
                {
                    "scope3"
                }
            };
            var updateClientGrantResponse =
                await _apiClient.ClientGrants.UpdateAsync(newClientGrantResponse.Id, updateClientGrantRequest);

            updateClientGrantResponse.Should().NotBeNull();
            updateClientGrantResponse.Scope.Count.Should().Be(1);
            updateClientGrantResponse.Scope[0].Should().Be("scope3");

            // Delete the client grant
            await _apiClient.ClientGrants.DeleteAsync(newClientGrantResponse.Id);
        }
Пример #3
0
 /// <summary>
 /// Updates a client grant.
 /// </summary>
 /// <param name="id">The identifier of the client grant to update.</param>
 /// <param name="request">The <see cref="ClientGrantUpdateRequest"/> containing the properties to update.</param>
 /// <returns>The <see cref="ClientGrant"/> that has been updated.</returns>
 public Task <ClientGrant> UpdateAsync(string id, ClientGrantUpdateRequest request)
 {
     return(Connection.SendAsync <ClientGrant>(new HttpMethod("PATCH"), BuildUri($"client-grants/{id}"), request, DefaultHeaders));
 }