Example #1
0
        public static void ValidateTokenReplay(string securityToken, ISecurityTokenValidator tokenValidator, TokenValidationParameters validationParameters)
        {
            TokenValidationParameters tvp = validationParameters.Clone() as TokenValidationParameters;

            Microsoft.IdentityModel.Test.TokenReplayCache replayCache =
                new Microsoft.IdentityModel.Test.TokenReplayCache()
            {
                OnAddReturnValue  = true,
                OnFindReturnValue = false,
            };

            tvp.TokenReplayCache = replayCache;
            TestUtilities.ValidateToken(securityToken, tvp, tokenValidator, ExpectedException.NoExceptionExpected);

            replayCache.OnFindReturnValue = true;
            TestUtilities.ValidateToken(securityToken, tvp, tokenValidator, ExpectedException.SecurityTokenReplayDetected());

            replayCache.OnFindReturnValue = false;
            replayCache.OnAddReturnValue  = false;
            TestUtilities.ValidateToken(securityToken, tvp, tokenValidator, ExpectedException.SecurityTokenReplayAddFailed());
        }