From a9608bcf7c4bc752e62d582eddc994a0cde8c055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20M=C3=A5nsson?= Date: Thu, 4 May 2023 19:38:20 +0200 Subject: [PATCH 1/2] Add CompanyHost role and make it authorize like a Volunteer --- .../Controllers/ContactsControllerTest.cs | 40 ++++++++++++------- Nexpo.Tests/Controllers/TestUtils.cs | 8 +++- .../Controllers/UsersControllerTest.cs | 26 ++++++------ .../Controllers/Session/SessionController.cs | 25 +++++++----- Nexpo/Models/ApplicationDbContext.cs | 24 ++++++----- Nexpo/Models/User.cs | 4 +- 6 files changed, 78 insertions(+), 49 deletions(-) diff --git a/Nexpo.Tests/Controllers/ContactsControllerTest.cs b/Nexpo.Tests/Controllers/ContactsControllerTest.cs index c66a480..0855042 100644 --- a/Nexpo.Tests/Controllers/ContactsControllerTest.cs +++ b/Nexpo.Tests/Controllers/ContactsControllerTest.cs @@ -12,7 +12,7 @@ namespace Nexpo.Tests.Controllers -{ +{ public class ContactControllerTests { [Fact] @@ -20,7 +20,7 @@ public async Task adminCreateAndDeleteContact() { //Setup var client = await TestUtils.Login("admin"); - + //Create contact var DTO = new CreateContactDTO() { @@ -52,7 +52,7 @@ public async Task adminCreateAndDeleteContact() getResponse = await client.GetAsync("/api/contacts/"); contacts = JsonConvert.DeserializeObject>(await getResponse.Content.ReadAsStringAsync()); Assert.True(contacts.Count == numberOfContacts + 1, "Wrong number of contacts. Expected: " + (numberOfContacts + 1) + ". Received: " + contacts.Count); - + //Delete contact var deleteResponse = await client.DeleteAsync("/api/contacts/" + responseContact.Id); Assert.True(deleteResponse.StatusCode.Equals(HttpStatusCode.NoContent), "Wrong Status Code. Expected: NoContent. Received: " + deleteResponse.StatusCode.ToString()); @@ -65,7 +65,7 @@ public async Task adminCreateAndDeleteContact() getResponse = await client.GetAsync("/api/contacts/"); contacts = JsonConvert.DeserializeObject>(await getResponse.Content.ReadAsStringAsync()); Assert.True(contacts.Count == numberOfContacts, "Wrong number of contacts. Expected: " + numberOfContacts + ". Received: " + contacts.Count); - + } [Fact] @@ -92,7 +92,8 @@ public async Task addingDuplicateContact() } [Fact] - public async Task volunteerCreateContact(){ + public async Task volunteerCreateContact() + { //Login var client = await TestUtils.Login("volunteer"); @@ -131,6 +132,19 @@ public async Task volunteerGetContact() Assert.True(responseContact.PhoneNumber == "003-333 33 33", "Wrong phone number. Expected: 003-333 33 33. Received: " + responseContact.PhoneNumber); } + [Fact] + public async Task companyHostGetContact() + { + // Make sure that CompanyHosts can access contacts, even though it's only explicitly authorized for Volunteers + + //Login as companyHost + var client = await TestUtils.Login("companyHost"); + + //Get contact and simply check status code + var response = await client.GetAsync("/api/contacts/-3"); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + [Fact] public async Task nonAuthorizedGetContact() { @@ -153,6 +167,7 @@ public async Task retrieveNonExistingContact() Assert.True(response.StatusCode.Equals(HttpStatusCode.NotFound), "Wrong Status Code. Expected: NotFound. Received: " + response.StatusCode.ToString()); } + [Fact] public async Task getAllContactsAsVolunteerTest() { @@ -213,7 +228,7 @@ public async Task getAllContactsAsStudentTest() { //Login var client = await TestUtils.Login("student1"); - + //Disallow access for student var response = await client.GetAsync("/api/contacts"); Assert.True(response.StatusCode.Equals(HttpStatusCode.Forbidden), "Wrong status code. Expected: Forbidden. Received: " + response.StatusCode.ToString()); @@ -233,8 +248,9 @@ public async Task getAllContactsWhileNotLoggedInTest() } [Fact] - public async Task NonAdminUpdateContactTest(){ - //LOgin + public async Task NonAdminUpdateContactTest() + { + //Login var client = await TestUtils.Login("volunteer"); //Update information @@ -252,6 +268,7 @@ public async Task NonAdminUpdateContactTest(){ Assert.True(response.StatusCode.Equals(HttpStatusCode.Forbidden), "Wrong status code. Expected: Forbidden. Received: " + response.StatusCode.ToString()); } + [Fact] public async Task updateContactAsAdminTest() { @@ -273,7 +290,7 @@ public async Task updateContactAsAdminTest() var payload = new StringContent(json.ToString(), Encoding.UTF8, "application/json"); var response = await client.PutAsync("api/contacts/-2", payload); Assert.True(response.StatusCode.Equals(HttpStatusCode.OK), "Wrong Status Code. Expected: OK. Received: " + response.ToString()); - + //Restore information var json2 = new JsonObject { @@ -308,10 +325,5 @@ public async Task updateContactAsAdminTest() Assert.True(responseObject2.Email == "contact2@example.com", "Wrong email. Expected: contact2@example.com. Received: " + responseObject2.Email); Assert.True(responseObject2.RoleInArkad == "Head of IT", "Wrong role in arkad. Expected: Head of IT. Received: " + responseObject2.RoleInArkad); } - - } - - - } \ No newline at end of file diff --git a/Nexpo.Tests/Controllers/TestUtils.cs b/Nexpo.Tests/Controllers/TestUtils.cs index c9ed21c..a840018 100644 --- a/Nexpo.Tests/Controllers/TestUtils.cs +++ b/Nexpo.Tests/Controllers/TestUtils.cs @@ -38,6 +38,10 @@ public static async Task Login(string user) json.Add("email", "volunteer@example.com"); json.Add("password", "password"); break; + case "companyHost": + json.Add("email", "companyHost@example.com"); + json.Add("password", "password"); + break; case "student1": json.Add("email", "student1@example.com"); json.Add("password", "password"); @@ -71,7 +75,7 @@ public static async Task Login(string user) json.Add("password", "password"); break; default: - return null; + return null; } var payload = new StringContent(json.ToString(), Encoding.UTF8, "application/json"); @@ -81,6 +85,6 @@ public static async Task Login(string user) token = "Bearer " + parser.Value("token"); client.DefaultRequestHeaders.Add("Authorization", token); return client; - } + } } } diff --git a/Nexpo.Tests/Controllers/UsersControllerTest.cs b/Nexpo.Tests/Controllers/UsersControllerTest.cs index c002dbd..5fd7a23 100644 --- a/Nexpo.Tests/Controllers/UsersControllerTest.cs +++ b/Nexpo.Tests/Controllers/UsersControllerTest.cs @@ -53,10 +53,10 @@ public async Task GetAllAsAdmin() //Extract the content of the response and deserialize it to a User object var serializedUser = await response.Content.ReadAsStringAsync(); var user = JsonConvert.DeserializeObject(serializedUser); - + //Check that the role of the user is now Volunteer Assert.True( - user.Role.Equals(Role.Volunteer), + user.Role.Equals(Role.Volunteer), "Wrong role. Expected: CompanyRepresentative. Received: " + user.Role.ToString() ); @@ -74,20 +74,21 @@ public async Task GetAllAsAdmin() var response2 = await client.PutAsync("api/users/-5", payload2); Assert.True( - response2.StatusCode.Equals(HttpStatusCode.OK), + response2.StatusCode.Equals(HttpStatusCode.OK), "Wrong status code. Expected: OK. Received: " + response2.StatusCode.ToString() ); var user2 = JsonConvert.DeserializeObject(await response2.Content.ReadAsStringAsync()); Assert.True( - user2.Role.Equals(Role.CompanyRepresentative), + user2.Role.Equals(Role.CompanyRepresentative), "Wrong role. Expected: CompanyRepresentative. Received: " + user2.Role.ToString() ); } [Fact] - public async Task AdminChangeNonExistingUserRole(){ + public async Task AdminChangeNonExistingUserRole() + { var client = await TestUtils.Login("admin"); var updateRoleDto = new UpdateUserDTO { @@ -106,7 +107,8 @@ public async Task AdminChangeNonExistingUserRole(){ } [Fact] - public async Task NonAdminChangeRole(){ + public async Task NonAdminChangeRole() + { var client = await TestUtils.Login("student1"); var updateRoleDto = new UpdateUserDTO { @@ -123,7 +125,7 @@ public async Task NonAdminChangeRole(){ "Wrong status code. Expected: Forbidden. Received: " + response.StatusCode.ToString() ); } - + [Fact] public async Task AdminGetAllUsers() { @@ -136,8 +138,8 @@ public async Task AdminGetAllUsers() var userAdmin = responseList.Find(user => user.Id == -1); var userStudent = responseList.Find(user => user.Id == -2); var userRep = responseList.Find(user => user.Id == -5); - - Assert.True(responseList.Count == 10, "Wrong number of users. Expected: 10. Received: " + responseList.Count.ToString()); + + Assert.True(responseList.Count == 11, "Wrong number of users. Expected: 11. Received: " + responseList.Count.ToString()); Assert.True(userAdmin.Role.Equals(Role.Administrator), "Wrong user role. Expected: admin. Received: " + userAdmin.Role.ToString()); Assert.True(userStudent.FirstName.Equals("Alpha"), "Wrong user first name. Expected: Alpha. Received: " + userStudent.FirstName); Assert.True(userRep.CompanyId == -1, "Wrong company id. Expected: -1. Received: " + userRep.CompanyId.ToString()); @@ -215,7 +217,7 @@ public async Task GetAsStudent() public async Task UpdateAsAdmin() { var application = new WebApplicationFactory(); - var client = await TestUtils.Login("admin"); + var client = await TestUtils.Login("admin"); var json = new JsonObject { @@ -457,7 +459,7 @@ public async Task updateMe() { "email", "rep1@company4.example.com" }, { "password", "password" } }; - + var testPayload = new StringContent(testJson.ToString(), Encoding.UTF8, "application/json"); var testResponse = await testClient.PostAsync("/api/session/signin", testPayload); @@ -545,7 +547,7 @@ public async Task UpdateMeUnautherized() { { "password", "newSuperSecretPassword" } }; - + var payload = new StringContent(json.ToString(), Encoding.UTF8, "application/json"); var response = await client.PutAsync("api/users/me", payload); diff --git a/Nexpo/Controllers/Session/SessionController.cs b/Nexpo/Controllers/Session/SessionController.cs index 9975b47..b99db4d 100644 --- a/Nexpo/Controllers/Session/SessionController.cs +++ b/Nexpo/Controllers/Session/SessionController.cs @@ -23,19 +23,19 @@ public class SessionController : ControllerBase private readonly IEmailService _emailService; public SessionController( - IUserRepository iUserRepo, - IStudentRepository iStudentRepo, - ICompanyRepository iCompanyRepo, + IUserRepository iUserRepo, + IStudentRepository iStudentRepo, + ICompanyRepository iCompanyRepo, PasswordService passwordService, TokenService tokenService, IEmailService iEmailService) { - _userRepo = iUserRepo; - _studentRepo = iStudentRepo; - _companyRepo = iCompanyRepo; + _userRepo = iUserRepo; + _studentRepo = iStudentRepo; + _companyRepo = iCompanyRepo; _passwordService = passwordService; - _tokenService = tokenService; - _emailService = iEmailService; + _tokenService = tokenService; + _emailService = iEmailService; } /// @@ -86,6 +86,13 @@ public async Task PostSignIn(SignInRequestDTO credentials) claims.Add(new Claim(UserClaims.VolunteerId, volunteer.Id.ToString())); } + if (user.Role == Role.CompanyHost) + { + // A CompanyHost is also a Volunteer + // TL;DR: This claim makes a CompanyHost authorized whenever [Authorize(Roles = nameof(Role.Volunteer))] is used + claims.Add(new Claim(UserClaims.Role, nameof(Role.Volunteer))); + } + var jwt = _tokenService.GenerateJWT(claims); return Ok(new SignInResponseDTO { Token = jwt }); @@ -139,7 +146,7 @@ public async Task PostResetPassword(ResetPasswordDTO DTO) public static class UserClaims { public static readonly string Id = nameof(Id); - public static readonly string Role = ClaimTypes.Role; + public static readonly string Role = ClaimTypes.Role; public static readonly string CompanyId = nameof(CompanyId); public static readonly string StudentId = nameof(StudentId); public static readonly string VolunteerId = nameof(VolunteerId); diff --git a/Nexpo/Models/ApplicationDbContext.cs b/Nexpo/Models/ApplicationDbContext.cs index 0f2ea54..c265591 100644 --- a/Nexpo/Models/ApplicationDbContext.cs +++ b/Nexpo/Models/ApplicationDbContext.cs @@ -52,10 +52,10 @@ public void Seed() } // Companies - var company1 = new Company { Id = -1, Name = "Apple", Description = "A fruit company" , DidYouKnow = "Apples", DesiredDegrees = new List(){(int) Degree.Bachelor,(int) Degree.Master}, DesiredProgramme = new List(){(int) Programme.Datateknik,(int) Programme.Elektroteknik}, Industries = new List(){(int)Industry.DataIT,(int) Industry.ElectricityEnergyPower}, Positions = new List(){(int)Position.ForeignOppurtunity, (int)Position.Internship}, StudentSessionMotivation = "We are the greatest company in the world according to us!"}; - var company2 = new Company { Id = -2, Name = "Google", Description = "You can find more about us by searching the web" , DidYouKnow = "we are big", DesiredDegrees = new List(){(int) Degree.Bachelor,(int) Degree.Master}, DesiredProgramme = new List(){(int) Programme.Arkitekt,(int) Programme.Väg_och_vatttenbyggnad}, Industries = new List(){(int)Industry.Industry,(int) Industry.DataIT}, Positions = new List(){(int)Position.PartTime, (int)Position.Internship}}; - var company3 = new Company { Id = -3, Name = "Spotify", Description = "We like music" , DidYouKnow = "we love music", DesiredDegrees = new List(){(int) Degree.Bachelor,(int) Degree.Master}, DesiredProgramme = new List(){(int) Programme.Kemiteknik,(int) Programme.Industriell_ekonomi}, Industries = new List(){(int)Industry.Coaching,(int) Industry.BankingFinance}, Positions = new List(){(int)Position.ForeignOppurtunity, (int)Position.SummerJob}}; - var company4 = new Company { Id = -4, Name = "Facebook", Description = "We have friends in common" , DidYouKnow = "Mark zuckerburg is an Alien", DesiredDegrees = new List(){(int) Degree.PhD,(int) Degree.Master}, DesiredProgramme = new List(){(int) Programme.Byggteknik_med_Järnvägsteknik,(int) Programme.Teknisk_Fysik}, Industries = new List(){(int)Industry.Environment,(int) Industry.ElectricityEnergyPower}, Positions = new List(){(int)Position.Thesis, (int)Position.TraineeEmployment}, StudentSessionMotivation = "We are better than Apple!"}; + var company1 = new Company { Id = -1, Name = "Apple", Description = "A fruit company", DidYouKnow = "Apples", DesiredDegrees = new List() { (int)Degree.Bachelor, (int)Degree.Master }, DesiredProgramme = new List() { (int)Programme.Datateknik, (int)Programme.Elektroteknik }, Industries = new List() { (int)Industry.DataIT, (int)Industry.ElectricityEnergyPower }, Positions = new List() { (int)Position.ForeignOppurtunity, (int)Position.Internship }, StudentSessionMotivation = "We are the greatest company in the world according to us!" }; + var company2 = new Company { Id = -2, Name = "Google", Description = "You can find more about us by searching the web", DidYouKnow = "we are big", DesiredDegrees = new List() { (int)Degree.Bachelor, (int)Degree.Master }, DesiredProgramme = new List() { (int)Programme.Arkitekt, (int)Programme.Väg_och_vatttenbyggnad }, Industries = new List() { (int)Industry.Industry, (int)Industry.DataIT }, Positions = new List() { (int)Position.PartTime, (int)Position.Internship } }; + var company3 = new Company { Id = -3, Name = "Spotify", Description = "We like music", DidYouKnow = "we love music", DesiredDegrees = new List() { (int)Degree.Bachelor, (int)Degree.Master }, DesiredProgramme = new List() { (int)Programme.Kemiteknik, (int)Programme.Industriell_ekonomi }, Industries = new List() { (int)Industry.Coaching, (int)Industry.BankingFinance }, Positions = new List() { (int)Position.ForeignOppurtunity, (int)Position.SummerJob } }; + var company4 = new Company { Id = -4, Name = "Facebook", Description = "We have friends in common", DidYouKnow = "Mark zuckerburg is an Alien", DesiredDegrees = new List() { (int)Degree.PhD, (int)Degree.Master }, DesiredProgramme = new List() { (int)Programme.Byggteknik_med_Järnvägsteknik, (int)Programme.Teknisk_Fysik }, Industries = new List() { (int)Industry.Environment, (int)Industry.ElectricityEnergyPower }, Positions = new List() { (int)Position.Thesis, (int)Position.TraineeEmployment }, StudentSessionMotivation = "We are better than Apple!" }; Companies.AddRange(company1, company2, company3, company4); SaveChanges(); @@ -71,9 +71,13 @@ public void Seed() var user7 = new User { Id = -7, Email = "rep1@company2.example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.CompanyRepresentative, FirstName = "Gamma", LastName = "Rep", CompanyId = company2.Id.Value }; var user8 = new User { Id = -8, Email = "rep1@company3.example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.CompanyRepresentative, FirstName = "Delta", LastName = "Rep", CompanyId = company3.Id.Value }; var user9 = new User { Id = -9, Email = "rep1@company4.example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.CompanyRepresentative, FirstName = "Epsilon", LastName = "Rep", CompanyId = company4.Id.Value }; - + var user10 = new User { Id = -10, Email = "volunteer@example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.Volunteer, FirstName = "Alpha", LastName = "Volunteer" }; - Users.AddRange(user1, user2, user3, user4, user5, user6, user7, user8, user9, user10); + + var user11 = new User { Id = -11, Email = "companyHost@example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.CompanyHost, FirstName = "Alpha", LastName = "CompanyHost" }; + + + Users.AddRange(user1, user2, user3, user4, user5, user6, user7, user8, user9, user10, user11); SaveChanges(); // Students @@ -88,12 +92,12 @@ public void Seed() var event2 = new Event { Id = -2, Name = "Bounce with Uber", Description = "Day event at Bounce with Uber", Date = DateTime.Now.AddDays(11).Date.ToString(), Start = "09:00", End = "16:00", Host = "Uber", Location = "Bounce Malmö", Language = "English", Capacity = 20 }; var event3 = new Event { Id = -3, Name = "CV Workshop with Randstad", Description = "Make your CV look professional with the help of Randstad", Date = DateTime.Now.AddDays(12).Date.ToString(), Start = "13:30", End = "15:00", Host = "Randstad", Location = "E:A", Language = "Swedish", Capacity = 3 }; var event4 = new Event { Id = -4, Name = "Inspirational lunch lecture", Description = "Get inspired and expand your horizons", Date = DateTime.Now.AddDays(14).Date.ToString(), Start = "12:15", End = "13:00", Host = "SYV", Location = "MA:3", Language = "Swedish", Capacity = 2 }; - var event5 = new Event { Id = -5, Name = "Pick apples with Apple", Description = "An apple a day keeps the doctor away", Date = DateTime.Now.AddDays(1).Date.ToString(), Start = "12:15", End = "13:00", Host = "Apple", Location = "M:B", Language = "English", Capacity = 200}; + var event5 = new Event { Id = -5, Name = "Pick apples with Apple", Description = "An apple a day keeps the doctor away", Date = DateTime.Now.AddDays(1).Date.ToString(), Start = "12:15", End = "13:00", Host = "Apple", Location = "M:B", Language = "English", Capacity = 200 }; Events.AddRange(event1, event2, event3, event4, event5); SaveChanges(); // Tickets - var ticket1 = new Ticket { Id = -1, Code = Guid.NewGuid(), PhotoOk = true, EventId = event1.Id.Value, UserId = user2.Id.Value , isConsumed = true}; + var ticket1 = new Ticket { Id = -1, Code = Guid.NewGuid(), PhotoOk = true, EventId = event1.Id.Value, UserId = user2.Id.Value, isConsumed = true }; var ticket2 = new Ticket { Id = -2, Code = Guid.NewGuid(), PhotoOk = false, EventId = event1.Id.Value, UserId = user3.Id.Value }; var ticket3 = new Ticket { Id = -3, Code = Guid.NewGuid(), PhotoOk = true, EventId = event1.Id.Value, UserId = user4.Id.Value }; @@ -122,7 +126,7 @@ public void Seed() SaveChanges(); // StudentSessionApplications - var application1 = new StudentSessionApplication { Id = -1, Motivation = "Hej, jag är jättebra och tror att ni vill träffa mig!", StudentId = student1.Id.Value, CompanyId = company1.Id.Value}; + var application1 = new StudentSessionApplication { Id = -1, Motivation = "Hej, jag är jättebra och tror att ni vill träffa mig!", StudentId = student1.Id.Value, CompanyId = company1.Id.Value }; var application2 = new StudentSessionApplication { Id = -2, Motivation = "I love my MacBook", StudentId = student2.Id.Value, CompanyId = company1.Id.Value }; var application3 = new StudentSessionApplication { Id = -3, Motivation = "User experience is very important for me", StudentId = student3.Id.Value, CompanyId = company1.Id.Value }; @@ -141,7 +145,7 @@ public void Seed() var contact4 = new Contact { Id = -4, FirstName = "Back", LastName = "End", RoleInArkad = "Backend Manager", Email = "contact4@example.com", PhoneNumber = "004-444 44 44" }; Contacts.AddRange(contact1, contact2, contact3, contact4); SaveChanges(); - + } } } \ No newline at end of file diff --git a/Nexpo/Models/User.cs b/Nexpo/Models/User.cs index e140f2d..22dc676 100644 --- a/Nexpo/Models/User.cs +++ b/Nexpo/Models/User.cs @@ -42,7 +42,7 @@ public enum Role Administrator, Student, CompanyRepresentative, - Volunteer + Volunteer, + CompanyHost, } } - From 025856b2b5e7939f76673f569921da032bcd2e1a Mon Sep 17 00:00:00 2001 From: Alexander Hansson Date: Thu, 11 May 2023 02:28:47 +0200 Subject: [PATCH 2/2] Added a test and fixed small test bug --- .../Controllers/ContactsControllerTest.cs | 28 ++++++++++++++++++- Nexpo.Tests/Controllers/TestUtils.cs | 4 +-- Nexpo/Models/ApplicationDbContext.cs | 4 +-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Nexpo.Tests/Controllers/ContactsControllerTest.cs b/Nexpo.Tests/Controllers/ContactsControllerTest.cs index 0855042..7cc5bfb 100644 --- a/Nexpo.Tests/Controllers/ContactsControllerTest.cs +++ b/Nexpo.Tests/Controllers/ContactsControllerTest.cs @@ -138,13 +138,39 @@ public async Task companyHostGetContact() // Make sure that CompanyHosts can access contacts, even though it's only explicitly authorized for Volunteers //Login as companyHost - var client = await TestUtils.Login("companyHost"); + var client = await TestUtils.Login("companyhost"); //Get contact and simply check status code var response = await client.GetAsync("/api/contacts/-3"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } + [Fact] + public async Task companyHostPutContact() + { + //Login as companyHost + var client = await TestUtils.Login("companyhost"); + + var DTO = new CreateContactDTO() + { + FirstName = "Test", + LastName = "Testsson", + PhoneNumber = "123-456 78 90", + Email = "test.testsson@example.com", + RoleInArkad = "Tester" + }; + + //serialize json + var payload = new StringContent(DTO.ToString(), Encoding.UTF8, "application/json"); + + //Get contact and check status code + var response = await client.PutAsync("/api/contacts/add", payload); + + Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); + + } + + [Fact] public async Task nonAuthorizedGetContact() { diff --git a/Nexpo.Tests/Controllers/TestUtils.cs b/Nexpo.Tests/Controllers/TestUtils.cs index a840018..f68e486 100644 --- a/Nexpo.Tests/Controllers/TestUtils.cs +++ b/Nexpo.Tests/Controllers/TestUtils.cs @@ -38,8 +38,8 @@ public static async Task Login(string user) json.Add("email", "volunteer@example.com"); json.Add("password", "password"); break; - case "companyHost": - json.Add("email", "companyHost@example.com"); + case "companyhost": + json.Add("email", "companyhost@example.com"); json.Add("password", "password"); break; case "student1": diff --git a/Nexpo/Models/ApplicationDbContext.cs b/Nexpo/Models/ApplicationDbContext.cs index c265591..27ce037 100644 --- a/Nexpo/Models/ApplicationDbContext.cs +++ b/Nexpo/Models/ApplicationDbContext.cs @@ -74,9 +74,7 @@ public void Seed() var user10 = new User { Id = -10, Email = "volunteer@example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.Volunteer, FirstName = "Alpha", LastName = "Volunteer" }; - var user11 = new User { Id = -11, Email = "companyHost@example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.CompanyHost, FirstName = "Alpha", LastName = "CompanyHost" }; - - + var user11 = new User { Id = -11, Email = "companyhost@example.com", PasswordHash = _passwordService.HashPassword("password"), Role = Role.CompanyHost, FirstName = "Alpha", LastName = "CompanyHost" }; Users.AddRange(user1, user2, user3, user4, user5, user6, user7, user8, user9, user10, user11); SaveChanges();