public async Task User_should_be_able_to_change_password() { var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var passwordRequest = new PasswordForgottenRequest { Username = createdResult.Data.First().Username }; var tokenResult = await UserManagementApi.GetPasswordResetToken(passwordRequest); var tokenData = tokenResult.Data.First(); var newPasswordRequest = new PasswordForgottenNewPassword { Username = tokenData.Username, Token = tokenData.Token, Password = "******" }; var changePasswordResult = await UserManagementApi.SetNewPasswordAfterReset(newPasswordRequest); Assert.True(createdResult.Success); Assert.True(tokenResult.Success); Assert.True(changePasswordResult.Success); }
public async Task User_should_be_deleted() { var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var deleteResult = await UserManagementApi.DeleteUser(createdResult.Data.First().Id); Assert.True(createdResult.Success); Assert.True(deleteResult.Success); }
public async Task Created_user_dto_should_match_fetched_by_id_dto() { var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var fetchResult = await UserManagementApi.GetUserById(createdResult.Data.First().Id); Assert.True(createdResult.Success); Assert.True(fetchResult.Success); Assert.Equal(createdResult.Data, fetchResult.Data); }
public async Task Created_user_dto_should_match_fetched_by_username_dto() { var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = createdResult.Data.First(); var fetchResult = await UserManagementApi.Search(new UsersTenantSearch(username : userData.Username)); Assert.True(createdResult.Success); Assert.True(fetchResult.Success); Assert.Contains(createdResult.Data.First(), fetchResult.Data); }
public async Task Created_user_dto_should_match_original_dto() { var userDto = GetUniqueTestUser; var createdResult = await UserManagementApi.CreateUser(userDto); var userData = createdResult.Data.First(); Assert.True(createdResult.Success); Assert.Equal(userDto.Email, userData.Email); Assert.Equal(userDto.Username, userData.Username); Assert.Equal(userDto.AdditionalDataJson, userData.AdditionalDataJson); }
public async Task User_should_be_assigned_to_role() { var userResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = userResult.Data.First(); await LoadRoles(); var roleAddResult = await UserManagementApi.AddUserToRole(userData.Id, Role1.Id); Assert.True(userResult.Success); Assert.True(roleAddResult.Success); }
public async Task Getting_user_by_multiple_params_should_work() { var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = createdResult.Data.First(); var fetchResult1 = await UserManagementApi.GetUserById(userData.Id); var fetchResult2 = await UserManagementApi.Search(new UsersTenantSearch(username : userData.Username)); Assert.True(createdResult.Success); Assert.True(fetchResult1.Success); Assert.True(fetchResult2.Success); }
public async Task Getting_profile_should_work() { var userDto = GetUniqueTestUser; await UserManagementApi.CreateUser(userDto); var tokenRequest = TokenRequest.PasswordTokenRequest(ClientId, userDto.Username, userDto.Password); var restResult = await restClient.Post <IdentityUtilsResult <TokenResponse> >($"{BaseUrl}/auth/token", tokenRequest); var accessToken = restResult.ResponseData.Data.First().AccessToken; var profileRestResult = await restClient.Get <IdentityUtilsResult <UserProfile> >($"{BaseUrl}/auth/init", accessToken); Assert.True(profileRestResult.Success); Assert.True(profileRestResult.ResponseData.Success); Assert.NotEmpty(profileRestResult.ResponseData.Data); }
public async Task Getting_auth_token_should_work() { var userDto = GetUniqueTestUser; await UserManagementApi.CreateUser(userDto); var tokenRequest = TokenRequest.PasswordTokenRequest(ClientId, userDto.Username, userDto.Password); var restResult = await restClient.Post <IdentityUtilsResult <TokenResponse> >($"{BaseUrl}/auth/token", tokenRequest); var tokenData = restResult.ResponseData?.Data?.FirstOrDefault(); Assert.True(restResult.Success); Assert.True(restResult.ResponseData.Success); Assert.NotNull(tokenData); Assert.NotEmpty(tokenData.AccessToken); Assert.NotEmpty(tokenData.RefreshToken); }
public async Task User_should_be_updated() { var createdResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userDto = createdResult.Data.First(); userDto.Email = "*****@*****.**"; var updatedResult = await UserManagementApi.UpdateUser(userDto); var fetchResult = await UserManagementApi.GetUserById(userDto.Id); Assert.True(createdResult.Success); Assert.True(updatedResult.Success); Assert.True(fetchResult.Success); Assert.Equal(userDto.Email, fetchResult.Data.First().Email); }
public async Task Managing_user_roles_should_work_properly_after_multiple_operations() { var userResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = userResult.Data.First(); await LoadRoles(); var roleRemoveResult = await UserManagementApi.RemoveUserFromRole(userData.Id, Role1.Id); var userRoles = await UserManagementApi.GetUserRoles(userData.Id); Assert.True(userResult.Success); Assert.True(roleRemoveResult.Success); Assert.Empty(userRoles.Data); }
public async Task Adding_user_to_role_multiple_times_shouldnt_do_anything() { var userResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = userResult.Data.First(); await LoadRoles(); var role1AddResult = await UserManagementApi.AddUserToRole(userData.Id, Role1.Id); var role2AddResult = await UserManagementApi.AddUserToRole(userData.Id, Role1.Id); var userRoles = await UserManagementApi.GetUserRoles(userData.Id); Assert.True(userResult.Success); Assert.True(role1AddResult.Success); Assert.True(role2AddResult.Success); Assert.Single(userRoles.Data); }
public async Task Adding_user_to_multiple_roles_should_work() { var userResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = userResult.Data.First(); await LoadRoles(); var roleAddResult1 = await UserManagementApi.AddUserToRole(userData.Id, Role1.Id); var roleAddResult2 = await UserManagementApi.AddUserToRole(userData.Id, Role2.Id); var userRoles = await UserManagementApi.GetUserRoles(userData.Id); Assert.True(userResult.Success); Assert.True(roleAddResult1.Success); Assert.True(roleAddResult2.Success); Assert.Equal(2, userRoles.Data.Count()); }
public async Task Removing_user_from_role_should_work() { var userResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = userResult.Data.First(); await LoadRoles(); var roleAddResult = await UserManagementApi.AddUserToRole(userData.Id, Role1.Id); var roleRemoveResult = await UserManagementApi.RemoveUserFromRole(userData.Id, Role1.Id); var userRoles = await UserManagementApi.GetUserRoles(userData.Id); Assert.True(userResult.Success); Assert.True(roleAddResult.Success); Assert.True(roleRemoveResult.Success); Assert.Empty(userRoles.Data); }
public async Task Removing_user_from_unassigned_role_shouldnt_do_anything() { var userResult = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData = userResult.Data.First(); await LoadRoles(); await UserManagementApi.AddUserToRole(userData.Id, Role1.Id); await UserManagementApi.AddUserToRole(userData.Id, Role2.Id); await UserManagementApi.AddUserToRole(userData.Id, Role2.Id); await UserManagementApi.RemoveUserFromRole(userData.Id, Role1.Id); await UserManagementApi.RemoveUserFromRole(userData.Id, Role2.Id); await UserManagementApi.AddUserToRole(userData.Id, Role2.Id); var userRoles = await UserManagementApi.GetUserRoles(userData.Id); Assert.Single(userRoles.Data); }
public async Task Fetching_users_per_role_should_filter_correctly() { await LoadRoles(); var userCreatedResult1 = await UserManagementApi.CreateUser(GetUniqueTestUser); var userCreatedResult2 = await UserManagementApi.CreateUser(GetUniqueTestUser); var userData1 = userCreatedResult1.Data.First(); var userData2 = userCreatedResult2.Data.First(); await UserManagementApi.AddUserToRole(userData1.Id, Role1.Id); await UserManagementApi.AddUserToRole(userData1.Id, Role2.Id); await UserManagementApi.AddUserToRole(userData2.Id, Role2.Id); var usersInRoleResult1 = await UserManagementApi.Search(new UsersSearch(Role1.Id)); var usersInRoleResult2 = await UserManagementApi.Search(new UsersSearch(Role2.Id)); Assert.Single(usersInRoleResult1.Data); Assert.Equal(2, usersInRoleResult2.Data.Count()); }