public void TestUpdateExpiredSession() { var oldProfile = Given .UserSession(Session) .When .GetCurrentUserRequestIsSend() .GetResultData <TestUserModel>(BddKeyConstants.CurrentUserResponse); var updateModel = new TestUserUpdateModel { FirstName = null, LastName = null }; Given .DefaultUserLoginCredentials() .UserSession(Session) .When .LogoutRequestIsSend() .UpdateUserRequestIsSend(updateModel) .WithCode(HttpStatusCode.Unauthorized) .LoginRequestIsSend() .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(oldProfile) .LogoutIfSessionTokenIsPresent(); }
public static WhenStatement UpdateUserRequestIsSend(this WhenStatement whenStatement, TestUserUpdateModel updateModel, string testKey = null) { whenStatement.GetStatementLogger() .Information("[{ContextStatement}] Getting current user", whenStatement.GetType().Name); var session = whenStatement.GetSessionFromData(testKey); var response = _facade.PostUpdateProfileNames(session, updateModel); whenStatement.AddResultData(response, BddKeyConstants.LastHttpResponse + testKey); return(whenStatement); }
public HttpResponseMessage PostUpdateProfileNames(string tokenValue, TestUserUpdateModel updateUser) { using (HttpClient client = HttpClientFactory.Create()) { client.DefaultRequestHeaders .Accept .Add(new MediaTypeWithQualityHeaderValue(CommonHttpConstants.ApplicationJsonMedia)); if (tokenValue != null) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(CommonHttpConstants.AuthorizationHeader, tokenValue); } return(client.LogAndPost($"{BaseApiRoute}/{UpdateNamesRoute}", new StringContent(updateUser.ToString(), Encoding.UTF8, CommonHttpConstants.ApplicationJsonMedia), Logger)); } }
public void TestDoubleUpdate() { var oldProfile = Given .UserSession(Session) .When .GetCurrentUserRequestIsSend() .GetResultData <TestUserModel>(BddKeyConstants.CurrentUserResponse); var updateModel = new TestUserUpdateModel { FirstName = TestStringHelper.RandomLatinString(), LastName = TestStringHelper.RandomLatinString() }; oldProfile.ApplyUpdate(updateModel); Given .UserSession(Session) .When .UpdateUserRequestIsSend(updateModel) .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(oldProfile); updateModel = new TestUserUpdateModel { FirstName = TestStringHelper.RandomLatinString(), LastName = TestStringHelper.RandomLatinString() }; oldProfile.ApplyUpdate(updateModel); Given .UserSession(Session) .When .UpdateUserRequestIsSend(updateModel) .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(oldProfile); }
public void TestSmokeForNewUserAfterUpdateMe() { var userModel = new TestUserModel { Email = $"{TestStringHelper.RandomLatinString()}@example.com", Password = TestStringHelper.RandomLatinString(), FirstName = TestStringHelper.RandomLatinString(), LastName = TestStringHelper.RandomLatinString(), }; var updateModel = new TestUserUpdateModel { FirstName = TestStringHelper.RandomLatinString(), LastName = TestStringHelper.RandomLatinString() }; var whenLoggedIn = Given .NewUserData(userModel) .UserLoginCredentials(new TestLoginModel { Email = userModel.Email, Password = userModel.Password, }) .When .CreateUserRequestIsSend() .LoginRequestIsSend(); whenLoggedIn .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(userModel); whenLoggedIn .UpdateUserRequestIsSend(updateModel) .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(userModel.ApplyUpdate(updateModel)) .LogoutIfSessionTokenIsPresent(); }
public void TestUpdateAllNulls() { var oldProfile = Given .UserSession(Session) .When .GetCurrentUserRequestIsSend() .GetResultData <TestUserModel>(BddKeyConstants.CurrentUserResponse); var updateModel = new TestUserUpdateModel { FirstName = null, LastName = null }; Given .UserSession(Session) .When .UpdateUserRequestIsSend(updateModel) .WithCode(HttpStatusCode.BadRequest) .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(oldProfile); }
public void TestUpdateOnlyLastName() { var oldProfile = Given .UserSession(Session) .When .GetCurrentUserRequestIsSend() .GetResultData <TestUserModel>(BddKeyConstants.CurrentUserResponse); var updateModel = new TestUserUpdateModel { FirstName = string.Empty, LastName = TestStringHelper.RandomLatinString() }; Given .UserSession(Session) .When .UpdateUserRequestIsSend(updateModel) .WithCode(HttpStatusCode.BadRequest) .GetCurrentUserRequestIsSend() .Then .CurrentUserIsEqualTo(oldProfile); }
public TestUserModel ApplyUpdate(TestUserUpdateModel updateModel) { FirstName = updateModel.FirstName; LastName = updateModel.LastName; return(this); }