/// <summary> /// Updates a resource server /// </summary> /// <param name="id">The id of the resource server to update</param> /// <param name="request">Contains the information for the resource server to update</param> /// <returns></returns> public Task <ResourceServer> UpdateAsync(string id, ResourceServerUpdateRequest request) { return(Connection.PatchAsync <ResourceServer>("resource-servers/{id}", request, new Dictionary <string, string> { { "id", id } })); }
public async Task Test_resource_server_crud_sequence() { string token = await GenerateManagementApiToken(); var apiClient = new ManagementApiClient(token, GetVariable("AUTH0_MANAGEMENT_API_URL")); // Add a new resource server var identifier = Guid.NewGuid(); var newResourceServerRequest = new ResourceServerCreateRequest() { Identifier = identifier.ToString("N"), Name = $"Integration testing {identifier:N}", TokenLifetime = 1, SigningAlgorithm = SigningAlgorithm.HS256, SigningSecret = "thisismysecret0123456789", Scopes = new List <ResourceServerScope> { new ResourceServerScope { Value = "scope1", Description = "Scope number 1" } } }; var newResourceServerResponse = await apiClient.ResourceServers.CreateAsync(newResourceServerRequest); newResourceServerResponse.ShouldBeEquivalentTo(newResourceServerRequest, options => options.Excluding(rs => rs.Id)); // Update the resource server var resourceServerRequest = new ResourceServerUpdateRequest() { Name = $"Integration testing {Guid.NewGuid():N}", TokenLifetime = 1, SigningAlgorithm = SigningAlgorithm.HS256, SigningSecret = "thisismysecret0123456789", Scopes = new List <ResourceServerScope> { new ResourceServerScope { Value = "scope1", Description = "Scope number 1" }, new ResourceServerScope { Value = "scope2", Description = "Scope number 2" } } }; var updateResourceServerResponse = await apiClient.ResourceServers.UpdateAsync(newResourceServerResponse.Id, resourceServerRequest); updateResourceServerResponse.ShouldBeEquivalentTo(resourceServerRequest, options => options.ExcludingMissingMembers()); // Get a single resource server var resourceServer = await apiClient.ResourceServers.GetAsync(newResourceServerResponse.Id); resourceServer.ShouldBeEquivalentTo(resourceServerRequest, options => options.ExcludingMissingMembers()); // Delete the client, and ensure we get exception when trying to fetch client again await apiClient.ResourceServers.DeleteAsync(resourceServer.Id); Func <Task> getFunc = async() => await apiClient.ResourceServers.GetAsync(resourceServer.Id); getFunc.ShouldThrow <ApiException>().And.ApiError.ErrorCode.Should().Be("inexistent_resource_server"); }
public async Task Test_resource_server_crud_sequence() { // Add a new resource server var identifier = Guid.NewGuid(); var createResourceServerRequest = new ResourceServerCreateRequest() { Identifier = identifier.ToString("N"), Name = $"Integration testing {identifier:N}", TokenLifetime = 1, TokenLifetimeForWeb = 1, SigningAlgorithm = SigningAlgorithm.HS256, SigningSecret = "thisismysecret0123456789", Scopes = new List <ResourceServerScope> { new ResourceServerScope { Value = "scope1", Description = "Scope number 1" } }, AllowOfflineAccess = true, //EnforcePolicies = true, //TokenDialect = TokenDialect.AccessTokenAuthZ, VerificationLocation = "https://abc.auth0.com/def", SkipConsentForVerifiableFirstPartyClients = true, }; var newResourceServerResponse = await _apiClient.ResourceServers.CreateAsync(createResourceServerRequest); newResourceServerResponse.Should().BeEquivalentTo(createResourceServerRequest, options => options.Excluding(rs => rs.Id)); // Update the resource server var updateResourceServerRequest = new ResourceServerUpdateRequest() { Name = $"Integration testing {Guid.NewGuid():N}", TokenLifetime = 2, TokenLifetimeForWeb = 1, SigningAlgorithm = SigningAlgorithm.HS256, SigningSecret = "thisismysecret0123456789", Scopes = new List <ResourceServerScope> { new ResourceServerScope { Value = "scope1", Description = "Scope number 1" }, new ResourceServerScope { Value = "scope2", Description = "Scope number 2" } }, AllowOfflineAccess = false, EnforcePolicies = false, TokenDialect = TokenDialect.AccessToken, VerificationLocation = "", SkipConsentForVerifiableFirstPartyClients = false, }; var updateResourceServerResponse = await _apiClient.ResourceServers.UpdateAsync(newResourceServerResponse.Id, updateResourceServerRequest); updateResourceServerResponse.Should().BeEquivalentTo(updateResourceServerRequest, options => options.ExcludingMissingMembers()); // Get a single resource server var resourceServer = await _apiClient.ResourceServers.GetAsync(newResourceServerResponse.Id); resourceServer.Should().BeEquivalentTo(updateResourceServerRequest, options => options.ExcludingMissingMembers()); // Delete the client, and ensure we get exception when trying to fetch client again await _apiClient.ResourceServers.DeleteAsync(resourceServer.Id); Func <Task> getFunc = async() => await _apiClient.ResourceServers.GetAsync(resourceServer.Id); getFunc.Should().Throw <ApiException>().And.ApiError.ErrorCode.Should().Be("inexistent_resource_server"); }
/// <summary> /// Updates a resource server, /// </summary> /// <param name="id">The id of the resource server to update.</param> /// <param name="request">Contains the information for the resource server to update.</param> /// <returns>The newly updated <see cref="ResourceServer"/>.</returns> public Task <ResourceServer> UpdateAsync(string id, ResourceServerUpdateRequest request) { return(Connection.SendAsync <ResourceServer>(new HttpMethod("PATCH"), BuildUri($"resource-servers/{EncodePath(id)}"), request, DefaultHeaders)); }