public void TestAuthenticateUserLogin()
        {
            ITSLogger log     = new TSLogger();
            UserDTO   userDTO = new UserDTO {
                UserName = "******", password = "******"
            };
            UserLogin userLogin = new UserLogin(new RefreshToken(), configuration, log, new JWTToken(log, new EncryptionService(), configuration), context, new EncryptionService());

            userDTO = userLogin.Login(userDTO);
            Assert.AreEqual(userDTO.HashPassword, "iO27OOseTcQsdEbch+UgOqRWGy80o7aZNit80EwggYgJ4f3vfFkMxmk5DKn6OooyiEEUY+YW5pr/9utIb6OR3Z7cFc40ikafRrhQ3sHE1OCM83C4Wxjcffwf721gKLCfJ/vF9AB4KWp/KasDBztCExyAmarZnoKlehZ60iMAlEK/Kgx3J4VualLR+X1gk1bpdP/jNZ1ZVFgxq6b5RR6zeJ1Lf5E+BV2ntO2yv7/67/FdXnqL1kivcoxGxX05TgPd8pSQnVc/As+8S5bQXWmandFkJatkGWQc70edq1qoF80KbARqMWXWJvd2tt+ZfytPuuFga7XU5suwMhTb3s9MUw==");
        }
Esempio n. 2
0
        public BasePage(IConfiguration configuration)
        {
            this.configuration = configuration;
            EncryptionService  = new EncryptionService();
            refToken           = new RefreshToken();
            itsLogger          = new TSLogger();
            var optionsBuilder = new DbContextOptionsBuilder <OAuthContext>();

            optionsBuilder.UseSqlServer(configuration.GetConnectionString("OAuthDatabase"));
            OAuthDbContext = new OAuthContext(optionsBuilder.Options);
            jwtToken       = new JWTToken(itsLogger, EncryptionService, this.configuration);
        }
        public void TestAuthenticateAccessTokenFromRefreshToken()
        {
            ITSLogger      log       = new TSLogger();
            AccessTokenDTO accessDTO = new AccessTokenDTO();
            AuthorizationGrantRequestDTO authorizationGrantRequestDTO = new AuthorizationGrantRequestDTO
            {
                Client_Id     = Guid.Parse("29bfd4b1-81c0-4db3-a615-4422d08f9792"),
                Code          = null,
                Grant_Type    = AuthorizationGrantType.refresh_token,
                UserName      = null,
                Scope         = null,
                Password      = null,
                Redirect_Uri  = null,
                Refresh_Token = HttpUtility.UrlEncode("pgsoAvSXD3xYPV+/pSAe3khYZWOFidHPxpltwNDP4Xw="),
                State         = null
            };
            IAuthenticationService tm = new AuthenticationService(new RefreshToken(), configuration, log, new JWTToken(log, new EncryptionService(), configuration), context, new EncryptionService());

            accessDTO.Authorization = accessDTO.Authorization = tm.Authenticate(authorizationGrantRequestDTO).access_token;
            TokenValidationService tokenValidationService = new TokenValidationService(new RefreshToken(), configuration, log, new JWTToken(log, new EncryptionService(), configuration), context, new EncryptionService());

            Assert.AreEqual(TokenConstants.ValidToken, tokenValidationService.VerifyToken(accessDTO));
        }