public void RoundTrip() { const string payload = "Frank Denis rocks"; string signature = PasetoUtility.SignBytes(_publicKey, _privateKey, Encoding.UTF8.GetBytes(payload)); Assert.Equal(payload, Encoding.UTF8.GetString(PasetoUtility.ParseBytes(_publicKey, signature).Payload)); }
public void FooterCanBeParsed() { string footerText = "Hello friend"; Assert.Equal(footerText, PasetoUtility.ParseFooter(PasetoUtility.SignBytes(_publicKey, _privateKey, new byte[0], footerText))); var footerJson = new Dictionary <string, object> { ["hello"] = "friend" }; Assert.Equal(footerJson, PasetoUtility.ParseFooterJson(PasetoUtility.Sign(_publicKey, _privateKey, new PasetoInstance { Footer = footerJson }))); }
public void TimezonesAreAllowed(string tokenJson) { var signedBytes = PasetoUtility.SignBytes(_publicKey, _privateKey, Encoding.UTF8.GetBytes(tokenJson)); Assert.Equal("2018-03-20T07:00:00+00:00", PasetoUtility.Parse(_publicKey, signedBytes, validateTimes: false).Expiration.Value.ToString(Iso8601Format)); }
public void InvalidJsonThrows(string str) { string token = PasetoUtility.SignBytes(_publicKey, _privateKey, Encoding.UTF8.GetBytes(str)); Assert.Throws <PasetoFormatException>(() => PasetoUtility.Parse(_publicKey, token)); }
public void EmptyTokenRoundTrip() { PasetoUtility.Parse(_publicKey, PasetoUtility.SignBytes(_publicKey, _privateKey, Encoding.UTF8.GetBytes("{}"))); Assert.Equal("{}", Encoding.UTF8.GetString(PasetoUtility.ParseBytes(_publicKey, PasetoUtility.Sign(_publicKey, _privateKey, new PasetoInstance())).Payload)); }