public void GenerateToken_WithPayload() { string expectedSignedToken = "eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsImV4cCI6MTUzOTEyOTYwMDAwMCwidGkiOiJhMjFkNDIzYS00M2ZkLTQ4MjEtODRmYS00MzkwZjZhMmZkM2UiLCJjIjoidGlja2V0YW5pYSIsImUiOiJteWV2ZW50In0.0rDlI69F1Dx4Twps5qD4cQrbXbCRiezBd6fH1PVm6CnVY456FALkAhN3rgVrh_PGCJHcEXN5zoqFg65MH8WZc_CQdD63hJre3Sedu0-9zIs.aZgzkJm57etFaXjjME_-9LjOgPNTTqkp1aJ057HuEiU"; IEnqueueTokenPayload payload = Payload .Enqueue() .WithKey("somekey") .WithRelativeQuality(0.45678663514) .WithCustomData("color", "blue") .WithCustomData("size", "medium") .Generate(); EnqueueToken token = new EnqueueToken( "a21d423a-43fd-4821-84fa-4390f6a2fd3e", "ticketania", "myevent", new DateTime(2018, 08, 20, 0, 0, 0, DateTimeKind.Utc), new DateTime(2018, 10, 10, 0, 0, 0, DateTimeKind.Utc), null, null, payload); token.Generate("5ebbf794-1665-4d48-80d6-21ac34be7faedf9e10b3-551a-4682-bb77-fee59d6355d6", false); string actualSignedToken = token.Token; Assert.Equal(expectedSignedToken, actualSignedToken); }
public void GenerateToken_MinimalHeader() { string expectedSignedToken = "eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsInRpIjoiYTIxZDQyM2EtNDNmZC00ODIxLTg0ZmEtNDM5MGY2YTJmZDNlIiwiYyI6InRpY2tldGFuaWEifQ..ChCRF4bTbt4zlOcvXLjQYouhgqgiNNNZqcci8VWoZIU"; EnqueueToken token = new EnqueueToken( "a21d423a-43fd-4821-84fa-4390f6a2fd3e", "ticketania", null, new DateTime(2018, 08, 20, 0, 0, 0, DateTimeKind.Utc), null, null, null, null); token.Generate("5ebbf794-1665-4d48-80d6-21ac34be7faedf9e10b3-551a-4682-bb77-fee59d6355d6", false); string actualSignedToken = token.Token; Assert.Equal(expectedSignedToken, actualSignedToken); }
public void GenerateToken_WithoutPayload() { string expectedSignedToken = "eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsImV4cCI6MTUzOTEyOTYwMDAwMCwidGkiOiJhMjFkNDIzYS00M2ZkLTQ4MjEtODRmYS00MzkwZjZhMmZkM2UiLCJjIjoidGlja2V0YW5pYSIsImUiOiJteWV2ZW50IiwiaXAiOiI1LjcuOC42IiwieGZmIjoiNDUuNjcuMi40LDM0LjU2LjMuMiJ9..wUOdVDIKlrIqumpU33bShDPdvTkicRk3q4Z-Vs8epFc"; EnqueueToken token = new EnqueueToken( "a21d423a-43fd-4821-84fa-4390f6a2fd3e", "ticketania", "myevent", new DateTime(2018, 08, 20, 0, 0, 0, DateTimeKind.Utc), new DateTime(2018, 10, 10, 0, 0, 0, DateTimeKind.Utc), "5.7.8.6", "45.67.2.4,34.56.3.2", null); token.Generate("5ebbf794-1665-4d48-80d6-21ac34be7faedf9e10b3-551a-4682-bb77-fee59d6355d6", false); string actualSignedToken = token.Token; Assert.Equal(expectedSignedToken, actualSignedToken); }