Ejemplo n.º 1
0
        public void SetUp()
        {
            var testAssembly = typeof(NotificationTests).Assembly;

            TrustlyApiClientSettings settings;

            using (var trustlyPrivateKey = testAssembly.GetManifestResourceStream("Trustly.Api.Client.UnitTests.Keys.trustly_local_fake_private.pem"))
            {
                using (var trustlyPublicKey = testAssembly.GetManifestResourceStream("Trustly.Api.Client.UnitTests.Keys.trustly_local_fake_public.pem"))
                {
                    using (var merchantPublicKey = testAssembly.GetManifestResourceStream("Trustly.Api.Client.UnitTests.Keys.merchant_public_key.cer"))
                    {
                        // An ugly way to fake as if the "client" is the Trustly server. So we sign the "request" (notification) with Trustly private key.
                        // It is then validated by the same client, with the Trustly public key, as if it is on the other side of the communication.
                        settings = TrustlyApiClientSettings
                                   .ForTest()
                                   .WithoutCredentials()
                                   .WithCertificatesFromStreams(merchantPublicKey, trustlyPrivateKey)
                                   .AndTrustlyCertificateFromStream(trustlyPublicKey);
                    }
                }
            }

            this.client = new TrustlyApiClient(settings);
        }
Ejemplo n.º 2
0
        public AbstractBaseController()
        {
            this.Client = new TrustlyApiClient(TrustlyApiClientSettings.ForDefaultTest());

            this.Client = new TrustlyApiClient(TrustlyApiClientSettings
                                               .ForTest()
                                               .WithCredentialsFromUserHome()
                                               .WithCertificatesFromUserHome()
                                               .AndTrustlyCertificate());
        }
Ejemplo n.º 3
0
        public void TestNullProperties()
        {
            var serializer = new Serializer();

            var testAssembly = typeof(JsonRpcSignerTest).Assembly;

            TrustlyApiClientSettings settings;

            using (var merchantPrivateKey = testAssembly.GetManifestResourceStream("Trustly.Api.Client.UnitTests.Keys.merchant_private_key.cer"))
            {
                using (var merchantPublicKey = testAssembly.GetManifestResourceStream("Trustly.Api.Client.UnitTests.Keys.merchant_public_key.cer"))
                {
                    settings = TrustlyApiClientSettings
                               .ForTest()
                               .WithCredentialsFromEnv()
                               .WithCertificatesFromStreams(merchantPublicKey, merchantPrivateKey)
                               .AndTrustlyCertificate();
                }
            }

            var client = new TrustlyApiClient(settings);
            var signer = new JsonRpcSigner(serializer, settings);

            var rpcResponse = client.CreateResponsePackage("account", "e76ffbe5-e0f9-4402-8689-f868ed2021f8", new NotificationResponse {
                Status = "OK"
            });

            var serialized = serializer.SerializeData(rpcResponse.GetData());

            Assert.AreEqual("statusOK", serialized);

            signer.Sign(rpcResponse);

            Assert.AreEqual(
                "J28IN0yXZN3dlV2ikg4nQKwnP98kso8lzpmuwBcfbXr8i3XeEyydRM4jRwsOOeF0ilGuXyr1Kyb3+1j4mVtgU0SwjVgBHWrYPMegNeykY3meto/aoATH0mvop4Ex1OKO7w/S/ktR2J0J5Npn/EuiKGiVy5GztHYTh9hWmZBCElYPZf4Rsd1CJQJAPlZeAuRcrb5dnbiGJvTEaL/7VLcPT27oqAUefSNb/zNt5yL+wH6BihlkpZ/mtE61lX5OpC46iql6hpsrlOBD3BroYfcwgk1t3YdcNOhVWrmkrlVptGQ/oy6T/LSIKbkG/tJsuV8sl6w1Z31IesK6MZDfSJbcXw==",
                rpcResponse.GetSignature()
                );
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     this.client = new TrustlyApiClient(TrustlyApiClientSettings.ForDefaultTest());
 }