Beispiel #1
0
 public JobStatusChanged(long jobId, string jobReference, JobStatus status, ConfirmationReference confirmationReference, List <Signature> signatures, DateTime nextPermittedPollTime)
 {
     JobId                 = jobId;
     JobReference          = jobReference;
     Status                = status;
     ConfirmationReference = confirmationReference;
     Signatures            = signatures;
     NextPermittedPollTime = nextPermittedPollTime;
 }
            public void Simple_constructor()
            {
                //Arrange
                var confirmationUri = new Uri("http://confirmationUri.no");

                //Act
                var confirmationReference = new ConfirmationReference(confirmationUri);

                //Assert
                Assert.Equal(confirmationUri, confirmationReference.Url);
            }
Beispiel #3
0
        public async Task Confirm(ConfirmationReference confirmationReference)
        {
            var requestResult = await _httpClient.PostAsync(confirmationReference.Url, null).ConfigureAwait(false);

            var requestResultContent = await requestResult.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (!requestResult.IsSuccessStatusCode)
            {
                throw HandleGeneralException(requestResult.StatusCode, requestResultContent);
            }

            _logger.LogDebug($"Successfully confirmed job with confirmation reference: {confirmationReference.Url}");
        }
            public void Simple_constructor()
            {
                //Arrange
                var jobId                 = 123456789;
                var jobReference          = "senders-reference";
                var jobStatus             = JobStatus.InProgress;
                var confirmationReference = new ConfirmationReference(new Uri("http://confirmationreference.no"));
                var nextPermittedPollTime = DateTime.Now;
                var signatures            = new List <Signature>
                {
                    new Signature
                    {
                        SignatureStatus = SignatureStatus.Signed,
                        Identifier      = new PersonalIdentificationNumber("123456789"),
                        XadesReference  = new XadesReference(new Uri("http://xadesuri1.no"))
                    },
                    new Signature
                    {
                        SignatureStatus = SignatureStatus.Waiting,
                        Identifier      = new PersonalIdentificationNumber("123456789"),
                        XadesReference  = null
                    }
                };

                //Act
                var portalJobStatusChangeResponse = new JobStatusChanged(
                    jobId,
                    jobReference,
                    jobStatus,
                    confirmationReference,
                    signatures,
                    nextPermittedPollTime
                    );

                //Assert
                Assert.Equal(jobId, portalJobStatusChangeResponse.JobId);
                Assert.Equal(jobReference, portalJobStatusChangeResponse.JobReference);
                Assert.Equal(jobStatus, portalJobStatusChangeResponse.Status);
                Assert.Equal(confirmationReference, portalJobStatusChangeResponse.ConfirmationReference);
                Assert.Equal(signatures, portalJobStatusChangeResponse.Signatures);
            }
Beispiel #5
0
        public TestHelper ExpectJobStatusForSenderIs(JobStatus expectedStatus, Sender sender = null)
        {
            Assert_state(_jobResponse);

            _jobStatusChanged = GetCurrentReceipt(_jobResponse.JobId, _client, sender);
            Assert.Equal(expectedStatus, _jobStatusChanged.Status);

            if (_jobStatusChanged.Status == NoChanges)
            {
                return(this);
            }

            _confirmationReference = new ConfirmationReference(TransformReferenceToCorrectEnvironment(_jobStatusChanged.ConfirmationReference.Url));

            if (_jobStatusChanged.Status != CompletedSuccessfully)
            {
                return(this);
            }

            _xadesReference = new XadesReference(TransformReferenceToCorrectEnvironment(_jobStatusChanged.Signatures.First().XadesReference.Url));
            _padesReference = new PadesReference(TransformReferenceToCorrectEnvironment(_jobStatusChanged.PadesReference.Url));

            return(this);
        }
