Exemplo n.º 1
0
        public async Task PostFailedTest()
        {
            _loginValidator.CheckPasswordUserAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()).Returns(false);
            _loginValidator.GetUserById(Arg.Any <string>()).Returns(new ApplicationUser());
            _loginValidator.ValidateRoleAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()).Returns(false);
            var loginController = new LoginController(_accessManager);
            var token           = await loginController.Post(SetupTests.GetLogin()) as Token;

            Assert.True(token == null);
        }
Exemplo n.º 2
0
        public async Task TestAccessManagerLoginSuccess()
        {
            var accessManager = new AccessManager(_signingConfigurations, _tokenConfigurations, _loginValidator);

            _loginValidator.GetUserById(Arg.Any <string>()).Returns(new ApplicationUser());
            _loginValidator.CheckPasswordUserAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()).Returns(true);
            _loginValidator.ValidateRoleAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()).Returns(true);
            var valid = await accessManager.ValidateCredentials(SetupTests.GetLogin());

            Assert.True(valid);
        }
Exemplo n.º 3
0
        public void GenerateToken()
        {
            _tokenConfigurations.Audience = "ExemploAudience";
            _tokenConfigurations.Issuer   = "ExemploIssuer";
            _tokenConfigurations.Seconds  = 90;

            var accessManager = new AccessManager(_signingConfigurations, _tokenConfigurations, _loginValidator);
            var token         = accessManager.GenerateToken(SetupTests.GetLogin());

            Assert.True(token.Authenticated);
            Assert.IsType <string>(token.AccessToken);
            Assert.IsType <Token>(token);
        }
Exemplo n.º 4
0
        public async Task PostTest()
        {
            _loginValidator.CheckPasswordUserAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()).Returns(true);
            _loginValidator.GetUserById(Arg.Any <string>()).Returns(new ApplicationUser());
            _loginValidator.ValidateRoleAsync(Arg.Any <ApplicationUser>(), Arg.Any <string>()).Returns(true);
            var loginController = new LoginController(_accessManager);
            var token           = await loginController.Post(SetupTests.GetLogin()) as Token;

            Assert.True(!string.IsNullOrEmpty(token.AccessToken));
            Assert.True(!string.IsNullOrEmpty(token.Message));
            Assert.True(token.Authenticated);
            Assert.True(!string.IsNullOrEmpty(token.Created));
            Assert.True(!string.IsNullOrEmpty(token.Expiration));
        }
        public void ClienteHasUserTest()
        {
            var cliente = SetupTests.GetLogin();

            Assert.True(cliente.HasClient());
        }