コード例 #1
0
ファイル: ClientTests.cs プロジェクト: jerriep/auth0.net
        public async Task Test_client_crud_sequence()
        {
            var scopes = new
            {
                clients = new
                {
                    actions = new string[] { "read", "create", "delete", "update" }
                },
                client_keys = new
                {
                    actions = new string[] { "read", "update" }
                }
            };
            string token = GenerateToken(scopes);

            var apiClient = new ManagementApiClient(token, new Uri(GetVariable("AUTH0_MANAGEMENT_API_URL")));

            // Get all clients
            var clientsBefore = await apiClient.Clients.GetAllAsync();

            // Add a new client
            var newClientRequest = new ClientCreateRequest
            {
                Name = $"Integration testing {Guid.NewGuid().ToString("N")}"
            };
            var newClientResponse = await apiClient.Clients.CreateAsync(newClientRequest);
            newClientResponse.Should().NotBeNull();
            newClientResponse.Name.Should().Be(newClientRequest.Name);

            // Get all clients again, and ensure we have one client more
            var clientsAfter = await apiClient.Clients.GetAllAsync();
            clientsAfter.Count.Should().Be(clientsBefore.Count + 1);

            // Update the client
            var updateClientRequest = new ClientUpdateRequest
            {
                Name = $"Integration testing {Guid.NewGuid().ToString("N")}"
            };
            var updateClientResponse = await apiClient.Clients.UpdateAsync(newClientResponse.ClientId, updateClientRequest);
            updateClientResponse.Should().NotBeNull();
            updateClientResponse.Name.Should().Be(updateClientRequest.Name);

            // Get a single client
            var client = await apiClient.Clients.GetAsync(newClientResponse.ClientId);
            client.Should().NotBeNull();
            client.Name.Should().Be(updateClientResponse.Name);

            // Delete the client, and ensure we get exception when trying to fetch client again
            await apiClient.Clients.DeleteAsync(client.ClientId);
            Func<Task> getFunc = async () => await apiClient.Clients.GetAsync(client.ClientId);
            getFunc.ShouldThrow<ApiException>().And.ApiError.ErrorCode.Should().Be("inexistent_client");
        }
コード例 #2
0
ファイル: ClientsClient.cs プロジェクト: jerriep/auth0.net
 /// <summary>
 /// Creates a new client application.
 /// </summary>
 /// <param name="request">The request containing the properties of the new client.</param>
 /// <returns>Task&lt;Core.Client&gt;.</returns>
 public Task<Core.Client> CreateAsync(ClientCreateRequest request)
 {
     return Connection.PostAsync<Core.Client>("clients", request, null, null, null, null, null);
 }
コード例 #3
0
ファイル: ClientsClient.cs プロジェクト: jerriep/auth0.net
 public Task<Core.Client> Create(ClientCreateRequest request)
 {
     return CreateAsync(request);
 }