public async Task Login_Ok() { var user = new DTO.User() { Email = "*****@*****.**", Password = "******" }; var response = await DoLogin(user); response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); }
/// <summary> /// Get Access Token from POST - api/login /// </summary> /// <returns>DTO Token</returns> private async Task <DTO.Token> GetToken() { var _user = new DTO.User() { Email = "*****@*****.**", Password = "******" }; var user = new StringContent(JsonConvert.SerializeObject(_user, Fixture.SerializerSettings), Encoding.UTF8, "application/json"); var response = await Fixture.HttpClient.PostAsync("api/login", user); var content = await response.Content.ReadAsStringAsync(); var json = JObject.Parse(content); return(JsonConvert.DeserializeObject <DTO.Token>(json["value"].ToString(), Fixture.SerializerSettings)); }
/// <summary> /// Method to do the Login Request POST api/login /// </summary> /// <param name="user">User DTO</param> /// <returns>HttpResponseMessage</returns> private async Task <HttpResponseMessage> DoLogin(DTO.User user) { var payload = new StringContent(JsonConvert.SerializeObject(user, Fixture.SerializerSettings), Encoding.UTF8, "application/json"); return(await Fixture.HttpClient.PostAsync("api/login", payload)); }
public async Task Login_Invalid_Data_NOk(DTO.User user) { var response = await DoLogin(user); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task <IActionResult> Login(DTO.User user) { return(Ok(await _loginService.Authenticate(new Entities.User(user)))); }
public User(DTO.User user) { Email = user.Email; Password = user.Password; }