private async Task <string> Login(string username) { var uri = "/"; var jsonContent = new Helpers.JsonContent(new { username = username, password = "******", }); using (var client = factory.CreateClient()) { var response = await client.PostAsync(uri, jsonContent); var content = await response.Content.ReadAsStringAsync(); var jtoken = JToken.Parse(content); return(jtoken.Value <string>("token")); } }
public async Task Testユーザ名をPOSTするとJWTが返る() { // Given var uri = "/"; var jsonContent = new Helpers.JsonContent(new { username = "******", password = "******", }); using (var client = factory.CreateClient()) { // When var response = await client.PostAsync(uri, jsonContent); // Then response.IsSuccessStatusCode.Should().BeTrue(); var content = await response.Content.ReadAsStringAsync(); var actual = JToken.Parse(content); actual.Should().HaveElement("token"); } }