Beispiel #1
0
        public static async Task ImmediateRoundtripStringWithFragment()
        {
            const string origUrl = "https://www.example.com#myFragment";

            var signer       = new TimedUrlSigner(new HmacUrlSigner <HMACSHA512>(Key));
            var signedString = signer.Sign(origUrl, TestTtl);
            await Task.Delay((int)TestTtl.TotalMilliseconds / 2);

            Assert.True(signer.Verify(signedString));
            Assert.EndsWith("#myFragment", signedString); // we want preserve fragment component

            var signedStringWithoutFragment = signedString.Replace("#myFragment", "");

            Assert.True(signer.Verify(signedStringWithoutFragment));
        }
Beispiel #2
0
        public static async Task ExpiredRoundtripString()
        {
            var signer       = new TimedUrlSigner(new HmacUrlSigner <HMACSHA512>(Key));
            var signedString = signer.Sign(TestString, TestTtl);
            await Task.Delay((int)TestTtl.TotalMilliseconds * 2);

            Assert.False(signer.Verify(signedString));
        }
Beispiel #3
0
        public static async Task ImmediateRoundtripUri()
        {
            var signer    = new TimedUrlSigner(new HmacUrlSigner <HMACSHA512>(Key));
            var signedUri = signer.Sign(TestUri, TestTtl);
            await Task.Delay((int)TestTtl.TotalMilliseconds / 2);

            Assert.True(signer.Verify(signedUri));
        }