Beispiel #6
0
 /// <summary>
 ///     Confirms that the status retrieved from <see cref="GetStatus(StatusReference)" /> is received. If the confirmed
 ///     <see cref="JobStatus" /> is a terminal status (i.e. <see cref="JobStatus.CompletedSuccessfully" /> or
 ///     <see cref="JobStatus.Failed" />),
 ///     the Signature service may make the job's associated resources unavailable through the API when receiving the
 ///     confirmation. Calling this method for a response with no <see cref="ConfirmationReference" /> has no effect.
 /// </summary>
 /// <param name="confirmationReference">the updated status retrieved from <see cref="GetStatus(StatusReference)" /></param>
 public async Task Confirm(ConfirmationReference confirmationReference)
 {
     await RequestHelper.Confirm(confirmationReference).ConfigureAwait(false);
 }
Beispiel #7
0
            public void Converts_portal_job_status_change_response_successfully()
            {
                //Todo: Husk å sjekke om vi skal ha type, ettersom man kan få et fødselsnummer eller en identifier tilbake. Nå er det bare en string

                //Arrange
                var now = DateTime.Now;

                var source = new portalsignaturejobstatuschangeresponse
                {
                    confirmationurl = "http://confirmationurl.no",
                    signaturejobid  = 12345678901011,
                    reference       = "senders-reference",
                    signatures      = new signatures
                    {
                        padesurl  = "http://padesurl.no",
                        signature = new[]
                        {
                            new signature
                            {
                                Item   = "01013300001",
                                status = new signaturestatus
                                {
                                    Value = SignatureStatus.Signed.Identifier,
                                    since = now
                                },
                                xadesurl = "http://xadesurl1.no"
                            },
                            new signature
                            {
                                Item   = "01013300002",
                                status = new signaturestatus
                                {
                                    Value = SignatureStatus.Waiting.Identifier,
                                    since = now
                                },
                                xadesurl = "http://xadesurl2.no"
                            }
                        }
                    },
                    status = portalsignaturejobstatus.IN_PROGRESS
                };

                var jobStatus             = source.status.ToJobStatus();
                var confirmationReference = new ConfirmationReference(new Uri(source.confirmationurl));
                var signature1            = source.signatures.signature[0];
                var signature2            = source.signatures.signature[1];
                var signatures            = new List <Signature>
                {
                    new Signature
                    {
                        SignatureStatus   = new SignatureStatus(signature1.status.Value),
                        Identifier        = new PersonalIdentificationNumber((string)signature1.Item),
                        XadesReference    = new XadesReference(new Uri(signature1.xadesurl)),
                        DateTimeForStatus = now
                    },
                    new Signature
                    {
                        SignatureStatus   = new SignatureStatus(signature2.status.Value),
                        Identifier        = new PersonalIdentificationNumber((string)signature2.Item),
                        XadesReference    = new XadesReference(new Uri(signature2.xadesurl)),
                        DateTimeForStatus = now
                    }
                };

                var nextPermittedPollTime = DateTime.Now;

                var expected = new JobStatusChanged(
                    source.signaturejobid,
                    source.reference,
                    jobStatus,
                    confirmationReference,
                    signatures,
                    nextPermittedPollTime
                    );

                var padesUrl = source.signatures.padesurl;

                if (padesUrl != null)
                {
                    expected.PadesReference = new PadesReference(new Uri(padesUrl));
                }

                //Act
                var actual = DataTransferObjectConverter.FromDataTransferObject(source, nextPermittedPollTime);

                //Assert
                var comparator = new Comparator();
                IEnumerable <IDifference> differences;

                comparator.AreEqual(expected, actual, out differences);
                Assert.Empty(differences);
            }
Beispiel #8
0
 public JobStatusChanged(long jobId, string jobReference, JobStatus status, ConfirmationReference confirmationReference, List <Signature> signatures)
     : this(jobId, jobReference, status, confirmationReference, signatures, DateTime.Now)
 {
 }
 public JobReferences(Uri confirmation, Uri pades)
 {
     Confirmation = new ConfirmationReference(confirmation);
     Pades        = new PadesReference(pades);
 }