public void TestBuild()
        {
            var hasher  = new TestHasher();
            var builder = new TokenBuilder(hasher.HashName)
                          .AddClaim("Hello", "World");

            var(success, _, token, error) = builder.BuildAsync(hasher).Result;
            Assert.True(success, error);

            _testOutputHelper.WriteLine(Encoding.UTF8.GetString(token));

            (success, _, error) = new Token(token).VerifyAsync(hasher).Result;
            Assert.True(success, error);
        }
Exemple #2
0
        public async Task TestValidVerify()
        {
            var exp     = DateTime.UtcNow.AddHours(1);
            var iat     = DateTime.UtcNow;
            var builder = new TokenBuilder(_testHasher.HashName)
                          .SetExpiry(exp)
                          .SetIssuedAt(iat)
                          .SetNotBefore(iat);

            var(success, _, tokenData, error) = await builder.BuildAsync(_testHasher);

            Assert.True(success, error);

            var token = new Token(tokenData);

            (success, _, error) = await token.VerifyAsync(_testHasher);

            Assert.True(success, error);
        }