public async Task PostAccountRegiser_WeakPassword_BadRequest() { // Arrange var body = JsonStringBuilder.RegisterJsonBody("The Message", "*****@*****.**", "onlylowercases"); var content = new StringContent(body); var path = $"{Routes.AccountRoute}/register"; // Act var response = await _endSystems.Post(path, content); // Assert Assert.Equal(HttpStatusCode.BadRequest, response.Code); // Tear down _endSystems.Dispose(); }
public async Task PostAccountRegiser_EmailInUse_Unauthorized() { // Arrange var user = MockApplicationUsers.Get(8); var body = JsonStringBuilder.RegisterJsonBody(user.Name, user.Email, MockApplicationUsers.UniversalPassword); var content = new StringContent(body); var path = $"{Routes.AccountRoute}/register"; // Act var response = await _endSystems.Post(path, content); // Assert Assert.Equal(HttpStatusCode.Unauthorized, response.Code); // Tear down _endSystems.Dispose(); }
public async Task PostAccountRegiser_ValidNewUser_CreatedAndToken() { // Arrange var user = new ApplicationUser { Name = "The Clash", Email = "*****@*****.**", UserName = "******" }; var registerBody = JsonStringBuilder.RegisterJsonBody ( user.Name, user.Email, MockApplicationUsers.UniversalPassword ); var loginBody = JsonStringBuilder.LoginJsonBody ( user.Email, MockApplicationUsers.UniversalPassword ); var registerContent = new StringContent(registerBody); var loginContent = new StringContent(loginBody); var registerPath = $"{Routes.AccountRoute}/register"; var loginPath = $"{Routes.AccountRoute}/login"; // Act var registerResponse = await _endSystems.Post(registerPath, registerContent); var loginResponse = await _endSystems.Post(loginPath, loginContent); var registerToken = JToken.Parse(registerResponse.Body).ToString(); var loginToken = JToken.Parse(loginResponse.Body).ToString(); // Assert Assert.Equal(HttpStatusCode.Created, registerResponse.Code); Assert.Equal(HttpStatusCode.OK, loginResponse.Code); CheckToken(MockRoles.User, user, registerToken, false); CheckToken(MockRoles.User, user, loginToken, false); // Tear down _endSystems.Dispose(); }