Esempio n. 1
0
        /// <summary>
        /// Test helper to test fetch for various states of requests in the workflow.
        /// </summary>
        private async Task FetchRequestsAllApplications(bool purged = false)
        {
            Skip.If(!_fixture.RegistrationOk);
            foreach (var application in _applicationTestSet)
            {
                foreach (var requestId in application.RequestIds)
                {
                    var appModel      = application.Model;
                    var applicationId = application.Model.ApplicationId.ToString();
                    if (purged)
                    {
                        await Assert.ThrowsAsync <ResourceNotFoundException>(async() =>
                        {
                            await _certificateRequest.FetchRequestAsync(requestId, applicationId);
                        });

                        continue;
                    }
                    var fetchResult = await _certificateRequest.FetchRequestAsync(requestId, applicationId);

                    Assert.Equal(requestId, fetchResult.RequestId);
                    Assert.Equal(applicationId, fetchResult.ApplicationId);
                    if (fetchResult.State == CertificateRequestState.Approved ||
                        fetchResult.State == CertificateRequestState.Accepted)
                    {
                        if (fetchResult.PrivateKey != null)
                        {
                            Assert.Equal(application.PrivateKeyFormat, fetchResult.PrivateKeyFormat);
                        }
                        Assert.NotNull(fetchResult.SignedCertificate);
                        if (fetchResult.PrivateKey != null)
                        {
                            Assert.NotNull(fetchResult.PrivateKey);
                        }
                        else
                        {
                            Assert.Null(fetchResult.PrivateKey);
                        }
                    }
                    else
                    if (fetchResult.State == CertificateRequestState.Revoked ||
                        fetchResult.State == CertificateRequestState.Deleted)
                    {
                        Assert.Null(fetchResult.PrivateKey);
                    }
                    else if (fetchResult.State == CertificateRequestState.Rejected ||
                             fetchResult.State == CertificateRequestState.New ||
                             fetchResult.State == CertificateRequestState.Removed
                             )
                    {
                        Assert.Null(fetchResult.PrivateKey);
                        Assert.Null(fetchResult.SignedCertificate);
                    }
                    else
                    {
                        Assert.True(false, "Invalid State");
                    }
                }
            }
        }
Esempio n. 2
0
        public async Task <FetchRequestResultApiModel> FetchCertificateRequestResultAsync(string requestId, string applicationId)
        {
            var result = await _certificateRequest.FetchRequestAsync(
                requestId,
                applicationId
                );

            return(new FetchRequestResultApiModel(
                       requestId,
                       applicationId,
                       result.State,
                       result.CertificateGroupId,
                       result.CertificateTypeId,
                       result.SignedCertificate,
                       result.PrivateKeyFormat,
                       result.PrivateKey,
                       result.AuthorityId
                       ));
        }