public async Task Throws_exception_on_no_sender() { //Arrange var clientConfiguration = new ClientConfiguration(Environment.DifiQa, GetPostenTestCertificate()); var directClient = new DirectClient(clientConfiguration); var directJob = new Job(DomainUtility.GetDirectDocument(), DomainUtility.GetSigner(), "SendersReference", DomainUtility.GetExitUrls()); //Act await Assert.ThrowsAsync <SenderNotSpecifiedException>(async() => await directClient.Create(directJob).ConfigureAwait(false)).ConfigureAwait(false); }
internal SignatureGenerator GetSignaturGenerator() { var document = DomainUtility.GetDirectDocument(); var sender = CoreDomainUtility.GetSender(); var signers = DomainUtility.GetSigner(); var manifest = new Manifest(sender, document, signers); var x509Certificate2 = CoreDomainUtility.GetTestCertificate(); var signaturGenerator = new SignatureGenerator(x509Certificate2, document, manifest); return(signaturGenerator); }
public void SimpleConstructor() { //Arrange var sender = CoreDomainUtility.GetSender(); var document = DomainUtility.GetDirectDocument(); var signer = DomainUtility.GetSigner(); //Act var manifest = new Manifest(sender, document, signer); //Assert Assert.Equal(sender, manifest.Sender); Assert.Equal(document, manifest.Document); Assert.Equal(signer, manifest.Signers); }
public void InitializesWithDocumentDirectManifestAndCertificate() { //Arrange var document = DomainUtility.GetDirectDocument(); var sender = CoreDomainUtility.GetSender(); var manifest = new Manifest(sender, document, DomainUtility.GetSigner()); var x509Certificate2 = CoreDomainUtility.GetTestCertificate(); //Act var signatur = new SignatureGenerator(x509Certificate2, document, manifest); //Assert Assert.Equal(document, signatur.Attachables.ElementAt(0)); Assert.Equal(manifest, signatur.Attachables.ElementAt(1)); Assert.Equal(x509Certificate2, signatur.Certificate); }
public void Simple_constructor() { //Arrange var id = "IdDirectJob"; var signers = DomainUtility.GetSigner(); var document = DomainUtility.GetDirectDocument(); var exitUrls = DomainUtility.GetExitUrls(); var sender = CoreDomainUtility.GetSender(); //Act var directJob = new Job(document, signers, id, exitUrls, sender); //Assert Assert.Equal(id, directJob.Reference); Assert.Equal(signers, directJob.Signers); Assert.Equal(document, directJob.Document); Assert.Equal(exitUrls, directJob.ExitUrls); Assert.Equal(sender, directJob.Sender); }
public void InitializesClassAndParentProperties() { //Arrange var businessCertificate = CoreDomainUtility.GetTestCertificate(); var clientConfiguration = CoreDomainUtility.GetClientConfiguration(); var directJob = new Job(DomainUtility.GetDirectDocument(), DomainUtility.GetSigner(), "reference", DomainUtility.GetExitUrls(), CoreDomainUtility.GetSender()); var serializedJob = SerializeUtility.Serialize(DataTransferObjectConverter.ToDataTransferObject(directJob)); var asiceBundle = DirectAsiceGenerator.CreateAsice(directJob, businessCertificate, clientConfiguration); //Act var action = new CreateAction(directJob, asiceBundle); //Assert Assert.Equal(directJob, action.RequestContent); Assert.Equal(serializedJob, action.RequestContentXml.InnerXml); Assert.Null(action.MultipartFormDataContent); }
public void ConstructorGeneratesBytes() { //Arrange var document = DomainUtility.GetDirectDocument(); var asiceArchive = new AsiceArchive(new AsiceAttachableProcessor[] { }, DomainUtility.GetDirectManifest(), DomainUtility.GetSignature(), document); //Act var archiveBytes = asiceArchive.GetBytes(); //Assert using (var memoryStream = new MemoryStream(archiveBytes)) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Read)) { Assert.Contains(archive.Entries, entry => entry.FullName == "manifest.xml"); Assert.Contains(archive.Entries, entry => entry.FullName == "META-INF/signatures.xml"); Assert.Contains(archive.Entries, entry => entry.FullName == document.FileName); } } }
public void Converts_direct_job_successfully_with_polling_queue_successfully() { var document = DomainUtility.GetDirectDocument(); var signer = DomainUtility.GetSigner(); var reference = "reference"; var exitUrls = DomainUtility.GetExitUrls(); var statusretrieval = statusretrievalmethod.WAIT_FOR_CALLBACK; var pollingQueue = new PollingQueue("CustomPollingQueue"); var sender = new Sender(BringPublicOrganizationNumber, pollingQueue); var source = new Job( document, signer, reference, exitUrls, sender); var expected = new directsignaturejobrequest { reference = reference, exiturls = new exiturls { completionurl = source.ExitUrls.CompletionUrl.AbsoluteUri, rejectionurl = source.ExitUrls.RejectionUrl.AbsoluteUri, errorurl = source.ExitUrls.ErrorUrl.AbsoluteUri }, statusretrievalmethod = statusretrieval, statusretrievalmethodSpecified = true, pollingqueue = pollingQueue.Name }; //Act var result = DataTransferObjectConverter.ToDataTransferObject(source); //Assert var comparator = new Comparator(); IEnumerable <IDifference> differences; comparator.AreEqual(expected, result, out differences); Assert.Empty(differences); }
public void AddsAttachableToZip() { //Arrange var asiceArchive = new AsiceArchive(new AsiceAttachableProcessor[] { }); //Act var attachment = DomainUtility.GetDirectDocument(); asiceArchive.AddAttachable(attachment.FileName, attachment.Bytes); var archiveBytes = asiceArchive.GetBytes(); //Assert using (var memoryStream = new MemoryStream(archiveBytes)) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Read)) { Assert.Contains(archive.Entries, entry => entry.FullName == attachment.FileName); } } }
public void SendsBytesThroughDocumentBundleProcessor() { //Arrange var clientConfiguration = new ClientConfiguration(Environment.DifiQa, CoreDomainUtility.GetPostenTestCertificate()) { DocumentBundleProcessors = new List <IDocumentBundleProcessor> { new SimpleDocumentBundleProcessor(), new SimpleDocumentBundleProcessor() } }; var job = DomainUtility.GetDirectJobWithSender(); var asiceAttachableProcessors = clientConfiguration.DocumentBundleProcessors.Select(p => new AsiceAttachableProcessor(job, p)); var asiceAttachables = new IAsiceAttachable[] { DomainUtility.GetDirectManifest(), DomainUtility.GetSignature(), DomainUtility.GetDirectDocument() }; //Act var asiceArchive = new AsiceArchive(asiceAttachableProcessors, asiceAttachables); asiceArchive.GetBytes(); //Assert foreach (var simpleProcessor in clientConfiguration.DocumentBundleProcessors.Cast <SimpleDocumentBundleProcessor>()) { Assert.True(simpleProcessor.StreamLength > 1000); Assert.True(simpleProcessor.CouldReadBytesStream); Assert.Equal(0, simpleProcessor.Initialposition); } }