public DigipostApiIntegrationTests()
 {
     ClientConfig = new ClientConfig(new Broker(1337), Environment.Production)
     {
         LogRequestAndResponse = false,
         TimeoutMilliseconds   = 300000000
     };
     Uri         = new Uri("/identification", UriKind.Relative);
     Certificate = CertificateResource.Certificate();
 }
            public void ReturnsCorrectSignature()
            {
                //Arrange
                const string senderId          = "1337";
                const string uri               = "http://fakeuri.no/someendpoint";
                const string method            = "POST";
                const string sha256Hash        = "TheHashOfContentForHeader";
                const string expectedSignature =
                    "HEZfhL+mu0Pb9Owvfs7pHLUXxZPthONK53nWTwXPFtFVjslr4AIxLqUSbAO7PerzBcRryYa84SellVabx8t16Ixg52afLQb02qyeDx1qF23YAIvvv01NmEJkVUUTV/oN7MgDAb4NGeujzVoUzXKTV+b5YC4W2c4M/RWSGYF1HxEEo+82SDyTlwGa3XxhcVem2Kg0LOgZvKaJnFWk0fsVDI7J9xWdOY0NWbtlm/xu77w2IlR+91lbr2G5A75lyzboXVEYvOj3UGzKwFTqGDpR7var+/PzWh00lQ/dKtILKzDGz3E80CxCOtlU/6kczk9MtYVQvLCy7QR0GMUI6ypTzg==";
                var certificate = CertificateResource.Certificate();
                var dateTime    = new DateTime(2014, 07, 07, 12, 00, 02).ToString("R");

                //Act
                var computedSignature = AuthenticationHandler.ComputeSignature(method, new Uri(uri), dateTime, sha256Hash,
                                                                               senderId,
                                                                               certificate,
                                                                               false);

                //Assert
                Assert.Equal(expectedSignature, computedSignature);
            }
Exemple #3
0
        public static TestSender GetSender(TestEnvironment testEnvironment)
        {
            switch (testEnvironment)
            {
            case TestEnvironment.DifiTest:
                return(new TestSender(
                           497013,
                           CertificateResource.Certificate(),
                           Environment.DifiTest,
                           new RecipientById(IdentificationType.DigipostAddress, "ReplaceMehere")
                           ));

            case TestEnvironment.Qa:
                return(new TestSender(
                           1185201,
                           CertificateReader.ReadCertificate(),
                           Environment.Qa,
                           new RecipientById(IdentificationType.DigipostAddress, "liv.test.aliassen#8514")
                           ));

            default:
                throw new ArgumentOutOfRangeException(nameof(testEnvironment), testEnvironment, null);
            }
        }