Exemplo n.º 1
0
        public void CreateJsonWebToken_TokenAudienceShouldMatchExpectedString()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            Assert.Equal("ThoseWhoRock", result.Audiences.FirstOrDefault());
        }
Exemplo n.º 2
0
        public void CreateJsonWebToken_ValidFromSultMatchTestDateTime()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            Assert.Equal(TestDateTime(), result.ValidFrom);
        }
Exemplo n.º 3
0
        public void CreateJsonWebToken_TokenIssuerShouldMatchExpectedString()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            Assert.Equal("FusionAlliance", result.Issuer);
        }
Exemplo n.º 4
0
        public void CreateJsonWebToken_ShoulReturnJwtSecurityToken()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            Assert.IsType(typeof(JwtSecurityToken), result);
        }
Exemplo n.º 5
0
        public void CreateJsonWebToken_TokenExperationMinutesShouldBeAccessedOnce()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            appSettings.VerifyGet(i => i.TokenSettings.ExpirationMinutes, Times.Once);
        }
Exemplo n.º 6
0
        public void CreateJsonWebToken_ValidToShouldMatchExpectedDateTime()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            Assert.Equal(TestDateTime().AddMinutes(5), result.ValidTo);
        }
        public void CreateJsonWebToken_ResultShouldHaveCorrectClaimsCount()
        {
            //arrange
            var userModel    = UserModelHelper.GetUser();
            var appSettings  = MockAppSettings();
            var tokenManager = new TokenManager(Options.Create(appSettings.Object), TestDateTime());

            //act
            var result = tokenManager.CreateJsonWebToken(userModel);

            //assert
            Assert.Equal(9, result.Claims.Count());
        }