/// <summary> /// Settings for DigitalPostForsendelse /// </summary> public EnvelopeSettings(Forsendelse forsendelse, DocumentBundle documentBundle, Databehandler databehandler, GuidUtility guidUtility, Klientkonfigurasjon konfigurasjon) { Forsendelse = forsendelse; DocumentBundle = documentBundle; Databehandler = databehandler; GuidUtility = guidUtility; Konfigurasjon = konfigurasjon; }
public void ReturnsCmsContentType() { //Arrange //Act var documentBundle = new DocumentBundle(null, 0, string.Empty); //Assert Assert.Equal(documentBundle.ContentType, "application/cms"); }
public void ReturnsBinaryEncoding() { //Arrange //Act var documentBundle = new DocumentBundle(null, 0, string.Empty); //Assert Assert.Equal(documentBundle.TransferEncoding, "binary"); }
public void Simple_constructor() { //Arrange var bundleBytes = new byte[] { 0x21, 0x22 }; //Act var documentBundle = new DocumentBundle(bundleBytes); //Assert Assert.Equal(bundleBytes, documentBundle.BundleBytes); }
private static void AddDocumentBundleToMultipart(DocumentBundle documentBundle, MultipartFormDataContent meldingsinnhold) { if (documentBundle != null) { var meldingsdata = new ByteArrayContent(documentBundle.BundleBytes); meldingsdata.Headers.ContentType = new MediaTypeHeaderValue(documentBundle.ContentType); meldingsdata.Headers.Add("Content-Transfer-Encoding", documentBundle.TransferEncoding); meldingsdata.Headers.Add("Content-ID", $"<{documentBundle.ContentId}>"); meldingsinnhold.Add(meldingsdata); } }
public void SimpleConstructor() { //Arrange var bundleBytes = new byte[] { 0x21, 0x22 }; const int billableBytes = 2; const string id = "id"; //Act var documentBundle = new DocumentBundle(bundleBytes, billableBytes, id); //Assert Assert.Equal(bundleBytes, documentBundle.BundleBytes); Assert.Equal(billableBytes, documentBundle.BillableBytes); }
private static HttpContent CreateHttpContent(AbstractEnvelope envelope, DocumentBundle asiceDocumentBundle) { var boundary = Guid.NewGuid().ToString(); var multipartFormDataContent = new MultipartFormDataContent(boundary); var contentType = $"Multipart/Related; boundary=\"{boundary}\"; " + "type=\"application/soap+xml\"; " + $"start=\"<{envelope.ContentId}>\""; var mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType); multipartFormDataContent.Headers.ContentType = mediaTypeHeaderValue; AddEnvelopeToMultipart(envelope, multipartFormDataContent); AddDocumentBundleToMultipart(asiceDocumentBundle, multipartFormDataContent); return(multipartFormDataContent); }
public async Task Throws_exception_on_invalid_manifest_in_attachment() { //Arrange var client = GetClientWithRequestValidator(new FakeHttpClientForDataResponse()); var serializedfunc = new Func <IRequestContent, string>(p => ContentUtility.GetDirectSignatureJobRequestBody()); var manifestBytes = Encoding.UTF8.GetBytes(XmlResource.Request.GetPortalManifest().OuterXml); var asiceArchive = new AsiceArchive(new List <AsiceAttachableProcessor>()); asiceArchive.AddAttachable("manifest.xml", manifestBytes); var documentBundle = new DocumentBundle(asiceArchive.GetBytes()); var createAction = new CreateAction(new FakeJob(), documentBundle, serializedfunc); //Act await Assert.ThrowsAsync <InvalidXmlException>(async() => await client.SendAsync(GetHttpRequestMessage(createAction.Content())).ConfigureAwait(false)).ConfigureAwait(false); //Assert }
private async Task <string> Send(AbstractEnvelope envelope, DocumentBundle asiceDocumentBundle = null) { if (ClientConfiguration.LoggForespørselOgRespons && RequestResponseLog.IsDebugEnabled) { RequestResponseLog.Debug($"Utgående {envelope.GetType().Name}, conversationId '{envelope.EnvelopeSettings.Forsendelse?.KonversasjonsId}', messageId '{envelope.EnvelopeSettings.GuidUtility.MessageId}': {envelope.Xml().OuterXml}"); } var requestUri = RequestUri(envelope); var httpContent = CreateHttpContent(envelope, asiceDocumentBundle); var responseMessage = await HttpClient.PostAsync(requestUri, httpContent).ConfigureAwait(false); var responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); if (ClientConfiguration.LoggForespørselOgRespons && RequestResponseLog.IsDebugEnabled) { RequestResponseLog.Debug($" Innkommende {responseContent}"); } return(responseContent); }
public CreateAction(Job job, DocumentBundle documentBundle) : base(job, documentBundle, SerializeFunc) { }
public async Task <Kvittering> SendMessage(ForretningsmeldingEnvelope envelope, DocumentBundle asiceDocumentBundle) { var result = await Send(envelope, asiceDocumentBundle).ConfigureAwait(false); return(KvitteringFactory.GetKvittering(result)); }
internal CreateAction(IRequestContent job, DocumentBundle documentBundle, Func <IRequestContent, string> serializeFunc) : base(job, serializeFunc) { _documentBundle = documentBundle; }