Ejemplo n.º 1
0
        private void RunOnDeviceFarm(string buildId)
        {
            // TODO use allCloudTests
            var runTests = new List <string>(new string[] { "DummyUTFTest" });

            jobStatus = Client.RunCloudTests(buildId, runTests);
        }
            public void SimpleConstructor()
            {
                //Arrange
                var jobId                 = 22;
                var jobReference          = "senders-reference";
                var jobStatus             = JobStatus.Failed;
                var jobReferences         = DomainUtility.GetJobReferences();
                var signatures            = DomainUtility.GetSignatures(1);
                var nextPermittedPollTime = DateTime.Now;


                //Act
                var jobStatusResponse = new JobStatusResponse(
                    jobId,
                    jobReference,
                    jobStatus,
                    jobReferences,
                    signatures,
                    nextPermittedPollTime

                    );

                //Assert
                Assert.Equal(jobId, jobStatusResponse.JobId);
                Assert.Equal(jobReference, jobStatusResponse.JobReference);
                Assert.Equal(jobStatus, jobStatusResponse.Status);
                Assert.Equal(jobReferences, jobStatusResponse.References);
                Assert.Equal(signatures, jobStatusResponse.Signatures);
                Assert.Equal(nextPermittedPollTime, jobStatusResponse.NextPermittedPollTime);
            }
        public TestHelper Get_status_by_polling(Sender sender)
        {
            var jobStatusResponse = GetCurrentReceipt(_jobResponse.JobId, sender);

            _status = TransformJobUrlsToCorrectEnvironmentIfNeeded(jobStatusResponse);
            return(this);
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <JobStatusResponse> > SubmitJob([FromBody] JobSubmitRequest request)
        {
            _eventTracker.TrackInfo("SubmitJob", "Submitting a new job", request);
            if (User.Identity.Name == null)
            {
                _eventTracker.TrackInfo("SubmitJob", "Unauthorized attempt to list all jobs");
                return(Unauthorized());
            }

            if (request.Attributes == null)
            {
                request.Attributes = new Dictionary <string, Dictionary <string, string> >();
            }

            var jobSubmit = new JobSubmit
            {
                JobName    = request.JobName,
                TopicQuery = request.TopicQuery,
                SelectedAcquirersIdentifiers = request.SelectedAcquirers,
                SelectedAnalysersIdentifiers = request.SelectedAnalysers,
            };

            var jobStatus = await _jobManagementService.SubmitJob(jobSubmit, request.Attributes);

            var response = new JobStatusResponse
            {
                JobId  = jobStatus.JobId,
                Status = jobStatus.Status,
            };

            _eventTracker.TrackInfo("SubmitJob", "New job submitted", response);
            return(Ok(response));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Return the status of a submitted job.
        /// </summary>
        /// <param name="requestIdentifier">Identifier for the request of interest.</param>
        /// <returns>The status of the request.</returns>
        public ServiceRequestInformation GetRequestStatus(string requestIdentifier)
        {
            ServiceRequestInformation status    = new ServiceRequestInformation();
            JobStatusResponse         jobStatus = _blastClient.QueryJobStatus(
                new Guid(requestIdentifier));

            switch (jobStatus.Status)
            {
            case STATUSRUNNING:
                status.StatusInformation = jobStatus.Status;
                status.Status            = ServiceRequestStatus.Waiting;
                break;

            case STATUSSUCCEEDED:
                status.StatusInformation = jobStatus.Status;
                status.Status            = ServiceRequestStatus.Ready;
                break;

            case STATUSFAILED:
                status.StatusInformation = jobStatus.Status;
                status.Status            = ServiceRequestStatus.Error;
                break;
            }

            return(status);
        }
        public TestHelper Get_status()
        {
            Assert_state(_statusReference);

            _status = TransformJobUrlsToCorrectEnvironmentIfNeeded(_directClient.GetStatus(_statusReference).Result);
            return(this);
        }
        public async Task ConfirmSignatureJob()
        {
            ClientConfiguration clientConfiguration = null; //As initialized earlier
            var directClient = new DirectClient(clientConfiguration);
            JobStatusResponse jobStatusResponse = null;     // Result of requesting job status

            await directClient.Confirm(jobStatusResponse.References.Confirmation);
        }
            public void Converts_direct_job_status_with_multiple_signers_successfully()
            {
                //Arrange
                var now = DateTime.Now;

                var source = new directsignaturejobstatusresponse
                {
                    signaturejobid     = 77,
                    reference          = null,
                    signaturejobstatus = directsignaturejobstatus.FAILED,
                    status             = new[]
                    {
                        new signerstatus {
                            signer = "12345678910", Value = "REJECTED", since = now
                        },
                        new signerstatus {
                            signer = "10987654321", Value = "SIGNED", since = now
                        }
                    },
                    xadesurl = new[]
                    {
                        new signerspecificurl {
                            signer = "10987654321", Value = "https://example.com/xades-url"
                        }
                    },
                    confirmationurl = "https://example.com/confirmation-url"
                };

                var nextPermittedPollTime = DateTime.Now;

                var expected = new JobStatusResponse(
                    source.signaturejobid,
                    source.reference,
                    JobStatus.Failed,
                    new JobReferences(new Uri("https://example.com/confirmation-url"), null),
                    new List <Signature>
                {
                    new Signature("12345678910", null, SignatureStatus.Rejected, now),
                    new Signature("10987654321", new XadesReference(new Uri("https://example.com/xades-url")), SignatureStatus.Signed, now)
                },
                    nextPermittedPollTime
                    );

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

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

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Ejemplo n.º 9
0
        public async Task CanCreateUpdateAndDeleteMultipeOrganizationsAsync()
        {
            var res1 = await api.Organizations.CreateOrganizationAsync(new Organization()
            {
                Name = "Test Org 1"
            });

            var res2 = await api.Organizations.CreateOrganizationAsync(new Organization()
            {
                Name = "Test Org 2"
            });

            Assert.That(res1.Organization.Id, Is.GreaterThan(0));
            Assert.That(res2.Organization.Id, Is.GreaterThan(0));

            res1.Organization.Notes = "Here is a sample note 1";
            res2.Organization.Notes = "Here is a sample note 2";

            var organisations = new List <Organization> {
                res1.Organization, res2.Organization
            };
            var updateJobStatus = await api.Organizations.UpdateMultipleOrganizationsAsync(organisations);

            Assert.That(updateJobStatus.JobStatus.Status, Is.EqualTo("queued"));
            JobStatusResponse job = null;

            do
            {
                Thread.Sleep(5000);
                job = await api.JobStatuses.GetJobStatusAsync(updateJobStatus.JobStatus.Id);

                Assert.That(job.JobStatus.Id, Is.EqualTo(updateJobStatus.JobStatus.Id));

                if (job.JobStatus.Status == "completed")
                {
                    break;
                }
            } while (true);

            var updatedOrganizationIds = new List <long> {
                res1.Organization.Id.Value, res2.Organization.Id.Value
            };
            var updatedOrganizations = await api.Organizations.GetMultipleOrganizationsAsync(updatedOrganizationIds);

            Assert.That(updatedOrganizations.Organizations.FirstOrDefault(o => o.Id == res1.Organization.Id).Notes, Is.EqualTo(res1.Organization.Notes));
            Assert.That(updatedOrganizations.Organizations.FirstOrDefault(o => o.Id == res2.Organization.Id).Notes, Is.EqualTo(res2.Organization.Notes));

            await api.Organizations.DeleteOrganizationAsync(res1.Organization.Id.Value);

            await api.Organizations.DeleteOrganizationAsync(res2.Organization.Id.Value);
        }
Ejemplo n.º 10
0
        void RefreshJobStatus()
        {
            if (string.IsNullOrEmpty(jobStatus.jobId.Trim()))
            {
                return;
            }
            if ((DateTime.UtcNow - lastRefresh).TotalSeconds < 1)
            {
                return;
            }
            lastRefresh = DateTime.UtcNow;

            jobStatus = Client.GetJobStatus(jobStatus.jobId);
        }
Ejemplo n.º 11
0
        public async Task <ActionResult <JobStatusResponse> > StopJob([FromRoute] Guid jobId)
        {
            if (!await _authorizationService.IsUserAuthorizedToSeeJob(User.Identity.Name, jobId))
            {
                _eventTracker.TrackInfo("StopJob", $"User '{User.Identity.Name}' is not authorized to stop job '{jobId}'");
                return(Unauthorized());
            }

            var jobStatus = await _jobManagementService.StopJob(jobId);

            var response = new JobStatusResponse
            {
                JobId  = jobStatus.JobId,
                Status = jobStatus.Status,
            };

            return(Ok(response));
        }
        public async Task GetXadesAndPades()
        {
            ClientConfiguration clientConfiguration = null; //As initialized earlier
            var directClient = new DirectClient(clientConfiguration);
            JobStatusResponse jobStatusResponse = null;     // Result of requesting job status

            if (jobStatusResponse.Status == JobStatus.CompletedSuccessfully)
            {
                var padesByteStream = await directClient.GetPades(jobStatusResponse.References.Pades);
            }

            var signature = jobStatusResponse.GetSignatureFor(new PersonalIdentificationNumber("00000000000"));

            if (signature.Equals(SignatureStatus.Signed))
            {
                var xadesByteStream = await directClient.GetXades(signature.XadesReference);
            }
        }
            public void Converts_signed_direct_job_status_successfully()
            {
                //Arrange
                var now = DateTime.Now;

                var source = new directsignaturejobstatusresponse
                {
                    signaturejobid     = 77,
                    reference          = "senders-reference",
                    signaturejobstatus = directsignaturejobstatus.COMPLETED_SUCCESSFULLY,
                    status             = new[] { new signerstatus {
                                                     signer = "12345678910", Value = "SIGNED", since = now
                                                 } },
                    confirmationurl = "http://signatureRoot.digipost.no/confirmation",
                    xadesurl        = new[] { new signerspecificurl {
                                                  signer = "12345678910", Value = "http://signatureRoot.digipost.no/xades"
                                              } },
                    padesurl = "http://signatureRoot.digipost.no/pades"
                };

                var nextPermittedPollTime = DateTime.Now;

                var expected = new JobStatusResponse(
                    source.signaturejobid,
                    source.reference,
                    JobStatus.CompletedSuccessfully,
                    new JobReferences(new Uri(source.confirmationurl), new Uri(source.padesurl)),
                    new List <Signature> {
                    new Signature("12345678910", new XadesReference(new Uri("http://signatureRoot.digipost.no/xades")), SignatureStatus.Signed, now)
                },
                    nextPermittedPollTime
                    );

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

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

                comparator.AreEqual(expected, result, out differences);
                Assert.Empty(differences);
            }
Ejemplo n.º 14
0
        /// <summary>
        /// Get the solution (if solved)
        /// </summary>
        /// <returns></returns>
        public async Task <Solution> GetSolution(CancellationToken ct)
        {
            var solution          = new Solution();
            var jobStatusResponse = new JobStatusResponse {
                status = ResponseJobStatus.failure
            };

            var submissionStatusResponse = await client.GetSubmissionStatus(submissionId, ct);

            if (submissionStatusResponse.jobs != null && !ct.IsCancellationRequested)
            {
                jobStatusResponse = await client.GetJobStatus(submissionStatusResponse.jobs[0], ct);
            }


            if (submissionStatusResponse.jobs != null && jobStatusResponse.status.Equals(ResponseJobStatus.success) &&
                !ct.IsCancellationRequested)
            {
                CalibrationResponse calibrationResponse = client.GetCalibration(submissionStatusResponse.jobs[0]);
                var objectsInFieldResponse = client.GetObjectsInField(submissionStatusResponse.jobs[0]);

                solution.RA             = calibrationResponse.ra;
                solution.Dec            = calibrationResponse.dec;
                solution.Radius         = calibrationResponse.radius;
                solution.Status         = SolverStatus.Success;
                solution.ObjectsInField = objectsInFieldResponse.objects_in_field;
                return(solution);
            }

            if (ct.IsCancellationRequested)
            {
                solution.Status = SolverStatus.Canceled;
                return(solution);
            }

            solution.Status = SolverStatus.Failure;
            return(solution);
        }
        private static JobStatusResponse TransformJobUrlsToCorrectEnvironmentIfNeeded(JobStatusResponse jobStatusResponse)
        {
            if (Endpoint == Localhost)
            {
                jobStatusResponse.Signatures = jobStatusResponse.Signatures.Select(signature =>
                {
                    var xadesReference = signature.XadesReference == null ? null : new XadesReference(TransformReferenceToCorrectEnvironment(signature.XadesReference.Url));
                    return(new Signature(signature.Signer, xadesReference, signature.SignatureStatus, signature.DateTimeForStatus));
                }).ToList();

                jobStatusResponse.References.Pades        = new PadesReference(TransformReferenceToCorrectEnvironment(jobStatusResponse.References.Pades.Url));
                jobStatusResponse.References.Confirmation = new ConfirmationReference(TransformReferenceToCorrectEnvironment(jobStatusResponse.References.Confirmation.Url));
            }

            return(jobStatusResponse);
        }
        private void ConfirmExcessReceipt(JobStatusResponse jobStatusResponse2)
        {
            var uri = TransformReferenceToCorrectEnvironment(jobStatusResponse2.References.Confirmation.Url);

            _directClient.Confirm(new ConfirmationReference(uri)).Wait();
        }