Example #1
0
        public void TestSetUserId_NoClaims_ShouldNotThrowAnyExceptions()
        {
            var claims = new List <Claim>();

            var claimsPrincipal = new ClaimsPrincipal();
            var user            = new WebApiUser(claimsPrincipal);

            Assert.AreEqual(Guid.Empty, user.Id);

            user.Invoking(x => x.SetUserId(claims)).ShouldNotThrow();
        }
Example #2
0
        public void TestSetTokenExpirationDate_InvalidTime()
        {
            var claims = new List <Claim>();

            claims.Add(new Claim(WebApiUser.EXPIRATION_DATE_KEY, "abc"));

            var claimsPrincipal = new ClaimsPrincipal();
            var user            = new WebApiUser(claimsPrincipal);

            user.Invoking(x => x.SetTokenExpirationDate(claims)).ShouldNotThrow();
        }
Example #3
0
        public void TestSetTokenValidAfterDate_InvalidTime()
        {
            var claims = new List <Claim>();

            claims.Add(new Claim(WebApiUser.VALID_NOT_BEFORE_DATE_KEY, "abc"));

            var claimsPrincipal = new ClaimsPrincipal();
            var user            = new WebApiUser(claimsPrincipal);

            user.Invoking(x => x.SetTokenValidAfterDate(claims)).ShouldNotThrow();
        }
Example #4
0
        public void TestSetTokenIssueDate_InvalidTime()
        {
            var claims = new List <Claim>();

            claims.Add(new Claim(WebApiUser.ISSUED_AT_TIME_KEY, "abc"));

            var claimsPrincipal = new ClaimsPrincipal();
            var user            = new WebApiUser(claimsPrincipal);

            user.Invoking(x => x.SetTokenIssueDate(claims)).ShouldNotThrow();
        }
Example #5
0
        public void TestSetUserId_InvalidGuid_ShouldNotThrow()
        {
            var id     = "hello";
            var claims = new List <Claim>();

            claims.Add(new Claim(WebApiUser.USER_ID_KEY, id.ToString()));

            var claimsPrincipal = new ClaimsPrincipal();
            var user            = new WebApiUser(claimsPrincipal);

            Assert.AreEqual(Guid.Empty, user.Id);
            user.Invoking(x => x.SetUserId(claims)).ShouldNotThrow();
        }