private async Task <HttpResponseMessage> CreateNewClient(IS4.Client testClient) { var stringContent = new StringContent(JsonConvert.SerializeObject(testClient), Encoding.UTF8, "application/json"); var response = await HttpClient.PostAsync("/api/Client", stringContent); return(response); }
public async Task TestCreateClient_Success(IS4.Client testClient) { HttpResponseMessage response = await CreateNewClient(testClient); Assert.Equal(HttpStatusCode.Created, response.StatusCode); var content = await response.Content.ReadAsStringAsync(); var client = (Client)JsonConvert.DeserializeObject(content, typeof(Client)); Assert.Equal(testClient.ClientId, client.ClientId); Assert.NotNull(client.ClientSecret); }
private async Task<Client> UpdateClient(IS4.Client testClient) { // Update the client var stringContent = new StringContent(JsonConvert.SerializeObject(testClient), Encoding.UTF8, "application/json"); var httpClient = await HttpClient; var response = await httpClient.PutAsync($"/api/Client/{testClient.ClientId}", stringContent); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); // Get the client and confirm expectations response = await httpClient.SendAsync(new HttpRequestMessage(new HttpMethod("GET"), $"/api/Client/{testClient.ClientId}")); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var content = await response.Content.ReadAsStringAsync(); var updatedClient = (Client)JsonConvert.DeserializeObject(content, typeof(Client)); Assert.Equal(testClient.AllowedScopes.Count, updatedClient.AllowedScopes.Count); return updatedClient; }