Exemple #1
0
        public async Task Adicionar_DeveRetornarErroQuandoUsuarioForInvalido()
        {
            var cadastrarUsuarioPayload = new CadastrarUsuarioPayload();

            var response = await _polarisLogFixture.Client.PostAsJsonAsync("Usuarios", cadastrarUsuarioPayload);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
        public async Task <IActionResult> Adicionar(CadastrarUsuarioPayload cadastrarUsuarioPayload)
        {
            var applicationUser = _mapper.Map <ApplicationUser>(cadastrarUsuarioPayload);

            var result = await _userManager.CreateAsync(applicationUser, cadastrarUsuarioPayload.Senha);

            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors.Select(error => error.Description)));
            }

            return(Ok(new[] { "Usuário cadastrado com sucesso" }));
        }
Exemple #3
0
        public async Task Adicionar_DeveAdicionarUsuarioComNomeEmailESenha()
        {
            var cadastrarUsuarioPayload = new CadastrarUsuarioPayload
            {
                Nome             = "Carlos Eduardo",
                Email            = "*****@*****.**",
                Senha            = "123456",
                SenhaConfirmacao = "123456"
            };

            var response = await _polarisLogFixture.Client.PostAsJsonAsync("Usuarios", cadastrarUsuarioPayload);

            response.EnsureSuccessStatusCode();
        }
        private async Task CadastrarUsuario()
        {
            var cadastrarUsuarioPayload = new CadastrarUsuarioPayload
            {
                Nome             = "Eduardo Azevedo",
                Email            = "*****@*****.**",
                Senha            = "123456",
                SenhaConfirmacao = "123456"
            };

            var response = await Client.PostAsJsonAsync("Usuarios", cadastrarUsuarioPayload);

            response.EnsureSuccessStatusCode();
        }
Exemple #5
0
        public async Task RecuperarSenha_DeveRetornarSucesso()
        {
            var cadastrarUsuarioPayload = new CadastrarUsuarioPayload
            {
                Nome             = "Carlos Eduardo",
                Email            = "*****@*****.**",
                Senha            = "123456",
                SenhaConfirmacao = "123456"
            };
            await _polarisLogFixture.Client.PostAsJsonAsync("Usuarios", cadastrarUsuarioPayload);

            var recuperarSenhaPayload = new RecuperarSenhaPayload
            {
                Email = "*****@*****.**"
            };

            var response =
                await _polarisLogFixture.Client.PostAsJsonAsync("Usuarios/RecuperarSenha", recuperarSenhaPayload);

            response.EnsureSuccessStatusCode();
        }
Exemple #6
0
        public async Task ResetarSenha_DeveRetornarErroQuandoTokenForInvalido()
        {
            var cadastrarUsuarioPayload = new CadastrarUsuarioPayload
            {
                Nome             = "Carlos Eduardo",
                Email            = "*****@*****.**",
                Senha            = "123456",
                SenhaConfirmacao = "123456"
            };
            await _polarisLogFixture.Client.PostAsJsonAsync("Usuarios", cadastrarUsuarioPayload);

            var resetarSenhaPayload = new ResetarSenhaPayload
            {
                Email = cadastrarUsuarioPayload.Email,
                Senha = "123456",
                Token = Guid.NewGuid().ToString()
            };

            var response = await _polarisLogFixture.Client.PostAsJsonAsync("Usuarios/ResetarSenha", resetarSenhaPayload);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }