public async Task Returns_transport_error_receipt() { //Arrange var sikkerDigitalPostKlient = DomainUtility.GetSikkerDigitalPostKlientQaOffentlig(); var fakeHttpClientHandlerResponse = new FakeResponseHandler() { HttpContent = new StringContent(XmlResource.Response.GetTransportError().OuterXml), StatusCode = HttpStatusCode.BadRequest }; sikkerDigitalPostKlient.RequestHelper.HttpClient = new HttpClient(fakeHttpClientHandlerResponse); //Act var forsendelse = DomainUtility.GetForsendelseSimple(); var transportkvittering = await sikkerDigitalPostKlient.SendAsync(forsendelse).ConfigureAwait(false); //Assert Assert.IsType<TransportFeiletKvittering>(transportkvittering); }
public async Task Returns_receipt_successfully() { //Arrange var forretningsmeldingEnvelope = DomainUtility.GetForretningsmeldingEnvelope(); var documentBundle = AsiceGenerator.Create(DomainUtility.GetForsendelseSimple(), new GuidUtility(), DomainUtility.GetAvsenderCertificate(), DomainUtility.GetKlientkonfigurasjon()); var requestHelper = new RequestHelper(new Klientkonfigurasjon(Miljø.FunksjoneltTestmiljø)); var fakeHttpClientHandlerResponse = new FakeResponseHandler() { HttpContent = new StringContent(XmlResource.Response.GetTransportOk().OuterXml), StatusCode = HttpStatusCode.OK }; requestHelper.HttpClient = new HttpClient(fakeHttpClientHandlerResponse); //Act var kvittering = await requestHelper.SendMessage(forretningsmeldingEnvelope, documentBundle).ConfigureAwait(false); Assert.IsType<TransportOkKvittering>(kvittering); }
public async Task Calls_all_dokumentpakke_prosessors() { //Arrange var klientkonfigurasjon = new Klientkonfigurasjon(Miljø.FunksjoneltTestmiljø) { Dokumentpakkeprosessorer = new List<IDokumentpakkeProsessor> { new SimpleDocumentBundleProcessor(), new SimpleDocumentBundleProcessor() } }; var sikkerDigitalPostKlient = new SikkerDigitalPostKlient(DomainUtility.GetDatabehandler(), klientkonfigurasjon); DomainUtility.GetSikkerDigitalPostKlientQaOffentlig(); var fakeHttpClientHandlerResponse = new FakeResponseHandler() { HttpContent = new StringContent(XmlResource.Response.GetTransportOk().OuterXml), }; sikkerDigitalPostKlient.RequestHelper.HttpClient = new HttpClient(fakeHttpClientHandlerResponse); //Act var forsendelse = DomainUtility.GetForsendelseSimple(); try { await sikkerDigitalPostKlient.SendAsync(forsendelse).ConfigureAwait(false); } catch (SdpSecurityException) { /* We do not care about the results. Just do sending. Nasty hack as we are unable to mock validation in SikkerDigitalPostKlient, which results in invalid timestamp since response is out of date. */ } //Assert foreach (var dokumentpakkeProsessor in klientkonfigurasjon.Dokumentpakkeprosessorer.Cast<SimpleDocumentBundleProcessor>()) { Assert.True(dokumentpakkeProsessor.CouldReadBytesStream); } }
public async Task Throws_exception_on_response_not_matching_request() { //Arrange var sikkerDigitalPostKlient = DomainUtility.GetSikkerDigitalPostKlientQaOffentlig(); var fakeHttpClientHandlerResponse = new FakeResponseHandler() { HttpContent = new StringContent(XmlResource.Response.GetTransportOk().OuterXml), }; sikkerDigitalPostKlient.RequestHelper.HttpClient = new HttpClient(fakeHttpClientHandlerResponse); //Act var forsendelse = DomainUtility.GetForsendelseSimple(); await Assert.ThrowsAsync<SdpSecurityException>(async () => await sikkerDigitalPostKlient.SendAsync(forsendelse)).ConfigureAwait(false); }