public async Task AddUser_To_Organization_Should_Add() { var client = new HttpClientWithUser(_client); await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var userEmail = "*****@*****.**"; var newUserId = await RegisterUser(userEmail); var organizationId = await CreateOrganization(client.Client, "janusz"); await client.RefreshToken(); var body = CreateContent(new { email = userEmail }); var response = await client.Client.PostAsync(Organization.Post.AddUserToOrganization(organizationId), body); response.EnsureSuccessStatusCode(); var organizationResponse = await client.Client.GetAsync(Organization.Get.GetOrganizationbyId(organizationId)); organizationResponse.EnsureSuccessStatusCode(); var organizationInfo = await organizationResponse.CastTo <OrganizationView>(); var user = organizationInfo.Users.FirstOrDefault(p => p.Id == newUserId); Assert.Equal(newUserId, user.Id); Assert.Equal(Role.User.Name, user.Role); }
public async Task Delete_UserFromOrganization_Should_Delete() { var client = new HttpClientWithUser(_client); await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var organizationId = await CreateOrganization(client.Client, "coommspany 19"); await client.RefreshToken(); var userEmail = "*****@*****.**"; await RegisterUser(userEmail); var body = CreateContent(new { email = userEmail }); var response = await client.Client.PostAsync(Organization.Post.AddUserToOrganization(organizationId), body); response.EnsureSuccessStatusCode(); var responseWithId = await response.CastTo <ResponseWithId>(); var responseDelete = await client.Client.DeleteAsync(Organization.Delete.DeleteUserFromOrganization(organizationId, responseWithId.Id)); Assert.False(responseDelete.IsSuccessStatusCode); }
public async Task Change_UserRole_Shoud_BadRequest() { var client = new HttpClientWithUser(_client); await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var organizationId = await CreateOrganization(client.Client, "coommspany"); var userEmail = "*****@*****.**"; var newUserId = await RegisterUser(userEmail); await client.RefreshToken(); var body = CreateContent(new { email = userEmail }); var response = await client.Client.PostAsync(Organization.Post.AddUserToOrganization(organizationId), body); response.EnsureSuccessStatusCode(); var roleBody = CreateContent(new { roleId = 4 }); var roleChangeResposne = await client.Client.PutAsync(Organization.Put.ChangeRole(organizationId, newUserId), roleBody); Assert.False(roleChangeResposne.IsSuccessStatusCode); }
public async Task Delete_Organization_Should_Delete() { var client = new HttpClientWithUser(_client); await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var organizationId = await CreateOrganization(client.Client, "coommspany 20"); await client.RefreshToken(); var response = await client.Client.DeleteAsync(Organization.Delete.DeleteOrganization(organizationId)); Assert.True(response.IsSuccessStatusCode); }
public async Task Delete_UserFromOrganization_BadRequest() { var client = new HttpClientWithUser(_client); var userId = await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var organizationId = await CreateOrganization(client.Client, "coommspany 18"); await client.RefreshToken(); var response = await client.Client.DeleteAsync(Organization.Delete.DeleteUserFromOrganization(organizationId, userId)); Assert.False(response.IsSuccessStatusCode); }
public async Task Add_Organization_Should_Create() { var client = new HttpClientWithUser(_client); await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var name = "test12333"; var organizationId = await CreateOrganization(client.Client, name); var organizationResponse = await _client.GetAsync(Organization.Get.GetOrganizationbyId(organizationId)); organizationResponse.EnsureSuccessStatusCode(); var organizationInfo = await organizationResponse.CastTo <OrganizationView>(); Assert.Equal(organizationId, organizationInfo.Id); Assert.Equal(name, organizationInfo.Name); }
public async Task AddUser_To_Organization_BadRequest() { var userEmail = "hjdhasdhsa"; var client = new HttpClientWithUser(_client); await client.Register("*****@*****.**", "Test1234."); await client.AddTokenHeader(); var organizationId = await CreateOrganization(client.Client, "przemek"); var body = CreateContent(new { email = userEmail }); var response = await _client.PostAsync(Organization.Post.AddUserToOrganization(organizationId), body); Assert.False(response.IsSuccessStatusCode); }
public async Task ChangeUser_Role_ShouldChange(int roleId, string email, string newEmail, string company) { var client = new HttpClientWithUser(_client); await client.Register(email, "Test1234."); await client.AddTokenHeader(); var organizationId = await CreateOrganization(client.Client, company); var userEmail = newEmail; var newUserId = await RegisterUser(userEmail); await client.RefreshToken(); var body = CreateContent(new { email = userEmail }); var response = await client.Client.PostAsync(Organization.Post.AddUserToOrganization(organizationId), body); response.EnsureSuccessStatusCode(); var role = Role.From(roleId); var roleBody = CreateContent(new { roleId = role.Id }); var roleChangeResposne = await client.Client.PutAsync(Organization.Put.ChangeRole(organizationId, newUserId), roleBody); roleChangeResposne.EnsureSuccessStatusCode(); var organizationResponse = await client.Client.GetAsync(Organization.Get.GetOrganizationbyId(organizationId)); organizationResponse.EnsureSuccessStatusCode(); var organizationInfo = await organizationResponse.CastTo <OrganizationView>(); var user = organizationInfo.Users.FirstOrDefault(p => p.Id == newUserId); Assert.Equal(role.Name, user.Role); }