public void TestMalformedPayload()
        {
            string res = jwt.GetPayload(token);

            Assert.IsTrue(SecurityUtils.compareStrings(res, ""));
            Assert.IsTrue(jwt.HasError());
        }
        public void TestNegative1()
        {
            options.AddHeaderParameter("pepe", "whatever");
            bool verification = jwt.DoVerify(token, "HS256", claims, options);

            Assert.IsFalse(verification);
            Assert.IsFalse(jwt.HasError());
        }
        public void TestNegative1()
        {
            claimslevel2.setClaim("pepe", "whatever");
            bool verification = jwt.DoVerify(token, "HS256", claimslevel1, options);

            Assert.IsFalse(verification);
            Assert.IsFalse(jwt.HasError());
        }
        public void GenerateToken()
        {
            string hexaKey = keyGen.doGenerateKey("GENERICRANDOM", 256);

            options.SetSecret(hexaKey);
            token = jwt.DoCreate("HS256", claims, options);
            Assert.IsFalse(jwt.HasError());
            bool verification = jwt.DoVerify(token, "HS256", claims, options);

            True(verification, jwt);
        }
        public void TestNegative_JustSign()
        {
            JWTOptions options1 = new JWTOptions();
            string     hexaKey1 = keyGen.doGenerateKey("GENERICRANDOM", 256);

            options1.SetSecret(hexaKey1);
            bool verification = jwt.DoVerifyJustSignature(token, "HS256", options1);

            Assert.IsFalse(verification);
            Assert.IsTrue(jwt.HasError());
        }
        private void bulkTest_shouldWork(PrivateKeyManager key, CertificateX509 cert, string alg, string curve)
        {
            options.SetPrivateKey(key);
            options.SetCertificate(cert);
            string token = jwt.DoCreate(alg, claims, options);

            Assert.IsFalse(jwt.HasError());
            bool verification = jwt.DoVerify(token, alg, claims, options);

            True(verification, jwt);
        }
        public void TestNegative()
        {
            rList.addIDToRevocationList(ID);
            bool verification = jwt.DoVerify(token, "HS256", claims, options);

            Assert.IsFalse(verification);
            Assert.IsFalse(jwt.HasError());
        }
        public void TestDomains()
        {
            options.SetSecret(hexaKey);
            string token = jwt.DoCreate("HS256 ", claims, options);

            Assert.IsFalse(jwt.HasError());
            bool verification = jwt.DoVerifyJustSignature(token, " HS256", options);

            True(verification, jwt);
        }
        public void Test_sha256_1024_PEM()
        {
            String            pathKey = Path.Combine(path_RSA_sha256_1024, "sha256d_key.pem");
            PrivateKeyManager key     = new PrivateKeyManager();

            key.Load(pathKey);
            options.SetPrivateKey(key);
            String alg   = "RS256";
            String token = jwt.DoCreate(alg, claims, options);

            Assert.IsFalse(SecurityUtils.compareStrings("", token));
            Assert.IsFalse(jwt.HasError());
        }