Exemplo n.º 1
0
            public void ShouldDecryptMessage()
            {
                var message = JweMessage.FromEncryptedString(
                    CardInfoEncryptedMessage,
                    new List <X509Certificate2> {
                    IssuerEncryptionCert.GetP12Cert()
                },
                    new DevJweCryptoPolicy());

                var cardInfoRequest = message.GetDecryptedJsonObjectAs <GetCardInfoRequest>();

                cardInfoRequest.Should().NotBeNull();

                cardInfoRequest.Pan.Should().Be("1234567890123456");
                cardInfoRequest.TransactionType.Should().Be("Browser Based (2.0)");
                cardInfoRequest.Service.Should().Be("RSA_CLIENT");
                cardInfoRequest.RsaSessionId.Should().Be("1122334455667788");
                cardInfoRequest.TimeStamp.Should().Be("20190530052056");
                cardInfoRequest.Version.Should().Be("3.1");

                cardInfoRequest.PurchaseAttributes.Amount.Should().Be("100.00");
                cardInfoRequest.PurchaseAttributes.MerchantName.Should().Be("Merchant Name 1");
                cardInfoRequest.PurchaseAttributes.Currency.Should().Be("USD");
                cardInfoRequest.PurchaseAttributes.MerchantCountryCode.Should().Be("UK");
            }
Exemplo n.º 2
0
            public void ShouldBeValidSignature()
            {
                var message = JweMessage.FromEncryptedString(
                    CardInfoEncryptedMessage,
                    new List <X509Certificate2> {
                    IssuerEncryptionCert.GetP12Cert()
                },
                    new DevJweCryptoPolicy());

                message.IsSignatureValidAndTrusted().Should().BeTrue();
            }
Exemplo n.º 3
0
            public void ShouldEncryptMessage()
            {
                var encryptedToken = JweMessage.CreateFromClearText(
                    "This is a test...",
                    IssuerEncryptionCert.GetP12Cert(),
                    new List <X509Certificate2>
                {
                    IssuerEncryptionCert.GetP12Cert()
                });

                encryptedToken.Should().NotBeNull();
            }
Exemplo n.º 4
0
            public void RoundTripEncryptAndDecryptMessageShouldBeLossless()
            {
                var jweMessage = JweMessage.CreateFrom <GetCardInfoRequest>(
                    CardInfoMessage,
                    IssuerEncryptionCert.GetP12Cert(),
                    new List <X509Certificate2>
                {
                    IssuerEncryptionCert.GetP12Cert()
                });

                jweMessage.Should().NotBeNull();

                var decryptedMessage = JweMessage.FromEncryptedString <GetCardInfoRequest>(
                    jweMessage,
                    new List <X509Certificate2> {
                    IssuerEncryptionCert.GetP12Cert()
                },
                    new DevJweCryptoPolicy());

                decryptedMessage.Should().BeEquivalentTo(CardInfoMessage);
            }