-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: verificar email de administrador e funcionário quando atuali…
…za-lo
- Loading branch information
1 parent
4e72a3c
commit 58b37a7
Showing
8 changed files
with
30 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using Hotel.Domain.DTOs.Base.User; | ||
using Hotel.Domain.Entities.AdminEntity; | ||
using Hotel.Domain.Entities.PermissionEntity; | ||
using Hotel.Domain.Entities.VerificationCodeEntity; | ||
using Hotel.Domain.Enums; | ||
using Hotel.Domain.Services.Permissions; | ||
using Hotel.Domain.Services.TokenServices; | ||
|
@@ -240,35 +241,6 @@ public async Task RemoveAdminPermission_ShouldReturn_OK() | |
Assert.AreEqual(adminWithPermissions.Permissions.Count, 0); | ||
} | ||
|
||
//[TestMethod] | ||
//public async Task UpdateToRootAdmin_ShouldReturn_OK() | ||
//{ | ||
// //Arrange | ||
// var admin = new Admin | ||
// ( | ||
// new Name("Beatriz", "Santos"), | ||
// new Email("[email protected]"), | ||
// new Phone("+55 (31) 99876-5432"), | ||
// "password3", | ||
// EGender.Feminine, | ||
// DateTime.Now.AddYears(-27), | ||
// new Address("Brazil", "Belo Horizonte", "MG-303", 303) | ||
// ); | ||
|
||
// await _dbContext.Admins.AddAsync(admin); | ||
// await _dbContext.SaveChangesAsync(); | ||
|
||
// //Act | ||
// var response = await _client.PostAsync($"{_baseUrl}/to-root-admin/{admin.Id}", null); | ||
|
||
// //Assert | ||
// var updatedAdmin = await _dbContext.Admins.FirstOrDefaultAsync(x => x.Id == admin.Id); | ||
|
||
// Assert.IsNotNull(response); | ||
// response.EnsureSuccessStatusCode(); | ||
// Assert.IsTrue(updatedAdmin!.IsRootAdmin); | ||
//} | ||
|
||
[TestMethod] | ||
public async Task UpdateAdmin_ShouldReturn_OK() | ||
{ | ||
|
@@ -408,8 +380,12 @@ public async Task UpdateEmailAdmin_ShouldReturn_OK() | |
|
||
var body = new Email("[email protected]"); | ||
|
||
var verificationNewEmailCode = new VerificationCode(body); | ||
await _dbContext.VerificationCodes.AddAsync(verificationNewEmailCode); | ||
await _dbContext.SaveChangesAsync(); | ||
|
||
//Act | ||
var response = await _client.PatchAsJsonAsync($"{_baseUrl}/email", body); | ||
var response = await _client.PatchAsJsonAsync($"{_baseUrl}/email?code={verificationNewEmailCode.Code}", body); | ||
|
||
//Assert | ||
var updatedAdmin = await _dbContext.Admins.FirstOrDefaultAsync(x => x.Id == admin.Id); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
using System.Net.Http.Headers; | ||
using System.Net.Http.Json; | ||
using Hotel.Domain.DTOs.EmployeeDTOs; | ||
using Hotel.Domain.Entities.VerificationCodeEntity; | ||
|
||
namespace Hotel.Tests.IntegrationTests.Controllers; | ||
|
||
|
@@ -386,8 +387,12 @@ public async Task UpdateEmployeeEmail_ShouldReturn_OK() | |
|
||
var body = new Email("[email protected]"); | ||
|
||
var verificationNewEmailCode = new VerificationCode(body); | ||
await _dbContext.VerificationCodes.AddAsync(verificationNewEmailCode); | ||
await _dbContext.SaveChangesAsync(); | ||
|
||
//Act | ||
var response = await _client.PatchAsJsonAsync($"{_baseUrl}/email", body); | ||
var response = await _client.PatchAsJsonAsync($"{_baseUrl}/email?code={verificationNewEmailCode.Code}", body); | ||
|
||
//Assert | ||
var updatedEmployee = await _dbContext.Employees.FirstOrDefaultAsync(x => x.Id == employee.Id); | ||
|