public void Decode_IKeyManagement_Override() { //given MockKeyManagement keyMgmt = new MockKeyManagement(); string token = "eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4R0NNIn0..yVi-LdQQngN0C5WS.1McwSmhZzAtmmLp9y-OdnJwaJFo1nj_4ashmzl2LhubGf0Jl1OTEVJzsHZb7bkup7cGTkuxh6Vfv10ljHsjWf_URXoxP3stQqQeViVcuPV0y2Q_WHYzTNGZpmHGe-hM6gjDhyZyvu3yeXGFSvfPQmp9pWVOgDjI4RC0MQ83rzzn-rRdnZkznWjbmOPxwPrR72Qng0BISsEwbkPn4oO8-vlHkVmPpuDTaYzCT2ZR5K9JnIU8d8QdxEAGb7-s8GEJ1yqtd_w._umbK59DAKA3O89h15VoKQ"; //when string json = Jose.JWT.Decode(token, aes128Key, settings: new JwtSettings().RegisterJwa(JweAlgorithm.DIR, keyMgmt)); //then Console.Out.WriteLine("json = {0}", json); Assert.Equal(json, @"{""exp"":1392548520,""sub"":""alice"",""nbf"":1392547920,""aud"":[""https:\/\/app-one.com"",""https:\/\/app-two.com""],""iss"":""https:\/\/openid.net"",""jti"":""0e659a67-1cd3-438b-8888-217e72951ec9"",""iat"":1392547920}"); Assert.True(keyMgmt.UnwrapCalled); }
public void Encode_IKeyManagement_Override() { //given MockKeyManagement keyMgmt = new MockKeyManagement(); string json = @"{""exp"":1389189552,""sub"":""alice"",""nbf"":1389188952,""aud"":[""https:\/\/app-one.com"",""https:\/\/app-two.com""],""iss"":""https:\/\/openid.net"",""jti"":""e543edf6-edf0-4348-8940-c4e28614d463"",""iat"":1389188952}"; //when string token = Jose.JWT.Encode(json, aes128Key, JweAlgorithm.DIR, JweEncryption.A128GCM, settings: new JwtSettings().RegisterJwa(JweAlgorithm.DIR, keyMgmt)); //then Console.Out.WriteLine("DIR_A128GCM = {0}", token); string[] parts = token.Split('.'); Assert.Equal(Jose.JWT.Decode(token, aes128Key), json); Assert.True(keyMgmt.WrapCalled); }