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)); }
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)); }
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)); }