public async Task TestGetPaymentsApiInvalidCredentials() { var authenticationManager = new PaymentSystem.Manager.AuthenticationManager(_databaseContext); using (var client = new TestClientProvider().Client) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authenticationManager.Authenticate("usertest1", "password2")); // this test should be unauthorize since paswword is incorrect var response = await client .GetAsync("/api/payments/getpayments"); response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); } }
public async Task TestAuthenticateApiInvalidCredentials() { using (var client = new TestClientProvider().Client) { var response = await client.PostAsync("/api/account/authenticate" , new StringContent( JsonConvert.SerializeObject(new UserCredentials() { Username = "******", Password = "******" // this test should be unauthorize since paswword is incorrect }), Encoding.UTF8, "application/json")); response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); } }
public async Task TestAuthenticateApi() { using (var client = new TestClientProvider().Client) { var response = await client.PostAsync("/api/account/authenticate" , new StringContent( JsonConvert.SerializeObject(new UserCredentials() { Username = "******", Password = "******" }), Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); response.StatusCode.Should().Be(HttpStatusCode.OK); } }