Пример #1
0
        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"));
            }
        }
Пример #2
0
        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");
            }
        }