Beispiel #1
0
        public async Task Deve_Verificar_Metodo_E_Retornar_UsuarioAutenticado()
        {
            // Arrange
            var command = new TenantAuthenticateCommand
            {
                Logon    = "mock-username",
                Password = "******"
            };

            var expectedResult = new AuthenticatedTenantModel()
            {
                ID    = Guid.NewGuid().ToString(),
                Role  = Role.Manager.ToString(),
                Token = string.Empty,
                Logon = "mock-username"
            };

            _moqMediator
            .Setup(p => p.Send(command, default))
            .ReturnsAsync(Result.Success(expectedResult));

            // Act
            var result = await GetController().AuthenticateAsync(command);

            // Assert
            var okResult = result as OkObjectResult;

            okResult.StatusCode.Should().Be(200);
            okResult.Value.Should().Be(expectedResult);
        }
Beispiel #2
0
        public async Task Deve_Verificar_Metodo_E_Retornar_Usuario_Autenticado()
        {
            // Arrange
            var secret          = "super secret key";
            var tokenExpiration = 10;

            BuildConfiguration(secret, tokenExpiration.ToString());

            var command = new TenantAuthenticateCommand()
            {
                Logon    = "username",
                Password = "******"
            };

            var tenant = new Tenant()
            {
                ID         = Guid.NewGuid(),
                Salt       = "123456789",
                Logon      = command.Logon,
                Password   = command.Password,
                Role       = Role.Client,
                Enterprise = new Enterprise()
                {
                    ConnectionString = "mock-schema"
                }
            };

            var expectedResult = new AuthenticatedTenantModel()
            {
                ID    = tenant.ID.ToString(),
                Logon = tenant.Logon,
                Role  = tenant.Role.ToString()
            };

            _moqTenantRepository
            .Setup(p => p.SingleOrDefaultAsync(x => x.Logon.Equals(command.Logon), true, default, x => x.Enterprise))