public void ValidateWithInvalidSecret()
        {
            Exception e = null;

            JwtManager.HsJwt sJwt = new JwtManager.HsJwt
            {
                KeySize = HashKeySize(),
                Secret  = Secret
            };
            JwtManager.HsJwt vJwt = new JwtManager.HsJwt
            {
                KeySize = HashKeySize(),
                Secret  = Secret + "a"
            };

            try
            {
                string data       = "{a:1,b:2}";
                string signedData = sJwt.Sign(data);
                Assert.IsNull(e, "An exception should not be thrown here");
                string validatedData = vJwt.Validate(signedData);
            }
            catch (Exception ex)
            {
                e = ex;
            }

            Assert.IsNotNull(e, "An exception should be thrown");
            Assert.AreEqual(e.Message, "Invalid signature.");
        }
        public void ValidateWithInvalidHashAlgorithm()
        {
            Exception e = null;

            JwtManager.HsJwt sJwt = new JwtManager.HsJwt
            {
                KeySize = HashKeySize(),
                Secret  = Secret
            };

            JwtManager.HsJwt vJwt = new JwtManager.HsJwt
            {
                KeySize = (JwtManager.Helpers.KeySize) 555,
                Secret  = Secret
            };

            try
            {
                string data       = "{\"a\":1,\"b\":2}";
                string signedData = sJwt.Sign(data);
                Assert.IsNull(e, "An exception should not be thrown here");
                string validatedData = vJwt.Validate(signedData);
            }
            catch (Exception ex)
            {
                e = ex;
            }

            Assert.IsNotNull(e, "An exception should be thrown");
            Assert.AreEqual(e.Message, "Non-valid key size.");
        }
        public void ValidateData()
        {
            string data = "{\"a\":1,\"b\":2}";

            JwtManager.HsJwt signJwt = new JwtManager.HsJwt
            {
                KeySize = HashKeySize(),
                Secret  = Secret
            };

            string signedData = signJwt.Sign(data);

            JwtManager.HsJwt jwt = new JwtManager.HsJwt
            {
                KeySize = HashKeySize(),
                Secret  = Secret
            };
            string validatedData = jwt.Validate(signedData);

            Assert.AreEqual(data, validatedData, "Signed data should match original data");
        }
        public void ValidateInvalidData()
        {
            Exception e = null;

            JwtManager.HsJwt jwt = new JwtManager.HsJwt
            {
                KeySize = HashKeySize(),
                Secret  = Secret
            };

            try
            {
                string data          = "{\"a\":1,\"b\":2}";
                string signedData    = jwt.Sign(data);
                string validatedData = jwt.Validate(signedData + "a");
            }
            catch (Exception ex)
            {
                e = ex;
            }


            Assert.IsNotNull(e, "An exception should be thrown");
        }