From be5f58f89f2b50a56b06e4193be6886f2389f83e Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 00:34:37 +0200 Subject: [PATCH 01/30] init commit for inntektsforesporsel --- .../main/kotlin/no/nav/emottak/cpa/Routes.kt | 13 +- .../resources/cpa/nav_qass_30823_modified.xml | 2900 +++++++++++++++++ .../main/kotlin/no/nav/emottak/ebms/App.kt | 50 +- .../emottak/utbetaling/UtbetalingClient.kt | 77 + .../nav/emottak/utbetaling/XmlMarshaller.kt | 46 + .../resources/inntektsforesporsel/SOAPrequest | 116 + .../no/nav/emottak/melding/model/Payload.kt | 2 +- settings.gradle.kts | 2 +- 8 files changed, 3188 insertions(+), 18 deletions(-) create mode 100644 cpa-repo/src/main/resources/cpa/nav_qass_30823_modified.xml create mode 100644 ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt create mode 100644 ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt create mode 100644 ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest diff --git a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt index 01689142..d867de34 100644 --- a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt +++ b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt @@ -173,11 +173,22 @@ fun Route.postCpa(cpaRepository: CPARepository) = post("/cpa") { } } +fun loadOverrideCPA(): CollaborationProtocolAgreement { + val cpaString = String(object {}::class.java.classLoader.getResource("cpa/nav_qass_30823_modified.xml").readBytes()) + return xmlMarshaller.unmarshal(cpaString, CollaborationProtocolAgreement::class.java) +} + fun Route.validateCpa(cpaRepository: CPARepository) = post("/cpa/validate/{$CONTENT_ID}") { val validateRequest = call.receive(ValidationRequest::class) try { log.info(validateRequest.marker(), "Validerer ebms mot CPA") - val cpa = cpaRepository.findCpa(validateRequest.cpaId) ?: throw NotFoundException("Fant ikke CPA (${validateRequest.cpaId})") + val cpa = + // TODO fjern override CPA for Inntektsforesporsel test: + if (validateRequest.cpaId == "nav:qass:30823") { + loadOverrideCPA() + } else { + cpaRepository.findCpa(validateRequest.cpaId) ?: throw NotFoundException("Fant ikke CPA (${validateRequest.cpaId})") + } cpa.validate(validateRequest) // Delivery Failure val partyInfo = cpa.getPartyInfoByTypeAndID(validateRequest.addressing.from.partyId) // Delivery Failure val encryptionCertificate = partyInfo.getCertificateForEncryption() // Security Failure diff --git a/cpa-repo/src/main/resources/cpa/nav_qass_30823_modified.xml b/cpa-repo/src/main/resources/cpa/nav_qass_30823_modified.xml new file mode 100644 index 00000000..3b448935 --- /dev/null +++ b/cpa-repo/src/main/resources/cpa/nav_qass_30823_modified.xml @@ -0,0 +1,2900 @@ + + + + 2024-08-09T14:32:47+02:00 + 2025-09-07T23:59:00+02:00 + + 8138375 + 922307814 + 922307814 + + + + + + + Legemelding + + + + Partner_channelSMTP0_partner + + NAV_SM_Sending2 + + + + + Partner_channelSMTP0_partner + + NAV_LE_Sending2 + + + + + Partner_channelSMTP0_partner + + NAV_OM_Sending2 + + + + + Partner_channelSMTP0_partner + + NAV_SO_Sending2 + + + + + Partner_channelSMTP0_partner + + NAV_Legemelding_Svarmelding2 + + + + + + + + + Sykmelding + + + + Partner_channelSMTP0_partner + + NAV_Sykmelding3 + + + + + Partner_channelSMTP0_partner + + NAV_Sykmelde_Svar3 + + + + + + + + + HenvendelseFraLege + + + + Partner_channelSMTP0_partner + + NAV_Henvendelse + + + + + Partner_channelSMTP0_partner + + NAV_HenvendelseFraLege_Bekreftelse + + + + + Partner_channelSMTP0_partner + + NAV_HenvendelseFraLege_Svar + + + + + + + + + BehandlerKrav + + + + Partner_channelSMTP0_partner + + NAV_BehandlerKravOppgjorsMelding2 + + + + + Partner_channelSMTP0_partner + + NAV_BehandlerKrav_Svarmelding2 + + + + + + + + + HarBorgerFrikort + + + + Partner_channelHTTP1_partner + + NAV_EgenandelForesporsel + + + + + Partner_channelHTTP1_partner + + NAV_EgenandelSvar + + + + + Partner_channelHTTP1_partner + + NAV_EgenandelAvvisning + + + + + + + + + HarBorgerFrikortMengde + + + + Partner_channelSMTP0_partner + + NAV_EgenandelForesporselM + + + + + Partner_channelSMTP0_partner + + NAV_EgenandelSvarM + + + + + Partner_channelSMTP0_partner + + NAV_EgenandelAvvisningM + + + + + + + + + PasientlisteForesporsel + + + + Partner_channelSMTP0_partner + + NAV_FastlegensPasientliste + + + + + Partner_channelSMTP0_partner + + NAV_PL_AbonnementInnmelding + + + + + Partner_channelSMTP0_partner + + NAV_PL_AbonnementUtmelding + + + + + Partner_channelSMTP0_partner + + NAV_PL_StatusAbonnement + + + + + Partner_channelSMTP0_partner + + NAV_PL_Svarmelding + + + + + + + + Partner_channelSMTP0_partner + + NAV_PLAS_Svarmelding + + + + + + + + Partner_channelSMTP0_partner + + NAV_PLKV_Svarmelding + + + + + + + + Partner_channelSMTP0_partner + + NAV_PL_NegativSvarmelding + + + + + + + + Partner_channelSMTP0_partner + + NAV_PasientListe + + + + + + + + + Inntektsforesporsel + + + + Partner_channelHTTP1_partner + + NAV_Inntektsforesporsel + + + + + Partner_channelHTTP1_partner + + NAV_InntektOpplysning + + + + + Partner_channelHTTP1_partner + + NAV_AvvisningInntektsforesporsel + + + + + + + + + Trekkopplysning + + + + Partner_channelSMTP0_partner + + NAV_Trekkgrunnlag + + + + + Partner_channelSMTP0_partner + + NAV_KvitteringTrekkvedtak + + + + + Partner_channelSMTP0_partner + + NAV_AvvisningTrekkvedtak + + + + + + + + + ForesporselFraSaksbehandler + + + + Partner_channelSMTP0_partner + + NAV_Svar2 + + + + + Partner_channelSMTP0_partner + + NAV_A10A + + + + + Partner_channelSMTP0_partner + + NAV_A10 + + + + + Partner_channelSMTP0_partner + + NAV_Foresporsel2 + + + + + Partner_channelSMTP0_partner + + NAV_ForesporselFraSaksbehandler_Bekreftelse + + + + + + Partner_channelSMTP0_partner + + NAV_ForesporselFraSaksbehandler_Svar + + + + + + + + + HenvendelseFraSaksbehandler + + + + Partner_channelSMTP0_partner + + NAV_HenvendelseFraSaksbehandler_Kvittering + + + + + + Partner_channelSMTP0_partner + + NAV_HenvendelseFraSaksbehandler_Svar + + + + + Partner_channelSMTP0_partner + + NAV_Henvendelse2 + + + + + + + + + Oppfolgingsplan + + + + Partner_channelSMTP0_partner + + NAV_Oppfolgingsplan_Kvittering + + + + + Partner_channelSMTP0_partner + + NAV_Oppfolgingsplan_Svar + + + + + Partner_channelSMTP0_partner + + NAV_Plan + + + + + + + + + DialogmoteInnkalling + + + + Partner_channelSMTP0_partner + + NAV_MoteRespons + + + + + Partner_channelSMTP0_partner + + NAV_DialogmoteInnkalling_Bekreftelse + + + + + Partner_channelSMTP0_partner + + NAV_MoteInnkalling + + + + + Partner_channelSMTP0_partner + + NAV_DialogmoteInnkalling_Kvittering + + + + + + + + MIIGRDCCBCygAwIBAgILAZu7vVkWSEvush0wDQYJKoZIhvcNAQELBQAwbjELMAkGA1UEBhMCTk8xGDAWBgNVBGEMD05UUk5PLTk4MzE2MzMyNzETMBEGA1UECgwKQnV5cGFzcyBBUzEwMC4GA1UEAwwnQnV5cGFzcyBDbGFzcyAzIFRlc3Q0IENBIEcyIFNUIEJ1c2luZXNzMB4XDTIzMDkxOTA4MTUxMVoXDTI2MDkxOTIxNTkwMFowaDELMAkGA1UEBhMCTk8xHDAaBgNVBAoME0hFTFNFUExBVFRGT1JNRU4gQVMxITAfBgNVBAMMGEhFTFNFUExBVFRGT1JNRU4gQVMgVEVTVDEYMBYGA1UEYQwPTlRSTk8tOTIyMzA3ODE0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAuBi+0uxTE7TPcH5mucJz03FSMM5xm47kRujJ0xyYS2mKCRoydPX5qWCP7aExj/kL6p6MFwdZbZr4eXQ41JfEMbw/g6if/RyQVwWE3QCmgknyvLcvtufsdD/aOffn8wdCXLUuY3Q8pOkV8kQ6y1S00J/vo9h2Jk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K51uMCp3qRpBT8wt7NQURBgoWG+UV8S3fMXCn36n2pX9PudQnkymVtaqlTRqqe+UKG/vmnH+IbizVLS7mbPg/twGIUQyGquGog/FuyShSB9x7D8h6JBkN6RcAMrdZylO0I5v2Gftn6gNul/LQ7T9n3m4Z1/FMlygrWCunFVjFdV9qcNOqIUkL0RZaE3Jwzl95osGuJpA/xpjUywO9BrjgzdTRyg65KBtM6qVQASfOYaEc2x4oESW1TLgLWEFUBdgwnz6zEo8/14b28ZQ+uSuuatAKOhL5UxHHOv8igV97wu6uC4dbOxhu7o6hXuchK8EfNY58ou2GAId33GkMxvEM6Sioj9VI6NPR/TERkRZzTVy0080bh0nT2Mr+SuYuph4dCiFeJ7ZiuqzN7CKrLjic3t6TVg102cGAZaYIHxe24J2861/nSAEexXjp4eFXamFiCiUWEilVlAyqhaBmZa6 + + + + + + + + + + + + + + SMTP + + + SMTP + + + + + + HTTP + + SSL + + + + HTTP + + + + + + + 4 + PT720M + NotGuaranteed + + P4D + + http://www.w3.org/2000/09/xmldsig# + + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + 4 + PT720M + NotGuaranteed + + P4D + + http://www.w3.org/2000/09/xmldsig# + + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + + http://www.w3.org/2000/09/xmldsig# + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + + http://www.w3.org/2000/09/xmldsig# + + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + 79768 + 111949 + 889640782 + 889640782 + + + + + + + Legemelding + + + + NAV_asyncSMTPChannelA1 + + Partner_Legemelding_Svarmelding24 + + + + + NAV_asyncSMTPChannelA1 + + Partner_SM_Sending20 + + + + + NAV_asyncSMTPChannelA1 + + Partner_LE_Sending21 + + + + + NAV_asyncSMTPChannelA1 + + Partner_OM_Sending22 + + + + + NAV_asyncSMTPChannelA1 + + Partner_SO_Sending23 + + + + + + + + + Sykmelding + + + + NAV_asyncSMTPChannelA1 + + Partner_Sykmelde_Svar31 + + + + + NAV_asyncSMTPChannelA1 + + Partner_Sykmelding30 + + + + + + + + + HenvendelseFraLege + + + + NAV_asyncSMTPChannelA1 + + Partner_HenvendelseFraLege_Bekreftelse1 + + + + + NAV_asyncSMTPChannelA1 + + Partner_HenvendelseFraLege_Svar2 + + + + + NAV_asyncSMTPChannelA1 + + Partner_Henvendelse0 + + + + + + + + + BehandlerKrav + + + + NAV_asyncSMTPChannelA1 + + Partner_BehandlerKrav_Svarmelding21 + + + + + NAV_asyncSMTPChannelA1 + + Partner_BehandlerKravOppgjorsMelding20 + + + + + + + + + HarBorgerFrikort + + + + NAV_SyncHttpChannelB1 + + Partner_EgenandelSvar1 + + + + + NAV_SyncHttpChannelB1 + + Partner_EgenandelAvvisning2 + + + + + NAV_SyncHttpChannelB1 + + Partner_EgenandelForesporsel0 + + + + + + + + + HarBorgerFrikortMengde + + + + NAV_asyncSMTPChannelA1 + + Partner_EgenandelSvarM1 + + + + + NAV_asyncSMTPChannelA1 + + Partner_EgenandelAvvisningM2 + + + + + NAV_asyncSMTPChannelA1 + + Partner_EgenandelForesporselM0 + + + + + + + + + PasientlisteForesporsel + + + + + + + NAV_asyncSMTPChannelA1 + + Partner_PLAS_Svarmelding5 + + + + + + + + NAV_asyncSMTPChannelA1 + + Partner_PLKV_Svarmelding6 + + + + + + + + NAV_asyncSMTPChannelA1 + + Partner_PL_NegativSvarmelding7 + + + + + + + + NAV_asyncSMTPChannelA1 + + Partner_PasientListe8 + + + + + NAV_asyncSMTPChannelA1 + + Partner_FastlegensPasientliste0 + + + + + NAV_asyncSMTPChannelA1 + + Partner_PL_AbonnementInnmelding1 + + + + + NAV_asyncSMTPChannelA1 + + Partner_PL_AbonnementUtmelding2 + + + + + NAV_asyncSMTPChannelA1 + + Partner_PL_StatusAbonnement3 + + + + + NAV_asyncSMTPChannelA1 + + Partner_PL_Svarmelding4 + + + + + + + + + Inntektsforesporsel + + + + NAV_SyncHttpChannelB1 + + Partner_InntektOpplysning1 + + + + + NAV_SyncHttpChannelB1 + + Partner_AvvisningInntektsforesporsel2 + + + + + NAV_SyncHttpChannelB1 + + Partner_Inntektsforesporsel0 + + + + + + + + + Trekkopplysning + + + + NAV_asyncSMTPChannelA1 + + Partner_KvitteringTrekkvedtak1 + + + + + NAV_asyncSMTPChannelA1 + + Partner_AvvisningTrekkvedtak2 + + + + + NAV_asyncSMTPChannelA1 + + Partner_Trekkgrunnlag0 + + + + + + + + + ForesporselFraSaksbehandler + + + + NAV_asyncSMTPChannelA1 + + Partner_Foresporsel23 + + + + + NAV_asyncSMTPChannelA1 + + Partner_ForesporselFraSaksbehandler_Bekreftelse4 + + + + + + NAV_asyncSMTPChannelA1 + + Partner_ForesporselFraSaksbehandler_Svar5 + + + + + NAV_asyncSMTPChannelA1 + + Partner_Svar20 + + + + + NAV_asyncSMTPChannelA1 + + Partner_A10A1 + + + + + NAV_asyncSMTPChannelA1 + + Partner_A102 + + + + + + + + + HenvendelseFraSaksbehandler + + + + NAV_asyncSMTPChannelA1 + + Partner_Henvendelse22 + + + + + NAV_asyncSMTPChannelA1 + + Partner_HenvendelseFraSaksbehandler_Kvittering0 + + + + + + NAV_asyncSMTPChannelA1 + + Partner_HenvendelseFraSaksbehandler_Svar1 + + + + + + + + + Oppfolgingsplan + + + + NAV_asyncSMTPChannelA1 + + Partner_Plan2 + + + + + NAV_asyncSMTPChannelA1 + + Partner_Oppfolgingsplan_Kvittering0 + + + + + NAV_asyncSMTPChannelA1 + + Partner_Oppfolgingsplan_Svar1 + + + + + + + + + DialogmoteInnkalling + + + + NAV_asyncSMTPChannelA1 + + Partner_MoteInnkalling2 + + + + + NAV_asyncSMTPChannelA1 + + Partner_DialogmoteInnkalling_Kvittering3 + + + + + NAV_asyncSMTPChannelA1 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VQVrzfIX5u7Mk26hptX8KUYJb/LEDR6bbFCxaapaZl4Zr5E80aUIAxZD3aVWMW4kaBdOqAzOFDEMx8zJPosfjfUK2V4hUrdcWnCwT6RHszPZ2r0tzp0lp76sTE88ft8+vyefGddiyWTEn + + + + + + + + + + + + + + SMTP + + + SMTP + + + + + + HTTP + + SSL + + + + HTTP + + + SSL + + + + + + + + 4 + PT720M + NotGuaranteed + + P4D + + http://www.w3.org/2000/09/xmldsig# + + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + 4 + PT720M + NotGuaranteed + + P4D + + http://www.w3.org/2000/09/xmldsig# + + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + + + http://www.w3.org/2000/09/xmldsig# + + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + http://www.w3.org/2000/09/xmldsig# + http://www.w3.org/2001/04/xmlenc#sha256 + + http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 + + + + + + + + http://www.oasis-open.org/committees/ebxml-msg/schema + + + + + http://www.kith.no/xmlstds/apprec/2004-11-21 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/dialog/2006-10-11 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/eresept/m2/2010-06-18 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/sykmelding/2011-03-04 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/HelseOpplysningerArbeidsuforhet/2013-10-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/legeerklaring/2008-06-06 + + + + + http://www.kith.no/xmlstds/lom/2003-12-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/bkm/2006-12-20 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandel/2010-02-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandel/2010-02-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandelmengde/2010-10-06 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandelmengde/2010-10-06 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/pasientliste/2010-02-01 + + + + + http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1 + + + + + http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1 + + + + + http://www.kith.no/xmlstds/InnrapporteringTrekk/InnrapporteringTrekk/2010-02-04 + + + + + http://www.kith.no/xmlstds/InnrapporteringTrekk/InnrapporteringTrekk/2010-02-04 + + + + + http://www.oasis-open.org/committees/ebxml-msg/schema + + + + + http://www.kith.no/xmlstds/apprec/2004-11-21 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/dialog/2006-10-11 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/eresept/m2/2010-06-18 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/sykmelding/2011-03-04 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/HelseOpplysningerArbeidsuforhet/2013-10-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/legeerklaring/2008-06-06 + + + + + http://www.kith.no/xmlstds/lom/2003-12-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/bkm/2006-12-20 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandel/2010-02-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandel/2010-02-01 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandelmengde/2010-10-06 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/egenandelmengde/2010-10-06 + + + + + http://www.kith.no/xmlstds/msghead/2006-05-24 + + + http://www.kith.no/xmlstds/nav/pasientliste/2010-02-01 + + + + + http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1 + + + + + http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1 + + + + + http://www.kith.no/xmlstds/InnrapporteringTrekk/InnrapporteringTrekk/2010-02-04 + + + + + http://www.kith.no/xmlstds/InnrapporteringTrekk/InnrapporteringTrekk/2010-02-04 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index f33a0b1f..f87aa321 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -14,7 +14,6 @@ import io.ktor.server.netty.Netty import io.ktor.server.plugins.contentnegotiation.ContentNegotiation import io.ktor.server.request.receive import io.ktor.server.response.respond -import io.ktor.server.routing.get import io.ktor.server.routing.post import io.ktor.server.routing.routing import io.micrometer.core.instrument.Timer.ResourceSample @@ -29,11 +28,12 @@ import no.nav.emottak.frikort.frikortsporring import no.nav.emottak.frikort.marshal import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.melding.model.SendInResponse +import no.nav.emottak.utbetaling.InntektsForesporselClient import no.nav.emottak.util.getEnvVar import no.nav.emottak.util.marker import no.nav.security.token.support.v2.tokenValidationSupport +import no.nav.tjeneste.ekstern.frikort.v1.types.FrikortsporringResponse import org.slf4j.LoggerFactory -import java.util.Timer internal val log = LoggerFactory.getLogger("no.nav.emottak.ebms.App") @@ -71,14 +71,22 @@ fun Application.ebmsSendInModule() { } routing { + val inntektsForesporselClient = InntektsForesporselClient() authenticate(AZURE_AD_AUTH) { post("/fagmelding/synkron") { val request = this.call.receive(SendInRequest::class) runCatching { log.info(request.marker(), "Payload ${request.payloadId} videresendes til fagsystem") withContext(Dispatchers.IO) { - timed(appMicrometerRegistry, "frikort-sporing") { - frikortsporring(wrapMessageInEIFellesFormat(request)) + when (request.addressing.service) { + "Inntektsforesporsel" -> + timed(appMicrometerRegistry, "Inntektsforesporsel") { + inntektsForesporselClient.sendInntektsforesporsel(request.payload) // TODO skal fellesformat brukes? + } + else -> + timed(appMicrometerRegistry, "frikort-sporing") { + frikortsporring(wrapMessageInEIFellesFormat(request)) + } } } }.onSuccess { @@ -86,17 +94,29 @@ fun Application.ebmsSendInModule() { request.marker(), "Payload ${request.payloadId} videresending til fagsystem ferdig, svar mottatt og returnerert" ) - call.respond( - SendInResponse( - request.messageId, - request.conversationId, - request.addressing.replayTo( - it.eiFellesformat.mottakenhetBlokk.ebService, - it.eiFellesformat.mottakenhetBlokk.ebAction - ), - marshal(it.eiFellesformat.msgHead).toByteArray() - ) - ) + when (it) { // TODO gjerne tenk igjennom en bedre flyt + is ByteArray -> + call.respond( + SendInResponse( + request.messageId, + request.conversationId, + request.addressing.replyTo(request.addressing.service, request.addressing.action), // TODO ser feil ut? + it + ) + ) + is FrikortsporringResponse -> + call.respond( + SendInResponse( + request.messageId, + request.conversationId, + request.addressing.replyTo( + it.eiFellesformat.mottakenhetBlokk.ebService, + it.eiFellesformat.mottakenhetBlokk.ebAction + ), + marshal(it.eiFellesformat.msgHead).toByteArray() + ) + ) + } }.onFailure { log.error(request.marker(), "Payload ${request.payloadId} videresending feilet", it) call.respond(HttpStatusCode.BadRequest, it.localizedMessage) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt new file mode 100644 index 00000000..9065cd7d --- /dev/null +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -0,0 +1,77 @@ +package no.nav.emottak.utbetaling + +import io.ktor.client.HttpClient +import io.ktor.client.engine.cio.CIO +import io.ktor.client.request.post +import io.ktor.client.request.setBody +import io.ktor.client.statement.bodyAsText +import io.ktor.client.statement.readBytes +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserRequest +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserResponse +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeRequest +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeResponse +import no.nav.emottak.cxf.ServiceBuilder +import no.nav.emottak.util.getEnvVar +import org.slf4j.LoggerFactory +import javax.xml.namespace.QName + +class InntektsForesporselClient { + + val log = LoggerFactory.getLogger(InntektsForesporselClient::class.java) + + val YRP_URL_TEST = "https://ytelser-rest-proxy.intern.dev.nav.no" + val YRP_URL_PROD = "https://ytelser-rest-proxy.intern.nav.no" + val RESOLVED_UTBETAL_URL = + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> YRP_URL_TEST + "dev-fss" -> YRP_URL_TEST + "prod-fss" -> YRP_URL_PROD + else -> YRP_URL_TEST + } + val UTBETAL_SOAP_ENDPOINT = RESOLVED_UTBETAL_URL + "/Utbetaling" + + val httpClient = HttpClient(CIO) + + fun sendInntektsforesporsel(payloadBytes: ByteArray): suspend () -> ByteArray { + log.info("Sender inntektsforespørsel til $UTBETAL_SOAP_ENDPOINT:\n" + String(payloadBytes)) + return { + httpClient.post(UTBETAL_SOAP_ENDPOINT) { + setBody(payloadBytes) + }.readBytes().also { + log.info("(DEBUG) Inntektsforesporsel response: " + String(it)) // TODO delete debug logging + } + } + } + + suspend fun finnUtbetalingListe(p0: FinnUtbetalingListeRequest): FinnUtbetalingListeResponse { + val response = withContext(Dispatchers.IO) { + httpClient.post(UTBETAL_SOAP_ENDPOINT) { + setBody(xmlMarshaller.marshal(p0)) + }.bodyAsText() + } + return xmlMarshaller.unmarshal(response, FinnUtbetalingListeResponse::class.java) + } + + suspend fun finnBrukersUtbetalteYtelser(p0: FinnBrukersUtbetalteYtelserRequest): FinnBrukersUtbetalteYtelserResponse { + val response = withContext(Dispatchers.IO) { + httpClient.post(UTBETAL_SOAP_ENDPOINT) { + setBody(xmlMarshaller.marshal(p0)) + }.bodyAsText() + } + return xmlMarshaller.unmarshal(response, FinnBrukersUtbetalteYtelserResponse::class.java) + } +} + +val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.Utbetaling = + ServiceBuilder( + no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.Utbetaling::class.java + ) + .withAddress(getEnvVar("UTBETALING_URL", "https://ytelser-rest-proxy.intern.nav.no/Utbetaling")) + .withWsdl("classpath:no/nav/ekstern/virkemiddelokonomi/utbetaling/utbetaling.wsdl") + .withServiceName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "Utbetaling")) + .withEndpointName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "UtbetalingPort")) + .build() + // .withBasicSecurity() + .get() diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt new file mode 100644 index 00000000..53630ece --- /dev/null +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt @@ -0,0 +1,46 @@ +package no.nav.emottak.utbetaling + +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserRequest +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeRequest +import java.io.StringWriter +import javax.xml.bind.JAXBContext +import javax.xml.stream.XMLInputFactory + +val xmlMarshaller = XmlMarshaller() + +fun marshal(objekt: Any) = xmlMarshaller.marshal(objekt) +fun unmarshal(xml: String, clazz: Class): T = xmlMarshaller.unmarshal(xml, clazz) + +class XmlMarshaller { + + companion object { + private val jaxbContext = JAXBContext.newInstance( + FinnUtbetalingListeRequest::class.java, + FinnBrukersUtbetalteYtelserRequest::class.java, + no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.ObjectFactory::class.java, + org.xmlsoap.schemas.soap.envelope.ObjectFactory::class.java, + no.kith.xmlstds.msghead._2006_05_24.ObjectFactory::class.java, + org.w3._1999.xlink.ObjectFactory::class.java, + org.w3._2009.xmldsig11_.ObjectFactory::class.java + ) + private val marshaller = jaxbContext.createMarshaller() + private val unmarshaller = jaxbContext.createUnmarshaller() + private val marshlingMonitor = Any() + private val unmarshlingMonitor = Any() + } + + fun marshal(objekt: Any): String { + val writer = StringWriter() + synchronized(marshlingMonitor) { + marshaller.marshal(objekt, writer) + } + return writer.toString() + } + + fun unmarshal(xml: String, clazz: Class): T { + val reader = XMLInputFactory.newInstance().createXMLStreamReader(xml.reader()) + return synchronized(unmarshlingMonitor) { + unmarshaller.unmarshal(reader, clazz).value + } + } +} diff --git a/ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest b/ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest new file mode 100644 index 00000000..581bd258 --- /dev/null +++ b/ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest @@ -0,0 +1,116 @@ +SOAPAction:"ebXML"\r\nX-Request-ID:275622fe2d19beb72b1fcef649454f9c\r\nX-Original-Forwarded-For:10.49.1.253\r\nX-Forwarded-Host:ebms-sync-router.dev.intern.nav.no:443\r\nX-Forwarded-Proto:https\r\nHost:ebms-sync-router.dev.intern.nav.no:443\r\norigHost:nhn-gw-q.nav.no:9443\r\nContent-Transfer-Encoding:8bit\r\nX-Global-Transaction-ID:da10915d667aac0901282273\r\nX-Forwarded-Port:443\r\nX-Client-IP:10.48.65.200\r\nVia:1.1 XMLFW-emottak-ebxml\r\nX-Forwarded-For:10.49.1.253\r\nContent-Length:12948\r\nX-Real-IP:10.49.1.253\r\nX-Forwarded-Scheme:https\r\nX-Scheme:https\r\nContent-Type:multipart/related; boundary="----=_Part_22_77333660.1264086702625"; type="text/xml"; start=""\r\n + +------=_Part_22_77333660.1264086702625 +Content-Type: text/xml; charset=UTF-8 +Content-Transfer-Encoding: binary +Content-ID: + + +8138375Fordringshaver111949Ytelsesutbetalernav:qass:308232b99d7a7-d70d-4dd2-8869-3448fd7df6bbInntektsforesporselForesporsel15552ce2-67e8-415f-a536-99c323cdea532024-06-25T13:37:45sI0z2uKiVArIF/hoCJK708KoJm0=K+a/pYe9VeySvC53uaCXs9omFtU=YFH5NzQDXZv0fp+NlptPHZxq6i4P2kqp+cDPs8mpB2280Rze5NmDrx7UO4uMYZiylEc0Ckp/bWfGotoT35oZeld0vyKqXdZW1aCoiHuM+krkVmY9JJxao6jZdT8LYCZBsVd6DkKKDOHQgjHd58GupcR0jeRShP7OVMlBR1XHh8oKIBIsvpHyrzuGwqYm4d5lBDtXReFCth06PNgTvOfoGuQzFzZpnqcA7a00dPcwleXjVllzlG6+M2BOsEGPKzwUkI2REigxsZMTg6Gtj2rzQyLtfpctru1wfr3VtYJGnGXBwzklAAzTUAkdpSVS2DAsWXLu95Xs1RRKedTo4YW++cox7dkhCIQc8NzoGDithSpaERtg9df8s4VUXbDHGzlJwmZS5xmbYfQdjtkJsHz91CKBRBO5UC6pGJqV7y8p2kVkrzAIvhCRrZyftnN+wbyGsR7aVNas2b4o7BmR+sb3GUd1m9gVHq4XzZIiYP3OCiESaUiENcGOiC4far+4Ic/WMIIGRDCCBCygAwIBAgILAZu7vVkWSEvush0wDQYJKoZIhvcNAQELBQAwbjELMAkGA1UEBhMCTk8xGDAWBgNVBGEMD05UUk5PLTk4MzE2MzMyNzETMBEGA1UECgwKQnV5cGFzcyBBUzEwMC4GA1UEAwwnQnV5cGFzcyBDbGFzcyAzIFRlc3Q0IENBIEcyIFNUIEJ1c2luZXNzMB4XDTIzMDkxOTA4MTUxMVoXDTI2MDkxOTIxNTkwMFowaDELMAkGA1UEBhMCTk8xHDAaBgNVBAoME0hFTFNFUExBVFRGT1JNRU4gQVMxITAfBgNVBAMMGEhFTFNFUExBVFRGT1JNRU4gQVMgVEVTVDEYMBYGA1UEYQwPTlRSTk8tOTIyMzA3ODE0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAuBi+0u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gmvhpWD2FbEz11uCLIY+CGjqrPH56UUG0ZqPykLMqlqKSGLvDV00XD1UF4/042/Gv5EAJq7viaAUY3GiLGca8hsTIGCN33tcLemnIWHkSBbKOdF9Kt8h99OfDb+CE9L85aait7tTqG96FCRDsYwQRET8qkLmKRRE3sYQ8A7flrDO6KtOi1uF2JsVzoO3OvfCdWd1S+onqnQ+69d4xRdz3zB6qKxnxjDfBGFHWMkYjznl5FsbYI/jxCiPp9zpov9cXoQUKTR+qCB0hzKwve2iuSgVWADagfQAn3iaqD2ZdSkMNhOjOO7nMitUZczbELaRgTrm5VhPPIvfEsKJU2ptHfJkAStyJt82dBywcEZ0ERvX2pA0Uyq3fAmyN7IrIfkMLSbYOc0NbbeMFC9QduwKDMsUESniStnKD+30ueb97NKt8ohBJXepZCW8w9VEbyZz72TCl5V+oKDbz272aHKYQMc8iVQooz7JWEDsKyw5eUSCOrER5bgIQP/cYMacb+mzIpshrx31QoDXa2emV6oTl7lYjAD3aZOFp4uk++P3/pGQ3jP3WhaQGsoMrnZxgnH3bx/tAsYali6x+Pkp8jFqV2UOR8nNMDSP8JWDlhJr+cAtmC+0bevGfjl +------=_Part_22_77333660.1264086702625 +Content-Type: text/xml +Content-ID: +Content-Transfer-Encoding: base64 + +MIIWXAYJKoZIhvcNAQcDoIIWTTCCFkkCAQAxggIZMIICFQIBADB9MG4xCzAJBgNVBAYTAk5PMRgw +FgYDVQRhDA9OVFJOTy05ODMxNjMzMjcxEzARBgNVBAoMCkJ1eXBhc3MgQVMxMDAuBgNVBAMMJ0J1 +eXBhc3MgQ2xhc3MgMyBUZXN0NCBDQSBHMiBTVCBCdXNpbmVzcwILAZUu998EpC5cTMkwDQYJKoZI +hvcNAQEBBQAEggGAJ1ZIrMf1v/lBmMdFRZO7K2F3q/dsp2bPSm/J0ujbIyueGlYw4nsFvCa9zXBy +ciO79vPLTBHTdkpgp8LVTd7H1eZiauthO40GaXkJs9y69s2fc1cYMhvY5DghjM70fLnPdFn7vpNd +zX1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+v+oiQ897jr2yFDiXsW7rCyVx4Q8nZpnrzwOJStb9AsQzE/mYhGVDPKeoIM09pi1iXXM7Oh5wg2yk +RDTke1cDFiweqnylDyPa0GsnuBKdtS0Ai/sk6Cal46skASTt10DaDtmVq/cjmfyNWImgZJEKFM6U +eQ9ebaGsE5qAYmIE5QrhTlzIYajl+cFkVcHhQDJ8v3ulVHf5V0emSP/Xkde95IrDNEJF7CdzwoeN +oNdxhWAbJPG0G8KXQPJBwiuEinNkjxR9Ok+4riNnd8/XCoWHMSTnu9XoAk46JSWPvf6e4JqMoma8 +7zT4f10nAbMO0TNtbPbmt3jqoFQmf9kS2RzHS0trRtWj0bzEaBviSVF4iHuu3Ju3M8dT6m0MDW+6 +gC1Yr4z6S56f4x+QeFMuD4sQYq9uIclruynFrnBFhmXG/KeYNYU9yhDmpXqa+4RoZsgNE9pUbk52 +zX04CbIp/hwxCa0REGnhFp6eC7p08RU4a8rvPLRDBcu6Ufqc8omtlYg6dxGEneTLYO/awd2N6wBb +z5otlBztpGrs19UqPnDrLIixmCQPxzL1GgFxQG5wyFeyBmiSIs9FoxiCHQYE4TewDzd5KQZ71Lne +m6ptzORWAstQILzU8p+hz+6+WpOahvYriKJzcVI5h9fpUEZhFmztpgeycURcUwur6BMQWcPOESvM +JqSY13Hva+uwe7HYNkqKyl3bOtXrFgsH4kGM9/Xt/GkZjJtoY/pTKm5Hb7CQytTvk/nc6OJJCxQf +gyyQQoz8twPotVZtxnLbWw19qYH7MrdUXgwwf2G47z6PTlTpT42kI5rwU0MPL5xm2LJ3XwA4nZ0K +0lEzJe0ZRD0O0QGEUM133Eu/cP67VYSr1qvNCw+AqOe0bCwq6QyJI6fP50BrBAYawVu+wVoXB+Ex +6uYIcvr0LZONUOh0ktHqs4SzG51eaTr1D6LVgQ== +------=_Part_22_77333660.1264086702625-- \ No newline at end of file diff --git a/felles/src/main/kotlin/no/nav/emottak/melding/model/Payload.kt b/felles/src/main/kotlin/no/nav/emottak/melding/model/Payload.kt index d04ead31..4c90a5b9 100644 --- a/felles/src/main/kotlin/no/nav/emottak/melding/model/Payload.kt +++ b/felles/src/main/kotlin/no/nav/emottak/melding/model/Payload.kt @@ -119,7 +119,7 @@ data class Addressing( val service: String, val action: String ) { - fun replayTo(service:String,action:String): Addressing = Addressing( to = from.copy(), from = to.copy(), service , action) + fun replyTo(service:String, action:String): Addressing = Addressing( to = from.copy(), from = to.copy(), service , action) } @Serializable diff --git a/settings.gradle.kts b/settings.gradle.kts index e2b90848..ffc71653 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -56,7 +56,7 @@ dependencyResolutionManagement { library("ktor-server-auth-jvm", "io.ktor:ktor-server-auth-jvm:2.3.8") library("token-validation-ktor-v2", "no.nav.security:token-validation-ktor-v2:4.1.4") library("flyway-core", "org.flywaydb:flyway-core:9.16.3") - library("emottak-payload-xsd", "no.nav.emottak:emottak-payload-xsd:0.0.2") + library("emottak-payload-xsd", "no.nav.emottak:emottak-payload-xsd:0.0.3") library("jaxb-runtime", "org.glassfish.jaxb:jaxb-runtime:2.4.0-b180830.0438") library("cxf-rt-frontend-jaxws", "org.apache.cxf", "cxf-rt-frontend-jaxws").versionRef("cxf") library("cxf-rt-transports-http", "org.apache.cxf", "cxf-rt-transports-http").versionRef("cxf") From 3ade753f4fff4ba57a263ee6219f43e96e0081fb Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 01:14:38 +0200 Subject: [PATCH 02/30] Oppdatert process config --- .../main/resources/db/migration/R__init_process_config.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpa-repo/src/main/resources/db/migration/R__init_process_config.sql b/cpa-repo/src/main/resources/db/migration/R__init_process_config.sql index d3074976..26228e00 100644 --- a/cpa-repo/src/main/resources/db/migration/R__init_process_config.sql +++ b/cpa-repo/src/main/resources/db/migration/R__init_process_config.sql @@ -12,7 +12,9 @@ values ('Behandler', 'HarBorgerFrikort', 'EgenandelForesporsel', ('Fastlege', 'PasientlisteForesporsel', 'HentAbonnementStatus', false, false, TRUE, TRUE, TRUE, TRUE, null, 'Avvisning'), ('Fastlege', 'PasientlisteForesporsel', 'HentPasientliste', false, false, TRUE, TRUE, TRUE, TRUE, null, 'Avvisning'), ('Fastlege', 'PasientlisteForesporsel', 'StartAbonnement', false, false, TRUE, TRUE, TRUE, TRUE, null, 'Avvisning'), - ('Fastlege', 'PasientlisteForesporsel', 'StoppAbonnement', false, false, TRUE, TRUE, TRUE, TRUE, null, 'Avvisning') + ('Fastlege', 'PasientlisteForesporsel', 'StoppAbonnement', false, false, TRUE, TRUE, TRUE, TRUE, null, 'Avvisning'), + ('Fordringshaver', 'Inntektsforesporsel', 'Foresporsel', true, false, TRUE, false, TRUE, TRUE, null, 'Avvisning') + on conflict (ROLE, SERVICE, ACTION) do update set KRYPTERING = EXCLUDED.KRYPTERING, KOMPRIMERING = EXCLUDED.KOMPRIMERING, SIGNERING = EXCLUDED.SIGNERING, From 92237aea57495db22ac79bf03adb6be692f7411c Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 09:17:14 +0200 Subject: [PATCH 03/30] UsernameToken --- .../emottak/utbetaling/UtbetalingClient.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 9065cd7d..666d95c0 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -16,6 +16,8 @@ import no.nav.emottak.cxf.ServiceBuilder import no.nav.emottak.util.getEnvVar import org.slf4j.LoggerFactory import javax.xml.namespace.QName +import javax.xml.soap.SOAPElement +import javax.xml.soap.SOAPFactory class InntektsForesporselClient { @@ -36,6 +38,7 @@ class InntektsForesporselClient { fun sendInntektsforesporsel(payloadBytes: ByteArray): suspend () -> ByteArray { log.info("Sender inntektsforespørsel til $UTBETAL_SOAP_ENDPOINT:\n" + String(payloadBytes)) + return { httpClient.post(UTBETAL_SOAP_ENDPOINT) { setBody(payloadBytes) @@ -62,6 +65,38 @@ class InntektsForesporselClient { } return xmlMarshaller.unmarshal(response, FinnBrukersUtbetalteYtelserResponse::class.java) } + fun createSecurityElement(username: String, password: String): SOAPElement { + val WSSE_URI = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" + val WSSE_PW_TYPE = + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" + try { + // https://www.ibm.com/docs/en/was/9.0.5?topic=authentication-username-token + val soapFactory = SOAPFactory.newInstance() + val usernameElement = soapFactory + .createElement("Username", "wsse", WSSE_URI).addTextNode(username) + val passwordElement = soapFactory + .createElement("Password", "wsse", WSSE_URI).addTextNode(password) + passwordElement + .addAttribute(QName("Type"), WSSE_PW_TYPE) + + val usernameTokenElement = soapFactory + .createElement("UsernameToken", "wsse", WSSE_URI) + + usernameTokenElement.addChildElement(usernameElement) + usernameTokenElement.addChildElement(passwordElement) + + val securityElement = soapFactory.createElement( + "Security", + "wsse", + WSSE_URI + ) + securityElement.addChildElement(usernameTokenElement) + return securityElement + } catch (e: javax.xml.soap.SOAPException) { + log.error("Feil i createSecurityElement", e) + throw RuntimeException("Feil i generering av usernametoken") + } + } } val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.Utbetaling = From 374216482d102511b02c14c34bdeef38064574a5 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 10:33:55 +0200 Subject: [PATCH 04/30] Bump XSD version --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index ffc71653..e28cc009 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -56,7 +56,7 @@ dependencyResolutionManagement { library("ktor-server-auth-jvm", "io.ktor:ktor-server-auth-jvm:2.3.8") library("token-validation-ktor-v2", "no.nav.security:token-validation-ktor-v2:4.1.4") library("flyway-core", "org.flywaydb:flyway-core:9.16.3") - library("emottak-payload-xsd", "no.nav.emottak:emottak-payload-xsd:0.0.3") + library("emottak-payload-xsd", "no.nav.emottak:emottak-payload-xsd:0.0.4") library("jaxb-runtime", "org.glassfish.jaxb:jaxb-runtime:2.4.0-b180830.0438") library("cxf-rt-frontend-jaxws", "org.apache.cxf", "cxf-rt-frontend-jaxws").versionRef("cxf") library("cxf-rt-transports-http", "org.apache.cxf", "cxf-rt-transports-http").versionRef("cxf") From 3bf3691da5f6ea92fc26395c06ce7f517f1d8e61 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 15:02:23 +0200 Subject: [PATCH 05/30] Send soaprequest til yrp --- .../main/kotlin/no/nav/emottak/ebms/App.kt | 2 +- .../emottak/utbetaling/UtbetalingClient.kt | 56 +++++++++++- .../nav/emottak/utbetaling/XmlMarshaller.kt | 2 + .../test/kotlin/InntektsforesporselTest.kt | 21 +++++ .../inntektsforesporsel.xml | 89 +++++++++++++++++++ 5 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt create mode 100644 ebms-send-in/src/test/resources/inntektsforesporsel/inntektsforesporsel.xml diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index f87aa321..014df56e 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -81,7 +81,7 @@ fun Application.ebmsSendInModule() { when (request.addressing.service) { "Inntektsforesporsel" -> timed(appMicrometerRegistry, "Inntektsforesporsel") { - inntektsForesporselClient.sendInntektsforesporsel(request.payload) // TODO skal fellesformat brukes? + inntektsForesporselClient.behandleInntektsforesporsel(request.payload) // TODO hva med fellesformat? } else -> timed(appMicrometerRegistry, "frikort-sporing") { diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 666d95c0..1e58d6fb 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -8,13 +8,17 @@ import io.ktor.client.statement.bodyAsText import io.ktor.client.statement.readBytes import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserRequest import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserResponse import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeRequest import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeResponse +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnBrukersUtbetalteYtelser +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe import no.nav.emottak.cxf.ServiceBuilder import no.nav.emottak.util.getEnvVar import org.slf4j.LoggerFactory +import java.io.FileInputStream import javax.xml.namespace.QName import javax.xml.soap.SOAPElement import javax.xml.soap.SOAPFactory @@ -36,9 +40,20 @@ class InntektsForesporselClient { val httpClient = HttpClient(CIO) + fun behandleInntektsforesporsel(payloadBytes: ByteArray): ByteArray { + val msgHead = xmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) + val melding = msgHead.document.map { it.refDoc.content.any }.also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } + .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() + val response: Any = when (melding) { + is FinnUtbetalingListe -> inntektsforesporselSoapEndpoint.finnUtbetalingListe(melding.request) + is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) + else -> throw IllegalStateException("Ukjent meldingstype. Classname: " + melding.javaClass.name) + } + return marshal(response).toByteArray() + } + fun sendInntektsforesporsel(payloadBytes: ByteArray): suspend () -> ByteArray { log.info("Sender inntektsforespørsel til $UTBETAL_SOAP_ENDPOINT:\n" + String(payloadBytes)) - return { httpClient.post(UTBETAL_SOAP_ENDPOINT) { setBody(payloadBytes) @@ -48,7 +63,36 @@ class InntektsForesporselClient { } } - suspend fun finnUtbetalingListe(p0: FinnUtbetalingListeRequest): FinnUtbetalingListeResponse { + suspend fun finnUtbetalingListe(payloadBytes: ByteArray): FinnUtbetalingListeResponse { + val unmarshal = xmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) +// unmarshal.document.map { doc -> doc.refDoc.content.any.find { +// rootElement -> rootElement is Element } as Element //&& rootElement.localName.equals("finnUtbetalingListe") } +// }.first { +// when((it).localName) { +// "finnUtbetalingListe" -> +// unmarshal(it.toString(), ) +// else +// } +// } + + val response = withContext(Dispatchers.IO) { + httpClient.post(UTBETAL_SOAP_ENDPOINT) { + setBody(xmlMarshaller.marshal(payloadBytes)) + }.bodyAsText() + } + return xmlMarshaller.unmarshal(response, FinnUtbetalingListeResponse::class.java) + } + + suspend fun finnBrukersUtbetalteYtelser(payloadBytes: ByteArray): FinnBrukersUtbetalteYtelserResponse { + val response = withContext(Dispatchers.IO) { + httpClient.post(UTBETAL_SOAP_ENDPOINT) { + setBody(xmlMarshaller.marshal(payloadBytes)) + }.bodyAsText() + } + return xmlMarshaller.unmarshal(response, FinnBrukersUtbetalteYtelserResponse::class.java) + } + + suspend fun finnUtbetalingListeMedHttpClient(p0: FinnUtbetalingListeRequest): FinnUtbetalingListeResponse { val response = withContext(Dispatchers.IO) { httpClient.post(UTBETAL_SOAP_ENDPOINT) { setBody(xmlMarshaller.marshal(p0)) @@ -57,7 +101,7 @@ class InntektsForesporselClient { return xmlMarshaller.unmarshal(response, FinnUtbetalingListeResponse::class.java) } - suspend fun finnBrukersUtbetalteYtelser(p0: FinnBrukersUtbetalteYtelserRequest): FinnBrukersUtbetalteYtelserResponse { + suspend fun finnBrukersUtbetalteYtelserMedHttpClient(p0: FinnBrukersUtbetalteYtelserRequest): FinnBrukersUtbetalteYtelserResponse { val response = withContext(Dispatchers.IO) { httpClient.post(UTBETAL_SOAP_ENDPOINT) { setBody(xmlMarshaller.marshal(p0)) @@ -65,6 +109,7 @@ class InntektsForesporselClient { } return xmlMarshaller.unmarshal(response, FinnBrukersUtbetalteYtelserResponse::class.java) } + fun createSecurityElement(username: String, password: String): SOAPElement { val WSSE_URI = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" val WSSE_PW_TYPE = @@ -108,5 +153,8 @@ val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester .withServiceName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "Utbetaling")) .withEndpointName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "UtbetalingPort")) .build() - // .withBasicSecurity() + .withUserNameToken( + String(FileInputStream("/secret/serviceuser/username").readAllBytes()), + String(FileInputStream("/secret/serviceuser/password").readAllBytes()) + ) .get() diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt index 53630ece..6947c146 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt @@ -2,6 +2,7 @@ package no.nav.emottak.utbetaling import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserRequest import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeRequest +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe import java.io.StringWriter import javax.xml.bind.JAXBContext import javax.xml.stream.XMLInputFactory @@ -17,6 +18,7 @@ class XmlMarshaller { private val jaxbContext = JAXBContext.newInstance( FinnUtbetalingListeRequest::class.java, FinnBrukersUtbetalteYtelserRequest::class.java, + FinnUtbetalingListe::class.java, no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.ObjectFactory::class.java, org.xmlsoap.schemas.soap.envelope.ObjectFactory::class.java, no.kith.xmlstds.msghead._2006_05_24.ObjectFactory::class.java, diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt new file mode 100644 index 00000000..1f5ab61c --- /dev/null +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -0,0 +1,21 @@ +import no.kith.xmlstds.msghead._2006_05_24.MsgHead +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import no.nav.emottak.utbetaling.unmarshal +import org.junit.jupiter.api.Test + +class InntektsforesporselTest { + + @Test + fun unmarshalMsgHead() { + val response = unmarshal( + String( + this::class.java.classLoader.getResourceAsStream("inntektsforesporsel/inntektsforesporsel.xml")!! + .readAllBytes() + ), + MsgHead::class.java + ) + + val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() + assert(request is FinnUtbetalingListe) + } +} diff --git a/ebms-send-in/src/test/resources/inntektsforesporsel/inntektsforesporsel.xml b/ebms-send-in/src/test/resources/inntektsforesporsel/inntektsforesporsel.xml new file mode 100644 index 00000000..4ad0ffea --- /dev/null +++ b/ebms-send-in/src/test/resources/inntektsforesporsel/inntektsforesporsel.xml @@ -0,0 +1,89 @@ + + + + v1.2 2006-05-24 + 2024-06-25T13:37:45 + + + + HELSEPLATTFORMEN AS + + 8137980 + + + + Meldingsmottak + + 8138375 + + + + + + + + NAV + + 111949 + + + + 23 + + + + + + + + + + + + + *********** + PERSON + + KOMMUNE + + + + + 2024-04-01 + 2024-04-30 + + + + + + + + + + + + + + + + v5V8tYBd24Ajyrr+Tc1h+e9eTOc= + + + + YmDS/uhMaYGdxsup73EYt0Fa7CfEZHgzY7ZbM8BbuD4TOBq+6w2P27/o4MdSAwKk2OkpA2M+oPZAyosIz4XVbkiIHKQ37J/xN3D0pOo13eyGzBViMOS2zH3epYlELCYvWEmZWDRvjHDqIKhhJMQiQmfycUpS3qQ9RNmZjdu1MJDZA55EVaxMMH2+ADbge7LXpn4y82B6ZkSSNHflGyP7Sbkpg9S6jLaVZSKTu+hYhG264T47FpZ214uIUVK1XX+twpfMHiV/bPss81i3Aiqh+fby28xp1yKv61f8pC+NxS0x5TvUNd3IqaaLPp6gxG44xkLykr4RSFbJJDK2DzSQYMuG0zYAnAtxSofzPVk4zSO3iJ+jc6AixjP5tQkNpPseKl7+WYY/VaoS5CVaxyK5EJKHRSeSHVC9bOy4NUW2aNA/8IOHKjD4ZOfQE6Mjj8MnQYMm/93R7k1ilehkgVRFGNAvldipJ7bn4RAVO3dD4pPQ9M8G9H8t6bHsdtjqk/5P + + + + + MIIGRDCCBCygAwIBAgILAZu7vVkWSEvush0wDQYJKoZIhvcNAQELBQAwbjELMAkGA1UEBhMCTk8xGDAWBgNVBGEMD05UUk5PLTk4MzE2MzMyNzETMBEGA1UECgwKQnV5cGFzcyBBUzEwMC4GA1UEAwwnQnV5cGFzcyBDbGFzcyAzIFRlc3Q0IENBIEcyIFNUIEJ1c2luZXNzMB4XDTIzMDkxOTA4MTUxMVoXDTI2MDkxOTIxNTkwMFowaDELMAkGA1UEBhMCTk8xHDAaBgNVBAoME0hFTFNFUExBVFRGT1JNRU4gQVMxITAfBgNVBAMMGEhFTF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GTAXMBUGCCsGAQUFBwsCMAkGBwQAi+xJAQIwDQYJKoZIhvcNAQELBQADggIBAEApxkKEwVTq+x7AC4J64VMnb5YHfdUBfOxyqJCEQJhDGe4dOSGGpgmvhpWD2FbEz11uCLIY+CGjqrPH56UUG0ZqPykLMqlqKSGLvDV00XD1UF4/042/Gv5EAJq7viaAUY3GiLGca8hsTIGCN33tcLemnIWHkSBbKOdF9Kt8h99OfDb+CE9L85aait7tTqG96FCRDsYwQRET8qkLmKRRE3sYQ8A7flrDO6KtOi1uF2JsVzoO3OvfCdWd1S+onqnQ+69d4xRdz3zB6qKxnxjDfBGFHWMkYjznl5FsbYI/jxCiPp9zpov9cXoQUKTR+qCB0hzKwve2iuSgVWADagfQAn3iaqD2ZdSkMNhOjOO7nMitUZczbELaRgTrm5VhPPIvfEsKJU2ptHfJkAStyJt82dBywcEZ0ERvX2pA0Uyq3fAmyN7IrIfkMLSbYOc0NbbeMFC9QduwKDMsUESniStnKD+30ueb97NKt8ohBJXepZCW8w9VEbyZz72TCl5V+oKDbz272aHKYQMc8iVQooz7JWEDsKyw5eUSCOrER5bgIQP/cYMacb+mzIpshrx31QoDXa2emV6oTl7lYjAD3aZOFp4uk++P3/pGQ3jP3WhaQGsoMrnZxgnH3bx/tAsYali6x+Pkp8jFqV2UOR8nNMDSP8JWDlhJr+cAtmC+0bevGfjl + + + + + \ No newline at end of file From b9d6e2c3fca1e67daf2e3f04bdd12742bdf5795a Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 16:19:54 +0200 Subject: [PATCH 06/30] Fix test --- ebms-send-in/build.gradle.kts | 2 ++ .../no/nav/emottak/utbetaling/UtbetalingClient.kt | 15 ++++++++++++--- .../src/test/kotlin/InntektsforesporselTest.kt | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ebms-send-in/build.gradle.kts b/ebms-send-in/build.gradle.kts index c65ba3b3..32324f79 100644 --- a/ebms-send-in/build.gradle.kts +++ b/ebms-send-in/build.gradle.kts @@ -69,6 +69,8 @@ dependencies { implementation("io.ktor:ktor-client-cio-jvm:2.3.4") implementation(libs.bundles.cxf) runtimeOnly("net.java.dev.jna:jna:5.12.1") + testImplementation("javax.activation:activation:1.1.1") + testImplementation("com.sun.xml.messaging.saaj:saaj-impl:1.5.1") testImplementation(testLibs.ktor.server.test.host) testImplementation(testLibs.junit.jupiter.api) testImplementation(testLibs.mockk.jvm) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 1e58d6fb..67fc1b38 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -149,12 +149,21 @@ val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.Utbetaling::class.java ) .withAddress(getEnvVar("UTBETALING_URL", "https://ytelser-rest-proxy.intern.nav.no/Utbetaling")) - .withWsdl("classpath:no/nav/ekstern/virkemiddelokonomi/utbetaling/utbetaling.wsdl") + .withWsdl( + "classpath:no.nav.ekstern.virkemiddelokonomi/tjenester/utbetaling/utbetaling.wsdl" + // "classpath:no.nav.ekstern.virkemiddelokonomi/tjenester.utbetaling/utbetaling.wsdl" + ) .withServiceName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "Utbetaling")) .withEndpointName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "UtbetalingPort")) .build() .withUserNameToken( - String(FileInputStream("/secret/serviceuser/username").readAllBytes()), - String(FileInputStream("/secret/serviceuser/password").readAllBytes()) + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> "testUserName" + else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) + }, + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> "testPassword" + else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) + } ) .get() diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index 1f5ab61c..99880e3c 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,5 +1,6 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import no.nav.emottak.utbetaling.inntektsforesporselSoapEndpoint import no.nav.emottak.utbetaling.unmarshal import org.junit.jupiter.api.Test @@ -17,5 +18,9 @@ class InntektsforesporselTest { val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) + + inntektsforesporselSoapEndpoint.finnUtbetalingListe( + (request as FinnUtbetalingListe).request + ) } } From f65e0b493ccbc796945d42243f662b59f63f7146 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 16:23:32 +0200 Subject: [PATCH 07/30] Temp ukommentert test --- ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index 99880e3c..bc14b5df 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,6 +1,5 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe -import no.nav.emottak.utbetaling.inntektsforesporselSoapEndpoint import no.nav.emottak.utbetaling.unmarshal import org.junit.jupiter.api.Test @@ -19,8 +18,8 @@ class InntektsforesporselTest { val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) - inntektsforesporselSoapEndpoint.finnUtbetalingListe( - (request as FinnUtbetalingListe).request - ) +// inntektsforesporselSoapEndpoint.finnUtbetalingListe( +// (request as FinnUtbetalingListe).request +// ) } } From e0f9fb7d8aa23827385de1eaae14d0322c3eebe6 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 16:38:29 +0200 Subject: [PATCH 08/30] Fjerner testimpl SAAJ --- ebms-send-in/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-send-in/build.gradle.kts b/ebms-send-in/build.gradle.kts index 32324f79..ca190819 100644 --- a/ebms-send-in/build.gradle.kts +++ b/ebms-send-in/build.gradle.kts @@ -67,10 +67,10 @@ dependencies { implementation(libs.ktor.server.auth.jvm) implementation(libs.ktor.client.auth) implementation("io.ktor:ktor-client-cio-jvm:2.3.4") + implementation("com.sun.xml.messaging.saaj:saaj-impl:1.5.1") implementation(libs.bundles.cxf) runtimeOnly("net.java.dev.jna:jna:5.12.1") testImplementation("javax.activation:activation:1.1.1") - testImplementation("com.sun.xml.messaging.saaj:saaj-impl:1.5.1") testImplementation(testLibs.ktor.server.test.host) testImplementation(testLibs.junit.jupiter.api) testImplementation(testLibs.mockk.jvm) From f3bc9bd8cb04c70d772c1e96e80173ead44b0710 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 18:52:01 +0200 Subject: [PATCH 09/30] =?UTF-8?q?Pr=C3=B8ver=20=C3=A5=20sette=20username/p?= =?UTF-8?q?assword=20p=C3=A5=20requestcontext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../emottak/utbetaling/UtbetalingClient.kt | 39 ++++++++++++++----- .../test/kotlin/InntektsforesporselTest.kt | 7 ++-- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 67fc1b38..07489516 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -22,6 +22,7 @@ import java.io.FileInputStream import javax.xml.namespace.QName import javax.xml.soap.SOAPElement import javax.xml.soap.SOAPFactory +import javax.xml.ws.BindingProvider class InntektsForesporselClient { @@ -44,6 +45,24 @@ class InntektsForesporselClient { val msgHead = xmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) val melding = msgHead.document.map { it.refDoc.content.any }.also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() + + (inntektsforesporselSoapEndpoint as BindingProvider).requestContext + .apply { + put( + "ws-security.username", + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> "testUserName" + else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) + } + ) + put( + "ws-security.password", + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> "testPassword" + else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) + } + ) + } val response: Any = when (melding) { is FinnUtbetalingListe -> inntektsforesporselSoapEndpoint.finnUtbetalingListe(melding.request) is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) @@ -156,14 +175,14 @@ val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester .withServiceName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "Utbetaling")) .withEndpointName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "UtbetalingPort")) .build() - .withUserNameToken( - when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { - "local" -> "testUserName" - else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) - }, - when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { - "local" -> "testPassword" - else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) - } - ) +// .withUserNameToken( +// when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { +// "local" -> "testUserName" +// else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) +// }, +// when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { +// "local" -> "testPassword" +// else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) +// } +// ) .get() diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index bc14b5df..99880e3c 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,5 +1,6 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import no.nav.emottak.utbetaling.inntektsforesporselSoapEndpoint import no.nav.emottak.utbetaling.unmarshal import org.junit.jupiter.api.Test @@ -18,8 +19,8 @@ class InntektsforesporselTest { val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) -// inntektsforesporselSoapEndpoint.finnUtbetalingListe( -// (request as FinnUtbetalingListe).request -// ) + inntektsforesporselSoapEndpoint.finnUtbetalingListe( + (request as FinnUtbetalingListe).request + ) } } From 45b7828af094fd9dc1cdd041bbab040cf692ebf2 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 18:53:28 +0200 Subject: [PATCH 10/30] =?UTF-8?q?Pr=C3=B8ver=20=C3=A5=20sette=20username/p?= =?UTF-8?q?assword=20p=C3=A5=20requestcontext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index 99880e3c..bc14b5df 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,6 +1,5 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe -import no.nav.emottak.utbetaling.inntektsforesporselSoapEndpoint import no.nav.emottak.utbetaling.unmarshal import org.junit.jupiter.api.Test @@ -19,8 +18,8 @@ class InntektsforesporselTest { val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) - inntektsforesporselSoapEndpoint.finnUtbetalingListe( - (request as FinnUtbetalingListe).request - ) +// inntektsforesporselSoapEndpoint.finnUtbetalingListe( +// (request as FinnUtbetalingListe).request +// ) } } From 776e9b3500e2beab0810ca1066ca3725343b71f3 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 19:24:28 +0200 Subject: [PATCH 11/30] =?UTF-8?q?Revert=20"Pr=C3=B8ver=20=C3=A5=20sette=20?= =?UTF-8?q?username/password=20p=C3=A5=20requestcontext"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 45b7828af094fd9dc1cdd041bbab040cf692ebf2. --- ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index bc14b5df..99880e3c 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,5 +1,6 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import no.nav.emottak.utbetaling.inntektsforesporselSoapEndpoint import no.nav.emottak.utbetaling.unmarshal import org.junit.jupiter.api.Test @@ -18,8 +19,8 @@ class InntektsforesporselTest { val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) -// inntektsforesporselSoapEndpoint.finnUtbetalingListe( -// (request as FinnUtbetalingListe).request -// ) + inntektsforesporselSoapEndpoint.finnUtbetalingListe( + (request as FinnUtbetalingListe).request + ) } } From b6a60d366d8a710af23246172692e23a470a3867 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 19:25:59 +0200 Subject: [PATCH 12/30] =?UTF-8?q?Revert=20"Pr=C3=B8ver=20=C3=A5=20sette=20?= =?UTF-8?q?username/password=20p=C3=A5=20requestcontext"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f3bc9bd8cb04c70d772c1e96e80173ead44b0710. --- .../emottak/utbetaling/UtbetalingClient.kt | 39 +++++-------------- .../test/kotlin/InntektsforesporselTest.kt | 7 ++-- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 07489516..67fc1b38 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -22,7 +22,6 @@ import java.io.FileInputStream import javax.xml.namespace.QName import javax.xml.soap.SOAPElement import javax.xml.soap.SOAPFactory -import javax.xml.ws.BindingProvider class InntektsForesporselClient { @@ -45,24 +44,6 @@ class InntektsForesporselClient { val msgHead = xmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) val melding = msgHead.document.map { it.refDoc.content.any }.also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() - - (inntektsforesporselSoapEndpoint as BindingProvider).requestContext - .apply { - put( - "ws-security.username", - when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { - "local" -> "testUserName" - else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) - } - ) - put( - "ws-security.password", - when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { - "local" -> "testPassword" - else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) - } - ) - } val response: Any = when (melding) { is FinnUtbetalingListe -> inntektsforesporselSoapEndpoint.finnUtbetalingListe(melding.request) is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) @@ -175,14 +156,14 @@ val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester .withServiceName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "Utbetaling")) .withEndpointName(QName("http://nav.no/ekstern/virkemiddelokonomi/tjenester/utbetaling/v1", "UtbetalingPort")) .build() -// .withUserNameToken( -// when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { -// "local" -> "testUserName" -// else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) -// }, -// when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { -// "local" -> "testPassword" -// else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) -// } -// ) + .withUserNameToken( + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> "testUserName" + else -> String(FileInputStream("/secret/serviceuser/username").readAllBytes()) + }, + when (getEnvVar("NAIS_CLUSTER_NAME", "local")) { + "local" -> "testPassword" + else -> String(FileInputStream("/secret/serviceuser/password").readAllBytes()) + } + ) .get() diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index 99880e3c..bc14b5df 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,6 +1,5 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe -import no.nav.emottak.utbetaling.inntektsforesporselSoapEndpoint import no.nav.emottak.utbetaling.unmarshal import org.junit.jupiter.api.Test @@ -19,8 +18,8 @@ class InntektsforesporselTest { val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) - inntektsforesporselSoapEndpoint.finnUtbetalingListe( - (request as FinnUtbetalingListe).request - ) +// inntektsforesporselSoapEndpoint.finnUtbetalingListe( +// (request as FinnUtbetalingListe).request +// ) } } From 72a0f3d75668497ba6ad7aab77ec6dd6f266dd20 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 21 Aug 2024 19:26:23 +0200 Subject: [PATCH 13/30] Fix URL --- .../main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 67fc1b38..28167e71 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -148,7 +148,7 @@ val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester ServiceBuilder( no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.Utbetaling::class.java ) - .withAddress(getEnvVar("UTBETALING_URL", "https://ytelser-rest-proxy.intern.nav.no/Utbetaling")) + .withAddress(getEnvVar("UTBETALING_URL", "https://ytelser-rest-proxy.dev.intern.nav.no/Utbetaling")) .withWsdl( "classpath:no.nav.ekstern.virkemiddelokonomi/tjenester/utbetaling/utbetaling.wsdl" // "classpath:no.nav.ekstern.virkemiddelokonomi/tjenester.utbetaling/utbetaling.wsdl" From a67e29a95cb144647306fa2cd159e4aefc5f1a80 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Fri, 6 Sep 2024 16:51:23 +0200 Subject: [PATCH 14/30] Construct message head --- .../main/kotlin/no/nav/emottak/ebms/App.kt | 7 +- .../no/nav/emottak/ebms/xml/DomUtils.kt | 9 ++ .../main/kotlin/no/nav/emottak/ebms/App.kt | 14 ++- .../no/nav/emottak/utbetaling/MsgHeadUtil.kt | 60 ++++++++++ .../emottak/utbetaling/UtbetalingClient.kt | 109 +----------------- .../nav/emottak/utbetaling/XmlMarshaller.kt | 6 +- 6 files changed, 88 insertions(+), 117 deletions(-) create mode 100644 ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt diff --git a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt index fd1638a8..6ef933f6 100644 --- a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -47,6 +47,7 @@ import no.nav.emottak.ebms.validation.MimeHeaders import no.nav.emottak.ebms.validation.MimeValidationException import no.nav.emottak.ebms.validation.validateMimeAttachment import no.nav.emottak.ebms.validation.validateMimeSoapEnvelope +import no.nav.emottak.ebms.xml.asByteArray import no.nav.emottak.ebms.xml.asString import no.nav.emottak.ebms.xml.getDocumentBuilder import no.nav.emottak.melding.model.EbmsAttachment @@ -54,6 +55,7 @@ import no.nav.emottak.util.createUniqueMimeMessageId import no.nav.emottak.util.getEnvVar import org.slf4j.LoggerFactory import java.io.ByteArrayInputStream +import java.nio.charset.StandardCharsets import java.time.Duration import java.time.Instant import java.util.Base64 @@ -268,7 +270,7 @@ suspend fun ApplicationCall.respondEbmsDokument(ebmsDokument: EbMSDocument) { this.append(MimeHeaders.SOAP_ACTION, "ebXML") } if (ebmsDokument.dokumentType() == DokumentType.PAYLOAD) { - val ebxml = Base64.getMimeEncoder().encodeToString(ebmsDokument.dokument.asString().toByteArray()) + val ebxml = Base64.getMimeEncoder().encodeToString(ebmsDokument.dokument.asByteArray()) val contentId = createUniqueMimeMessageId() val ebxmlFormItem = PartData.FormItem( ebxml, @@ -282,7 +284,8 @@ suspend fun ApplicationCall.respondEbmsDokument(ebmsDokument: EbMSDocument) { val parts = mutableListOf(ebxmlFormItem) ebmsDokument.attachments.first().let { PartData.FormItem( - Base64.getMimeEncoder().encodeToString(it.bytes), + // Base64.getMimeEncoder().encodeToString(it.bytes), // Implicit ISO_8859_1 + String(Base64.getEncoder().encode(it.bytes), StandardCharsets.UTF_8), // TODO verifiser {}, HeadersBuilder().apply { append(MimeHeaders.CONTENT_TRANSFER_ENCODING, "base64") diff --git a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/xml/DomUtils.kt b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/xml/DomUtils.kt index 5928857e..c6949b8e 100644 --- a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/xml/DomUtils.kt +++ b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/xml/DomUtils.kt @@ -1,6 +1,7 @@ package no.nav.emottak.ebms.xml import org.w3c.dom.Document +import java.io.ByteArrayOutputStream import java.io.StringWriter import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -31,3 +32,11 @@ fun Document.asString(): String { transformer.transform(domSource, sr) return sw.toString() } + +fun Document.asByteArray(): ByteArray { + return ByteArrayOutputStream().use { + TransformerFactory.newInstance().newTransformer() + .transform(DOMSource(this), StreamResult(it)) + it.toByteArray() + } +} diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index 014df56e..c5c6807e 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -21,6 +21,7 @@ import io.micrometer.prometheus.PrometheusConfig import io.micrometer.prometheus.PrometheusMeterRegistry import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.emottak.auth.AZURE_AD_AUTH import no.nav.emottak.auth.AuthConfig import no.nav.emottak.fellesformat.wrapMessageInEIFellesFormat @@ -29,6 +30,8 @@ import no.nav.emottak.frikort.marshal import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.melding.model.SendInResponse import no.nav.emottak.utbetaling.InntektsForesporselClient +import no.nav.emottak.utbetaling.MsgHeadUtil +import no.nav.emottak.utbetaling.utbetalingXmlMarshaller import no.nav.emottak.util.getEnvVar import no.nav.emottak.util.marker import no.nav.security.token.support.v2.tokenValidationSupport @@ -81,7 +84,10 @@ fun Application.ebmsSendInModule() { when (request.addressing.service) { "Inntektsforesporsel" -> timed(appMicrometerRegistry, "Inntektsforesporsel") { - inntektsForesporselClient.behandleInntektsforesporsel(request.payload) // TODO hva med fellesformat? + MsgHeadUtil().msgHeadResponse( + request, + inntektsForesporselClient.behandleInntektsforesporsel(request.payload) + ) } else -> timed(appMicrometerRegistry, "frikort-sporing") { @@ -94,14 +100,14 @@ fun Application.ebmsSendInModule() { request.marker(), "Payload ${request.payloadId} videresending til fagsystem ferdig, svar mottatt og returnerert" ) - when (it) { // TODO gjerne tenk igjennom en bedre flyt - is ByteArray -> + when (it) { // TODO gjerne tenk igjennom en bedre flyt, kanskje alt burde få MsgHead + is MsgHead -> call.respond( SendInResponse( request.messageId, request.conversationId, request.addressing.replyTo(request.addressing.service, request.addressing.action), // TODO ser feil ut? - it + utbetalingXmlMarshaller.marshal(it).toByteArray() ) ) is FrikortsporringResponse -> diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt new file mode 100644 index 00000000..8da03a74 --- /dev/null +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt @@ -0,0 +1,60 @@ +package no.nav.emottak.utbetaling + +import no.kith.xmlstds.msghead._2006_05_24.Document +import no.kith.xmlstds.msghead._2006_05_24.MsgHead +import no.kith.xmlstds.msghead._2006_05_24.RefDoc +import no.nav.emottak.melding.model.SendInRequest +import no.nav.emottak.util.toXMLGregorianCalendar +import java.nio.charset.StandardCharsets +import java.time.Instant +import java.util.UUID + +class MsgHeadUtil { + + fun msgHeadResponse(sendInRequest: SendInRequest, fagmeldingResponse: ByteArray): MsgHead { + val msgHead: MsgHead = + utbetalingXmlMarshaller + .unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) + + return msgHead.apply { + msgInfo.apply { + type.apply { + dn = "Svar på forespørsel om inntekt" + v = "InntektInformasjon" + } + genDate = Instant.now().toXMLGregorianCalendar() + msgId = UUID.randomUUID().toString() + ack.apply { + v = "N" + dn = "Nei" + } + val newReceiver = sender + val newSender = receiver + sender.apply { organisation = newSender.organisation } + receiver.apply { organisation = newReceiver.organisation } + conversationRef.apply { + refToParent = sendInRequest.messageId + refToConversation = sendInRequest.conversationId + } + } + document.clear() + document.add( + Document().apply { + refDoc.apply { + msgType.apply { + v = "XML" + dn = "XML-instans" + } + mimeType = "text/xml" + content = RefDoc.Content().apply { + any.add( + listOf(String(fagmeldingResponse, StandardCharsets.UTF_8)) + ) + } + } + } + ) + signature = null // TODO? + } + } +} diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 28167e71..4e87f7ab 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -1,18 +1,6 @@ package no.nav.emottak.utbetaling -import io.ktor.client.HttpClient -import io.ktor.client.engine.cio.CIO -import io.ktor.client.request.post -import io.ktor.client.request.setBody -import io.ktor.client.statement.bodyAsText -import io.ktor.client.statement.readBytes -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import no.kith.xmlstds.msghead._2006_05_24.MsgHead -import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserRequest -import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserResponse -import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeRequest -import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeResponse import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnBrukersUtbetalteYtelser import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe import no.nav.emottak.cxf.ServiceBuilder @@ -20,8 +8,6 @@ import no.nav.emottak.util.getEnvVar import org.slf4j.LoggerFactory import java.io.FileInputStream import javax.xml.namespace.QName -import javax.xml.soap.SOAPElement -import javax.xml.soap.SOAPFactory class InntektsForesporselClient { @@ -38,10 +24,8 @@ class InntektsForesporselClient { } val UTBETAL_SOAP_ENDPOINT = RESOLVED_UTBETAL_URL + "/Utbetaling" - val httpClient = HttpClient(CIO) - fun behandleInntektsforesporsel(payloadBytes: ByteArray): ByteArray { - val msgHead = xmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) + val msgHead = utbetalingXmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) val melding = msgHead.document.map { it.refDoc.content.any }.also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() val response: Any = when (melding) { @@ -51,97 +35,6 @@ class InntektsForesporselClient { } return marshal(response).toByteArray() } - - fun sendInntektsforesporsel(payloadBytes: ByteArray): suspend () -> ByteArray { - log.info("Sender inntektsforespørsel til $UTBETAL_SOAP_ENDPOINT:\n" + String(payloadBytes)) - return { - httpClient.post(UTBETAL_SOAP_ENDPOINT) { - setBody(payloadBytes) - }.readBytes().also { - log.info("(DEBUG) Inntektsforesporsel response: " + String(it)) // TODO delete debug logging - } - } - } - - suspend fun finnUtbetalingListe(payloadBytes: ByteArray): FinnUtbetalingListeResponse { - val unmarshal = xmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) -// unmarshal.document.map { doc -> doc.refDoc.content.any.find { -// rootElement -> rootElement is Element } as Element //&& rootElement.localName.equals("finnUtbetalingListe") } -// }.first { -// when((it).localName) { -// "finnUtbetalingListe" -> -// unmarshal(it.toString(), ) -// else -// } -// } - - val response = withContext(Dispatchers.IO) { - httpClient.post(UTBETAL_SOAP_ENDPOINT) { - setBody(xmlMarshaller.marshal(payloadBytes)) - }.bodyAsText() - } - return xmlMarshaller.unmarshal(response, FinnUtbetalingListeResponse::class.java) - } - - suspend fun finnBrukersUtbetalteYtelser(payloadBytes: ByteArray): FinnBrukersUtbetalteYtelserResponse { - val response = withContext(Dispatchers.IO) { - httpClient.post(UTBETAL_SOAP_ENDPOINT) { - setBody(xmlMarshaller.marshal(payloadBytes)) - }.bodyAsText() - } - return xmlMarshaller.unmarshal(response, FinnBrukersUtbetalteYtelserResponse::class.java) - } - - suspend fun finnUtbetalingListeMedHttpClient(p0: FinnUtbetalingListeRequest): FinnUtbetalingListeResponse { - val response = withContext(Dispatchers.IO) { - httpClient.post(UTBETAL_SOAP_ENDPOINT) { - setBody(xmlMarshaller.marshal(p0)) - }.bodyAsText() - } - return xmlMarshaller.unmarshal(response, FinnUtbetalingListeResponse::class.java) - } - - suspend fun finnBrukersUtbetalteYtelserMedHttpClient(p0: FinnBrukersUtbetalteYtelserRequest): FinnBrukersUtbetalteYtelserResponse { - val response = withContext(Dispatchers.IO) { - httpClient.post(UTBETAL_SOAP_ENDPOINT) { - setBody(xmlMarshaller.marshal(p0)) - }.bodyAsText() - } - return xmlMarshaller.unmarshal(response, FinnBrukersUtbetalteYtelserResponse::class.java) - } - - fun createSecurityElement(username: String, password: String): SOAPElement { - val WSSE_URI = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" - val WSSE_PW_TYPE = - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" - try { - // https://www.ibm.com/docs/en/was/9.0.5?topic=authentication-username-token - val soapFactory = SOAPFactory.newInstance() - val usernameElement = soapFactory - .createElement("Username", "wsse", WSSE_URI).addTextNode(username) - val passwordElement = soapFactory - .createElement("Password", "wsse", WSSE_URI).addTextNode(password) - passwordElement - .addAttribute(QName("Type"), WSSE_PW_TYPE) - - val usernameTokenElement = soapFactory - .createElement("UsernameToken", "wsse", WSSE_URI) - - usernameTokenElement.addChildElement(usernameElement) - usernameTokenElement.addChildElement(passwordElement) - - val securityElement = soapFactory.createElement( - "Security", - "wsse", - WSSE_URI - ) - securityElement.addChildElement(usernameTokenElement) - return securityElement - } catch (e: javax.xml.soap.SOAPException) { - log.error("Feil i createSecurityElement", e) - throw RuntimeException("Feil i generering av usernametoken") - } - } } val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.Utbetaling = diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt index 6947c146..92350116 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt @@ -7,10 +7,10 @@ import java.io.StringWriter import javax.xml.bind.JAXBContext import javax.xml.stream.XMLInputFactory -val xmlMarshaller = XmlMarshaller() +val utbetalingXmlMarshaller = XmlMarshaller() -fun marshal(objekt: Any) = xmlMarshaller.marshal(objekt) -fun unmarshal(xml: String, clazz: Class): T = xmlMarshaller.unmarshal(xml, clazz) +fun marshal(objekt: Any) = utbetalingXmlMarshaller.marshal(objekt) +fun unmarshal(xml: String, clazz: Class): T = utbetalingXmlMarshaller.unmarshal(xml, clazz) class XmlMarshaller { From 3f2b5a616453b0f1498d08f3afeac9628335f5f6 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 10:13:25 +0200 Subject: [PATCH 15/30] =?UTF-8?q?Feilh=C3=A5ndtering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .nais/ebms-send-in-dev.yaml | 3 + .nais/smtp-listeners-prod.yaml | 4 +- .../emottak/utbetaling/UtbetalingClient.kt | 46 +- .../nav/emottak/utbetaling/XmlMarshaller.kt | 12 + .../test/kotlin/InntektsforesporselTest.kt | 30 +- readme.md | 1 + settings.gradle.kts | 2 +- .../main/kotlin/no/nav/emottak/HttpClients.kt | 6 +- .../emottak/smtp/cpasync/CpaSyncService.kt | 143 +++--- .../smtp/cpasync/CpaSyncServiceTest.kt | 425 +++++++++++------- 10 files changed, 416 insertions(+), 256 deletions(-) diff --git a/.nais/ebms-send-in-dev.yaml b/.nais/ebms-send-in-dev.yaml index 45a2238d..51120165 100644 --- a/.nais/ebms-send-in-dev.yaml +++ b/.nais/ebms-send-in-dev.yaml @@ -50,6 +50,9 @@ spec: inbound: rules: - application: ebms-provider + - application: azure-token-generator + namespace: team-emottak + cluster: dev-fss env: - name: FRIKORT_URL value: https://wasapp-q1.adeo.no/nav-frikort/tjenestereksterne \ No newline at end of file diff --git a/.nais/smtp-listeners-prod.yaml b/.nais/smtp-listeners-prod.yaml index d27ae637..ea2252b0 100644 --- a/.nais/smtp-listeners-prod.yaml +++ b/.nais/smtp-listeners-prod.yaml @@ -30,10 +30,10 @@ spec: resources: limits: cpu: "200m" - memory: "512Mi" + memory: "1024Mi" requests: cpu: "200m" - memory: "512Mi" + memory: "1024Mi" ingresses: - "https://smtp-listeners.intern.nav.no" filesFrom: diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 4e87f7ab..302e4734 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -3,6 +3,11 @@ package no.nav.emottak.utbetaling import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnBrukersUtbetalteYtelser import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBaksystemIkkeTilgjengelig +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBrukerIkkeFunnet +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeIngenTilgangTilEnEllerFlereYtelser +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeUgyldigDato +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeUgyldigKombinasjonBrukerIdOgBrukertype import no.nav.emottak.cxf.ServiceBuilder import no.nav.emottak.util.getEnvVar import org.slf4j.LoggerFactory @@ -13,6 +18,9 @@ class InntektsForesporselClient { val log = LoggerFactory.getLogger(InntektsForesporselClient::class.java) + val utbetalingObjectFactory: no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory = + no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory() + val YRP_URL_TEST = "https://ytelser-rest-proxy.intern.dev.nav.no" val YRP_URL_PROD = "https://ytelser-rest-proxy.intern.nav.no" val RESOLVED_UTBETAL_URL = @@ -26,14 +34,40 @@ class InntektsForesporselClient { fun behandleInntektsforesporsel(payloadBytes: ByteArray): ByteArray { val msgHead = utbetalingXmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) - val melding = msgHead.document.map { it.refDoc.content.any }.also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } + val melding = msgHead.document.map { it.refDoc.content.any } + .also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() - val response: Any = when (melding) { - is FinnUtbetalingListe -> inntektsforesporselSoapEndpoint.finnUtbetalingListe(melding.request) - is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) - else -> throw IllegalStateException("Ukjent meldingstype. Classname: " + melding.javaClass.name) + try { + val response: Any = when (melding) { + is FinnUtbetalingListe -> inntektsforesporselSoapEndpoint.finnUtbetalingListe(melding.request) + is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) + else -> throw IllegalStateException("Ukjent meldingstype. Classname: " + melding.javaClass.name) + } + return marshal(response).toByteArray() + } catch (utbetalError: Throwable) { + log.info("Handling inntektsforesporsel error: " + utbetalError.message) + return utbetalingXmlMarshaller.marshalToByteArray( + when (utbetalError) { + is FinnUtbetalingListeBrukerIkkeFunnet + -> utbetalingObjectFactory + .createFinnUtbetalingListebrukerIkkeFunnet(utbetalError.faultInfo) + is FinnUtbetalingListeBaksystemIkkeTilgjengelig + -> utbetalingObjectFactory + .createFinnUtbetalingListebaksystemIkkeTilgjengelig(utbetalError.faultInfo) + is FinnUtbetalingListeIngenTilgangTilEnEllerFlereYtelser + -> utbetalingObjectFactory + .createFinnUtbetalingListeingenTilgangTilEnEllerFlereYtelser(utbetalError.faultInfo) + is FinnUtbetalingListeUgyldigDato + -> utbetalingObjectFactory + .createFinnUtbetalingListeugyldigDato(utbetalError.faultInfo) + is FinnUtbetalingListeUgyldigKombinasjonBrukerIdOgBrukertype + -> utbetalingObjectFactory + .createFinnUtbetalingListeugyldigKombinasjonBrukerIdOgBrukertype(utbetalError.faultInfo) + else -> + throw utbetalError.also { log.error("Ukjent feiltype: " + it.message, it) } + } + ) } - return marshal(response).toByteArray() } } diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt index 92350116..acc9c92a 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt @@ -3,6 +3,7 @@ package no.nav.emottak.utbetaling import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnBrukersUtbetalteYtelserRequest import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.FinnUtbetalingListeRequest import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import java.io.ByteArrayOutputStream import java.io.StringWriter import javax.xml.bind.JAXBContext import javax.xml.stream.XMLInputFactory @@ -20,6 +21,8 @@ class XmlMarshaller { FinnBrukersUtbetalteYtelserRequest::class.java, FinnUtbetalingListe::class.java, no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.ObjectFactory::class.java, + no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.feil.v1.ObjectFactory::class.java, + no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory::class.java, org.xmlsoap.schemas.soap.envelope.ObjectFactory::class.java, no.kith.xmlstds.msghead._2006_05_24.ObjectFactory::class.java, org.w3._1999.xlink.ObjectFactory::class.java, @@ -39,6 +42,15 @@ class XmlMarshaller { return writer.toString() } + fun marshalToByteArray(objekt: Any): ByteArray { + return ByteArrayOutputStream().use { + synchronized(marshlingMonitor) { + marshaller.marshal(objekt, it) + } + it.toByteArray() + } + } + fun unmarshal(xml: String, clazz: Class): T { val reader = XMLInputFactory.newInstance().createXMLStreamReader(xml.reader()) return synchronized(unmarshlingMonitor) { diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index bc14b5df..a8333205 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,7 +1,12 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.feil.v1.BrukerIkkeFunnet +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.feil.v1.ObjectFactory import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBrukerIkkeFunnet import no.nav.emottak.utbetaling.unmarshal +import no.nav.emottak.utbetaling.utbetalingXmlMarshaller import org.junit.jupiter.api.Test +import kotlin.reflect.full.memberFunctions class InntektsforesporselTest { @@ -14,12 +19,29 @@ class InntektsforesporselTest { ), MsgHead::class.java ) - val request = response.document.map { doc -> doc.refDoc.content.any }.first().first() assert(request is FinnUtbetalingListe) + } + + @Test + fun canMarshalFaultInfo() { + val stelvioFault = ObjectFactory().createBrukerIkkeFunnet() + stelvioFault.errorMessage = "Ayylmaoo" + val brukerIkkeFunnetException: Exception = FinnUtbetalingListeBrukerIkkeFunnet("Ayylmaoo", stelvioFault) + val createFinnBrukersUtbetalteYtelserbrukerIkkeFunnet = + no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory() + .createFinnBrukersUtbetalteYtelserbrukerIkkeFunnet( + with(brukerIkkeFunnetException) { + this::class.memberFunctions + .find { func -> func.name == "getFaultInfo" }!! + .call(this) as BrukerIkkeFunnet + } + ) -// inntektsforesporselSoapEndpoint.finnUtbetalingListe( -// (request as FinnUtbetalingListe).request -// ) + println( + String( + utbetalingXmlMarshaller.marshalToByteArray(createFinnBrukersUtbetalteYtelserbrukerIkkeFunnet) + ) + ) } } diff --git a/readme.md b/readme.md index 3d984548..960d86a8 100644 --- a/readme.md +++ b/readme.md @@ -86,6 +86,7 @@ Les dokumentasjon fra e-helse for deres tolkning av ebXML-standarden. * [ebXML Rammeverk](https://sarepta.helsedir.no/standard/EBXML%20rammeverk) * [Basert på ebXML](https://git.sarepta.ehelse.no/publisert/standarder/raw/master/kravdokument/EBXMLrammeverk/HIS%201037_2011%20Rammeverk%20for%20meldingsutveksling%20v1.1%20-oppdatert.pdf) +* [Implementasjon og bruk av ebXML som rammeverk for meldingsutveksling](https://git.sarepta.ehelse.no/publisert/standarder/raw/master/kravdokument/VeiledningTilRiktigBrukAvebXML/HITS%201171_2017%20Implementasjon%20og%20bruk%20av%20ebXML%20-oppdatert.pdf) * [Validering av ebXML-meldinger](https://git.sarepta.ehelse.no/publisert/standarder/raw/master/kravdokument/ValideringAvebXMLMeldinger/HITS%201172_2017%20Validering%20av%20ebXML-meldinger%20-oppdatert.pdf) * [Profil for CPP/CPA](https://www.ehelse.no/standardisering/standarder/profil-for-cpp-cpa--partnerprofiler-og-avtaler/_/attachment/inline/8ff59f07-70be-459a-a644-6b11451d1dc2:b47b3b4b5740def9e91c0cd2795c872dd4196d3c/Profil%20for%20CPP%20CPA%20%E2%80%93%20partnerprofiler%20og%20avtaler.pdf) diff --git a/settings.gradle.kts b/settings.gradle.kts index e28cc009..3bc9f85b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -56,7 +56,7 @@ dependencyResolutionManagement { library("ktor-server-auth-jvm", "io.ktor:ktor-server-auth-jvm:2.3.8") library("token-validation-ktor-v2", "no.nav.security:token-validation-ktor-v2:4.1.4") library("flyway-core", "org.flywaydb:flyway-core:9.16.3") - library("emottak-payload-xsd", "no.nav.emottak:emottak-payload-xsd:0.0.4") + library("emottak-payload-xsd", "no.nav.emottak:emottak-payload-xsd:0.0.5") library("jaxb-runtime", "org.glassfish.jaxb:jaxb-runtime:2.4.0-b180830.0438") library("cxf-rt-frontend-jaxws", "org.apache.cxf", "cxf-rt-frontend-jaxws").versionRef("cxf") library("cxf-rt-transports-http", "org.apache.cxf", "cxf-rt-transports-http").versionRef("cxf") diff --git a/smtp-listeners/src/main/kotlin/no/nav/emottak/HttpClients.kt b/smtp-listeners/src/main/kotlin/no/nav/emottak/HttpClients.kt index 56394ff4..e1ad6a2a 100644 --- a/smtp-listeners/src/main/kotlin/no/nav/emottak/HttpClients.kt +++ b/smtp-listeners/src/main/kotlin/no/nav/emottak/HttpClients.kt @@ -33,7 +33,6 @@ import no.nav.emottak.smtp.log import java.net.InetSocketAddress import java.net.Proxy import java.net.URL -import java.time.Instant val URL_CPA_REPO_BASE = getEnvVar("URL_CPA_REPO", "http://cpa-repo.team-emottak.svc.nais.local") val URL_CPA_REPO_PUT = "$URL_CPA_REPO_BASE/cpa".also { log.info("CPA REPO PUT URL: [$it]") } @@ -120,11 +119,10 @@ suspend fun HttpClient.getCPATimestamps() = this.get(URL_CPA_REPO_TIMESTAMPS).bodyAsText() ) -suspend fun HttpClient.putCPAinCPARepo(cpaFile: String, lastModified: Instant) = +suspend fun HttpClient.putCPAinCPARepo(cpaFile: String, lastModified: String) = this.post(URL_CPA_REPO_PUT) { headers { - header("updated_date", lastModified.toString()) - header("upsert", "true") // Upsert kan nok alltid brukes (?) + header("updated_date", lastModified) } setBody(cpaFile) } diff --git a/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncService.kt b/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncService.kt index e78345a3..54c672b4 100644 --- a/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncService.kt +++ b/smtp-listeners/src/main/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncService.kt @@ -9,103 +9,114 @@ import no.nav.emottak.nfs.NFSConnector import no.nav.emottak.putCPAinCPARepo import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.io.ByteArrayOutputStream +import java.nio.charset.StandardCharsets import java.time.Instant import java.time.temporal.ChronoUnit +import java.util.zip.GZIPInputStream +import java.util.zip.GZIPOutputStream -class CpaSyncService(private val cpaRepoClient: HttpClient, private val nfsConnector: NFSConnector) { +data class NfsCpa(val id: String, val timestamp: String, val content: ByteArray) +class CpaSyncService(private val cpaRepoClient: HttpClient, private val nfsConnector: NFSConnector) { private val log: Logger = LoggerFactory.getLogger("no.nav.emottak.smtp.cpasync") suspend fun sync() { return runCatching { - val cpaTimestamps = cpaRepoClient.getCPATimestamps() - processAndSyncEntries(cpaTimestamps) + val dbCpaMap = cpaRepoClient.getCPATimestamps() + val nfsCpaMap = getNfsCpaMap() + upsertFreshCpa(nfsCpaMap, dbCpaMap) + deleteStaleCpa(nfsCpaMap.keys, dbCpaMap) }.onFailure { logFailure(it) }.getOrThrow() } - private suspend fun processAndSyncEntries(cpaTimestamps: Map) { - nfsConnector.use { connector -> - val staleCpaTimestamps = connector.folder().asSequence() + internal fun getNfsCpaMap(): Map { + return nfsConnector.use { connector -> + connector.folder().asSequence() .filter { entry -> isXmlFileEntry(entry) } - .fold(cpaTimestamps) { accumulatedCpaTimestamps, entry -> - val filename = entry.filename - val lastModified = getLastModifiedInstant(entry.attrs.mTime.toLong()) - val shouldSkip = shouldSkipFile(filename, lastModified, accumulatedCpaTimestamps) - if (!shouldSkip) { - runCatching { - log.info("Fetching file $filename") - val cpaFileContent = connector.file("/outbound/cpa/$filename").use { - String(it.readAllBytes()) - } - log.info("Uploading $filename") - cpaRepoClient.putCPAinCPARepo(cpaFileContent, lastModified) - }.onFailure { - log.error("Error uploading $filename to cpa-repo: ${it.message}", it) - } - } - - filterStaleCpaTimestamps(filename, lastModified, accumulatedCpaTimestamps) + .fold(mutableMapOf()) { accumulator, nfsCpaFile -> + val nfsCpa = getNfsCpa(connector, nfsCpaFile) + + val existingEntry = accumulator.put(nfsCpa.id, nfsCpa) + require(existingEntry == null) { "NFS contains duplicate CPA IDs. Aborting sync." } + + accumulator } + } + } - deleteStaleCpaEntries(staleCpaTimestamps) + internal fun isXmlFileEntry(entry: ChannelSftp.LsEntry): Boolean { + if (entry.filename.endsWith(".xml")) { + return true } + log.debug("${entry.filename} is ignored. Invalid file ending") + return false } - internal fun getLastModifiedInstant(mTimeInSeconds: Long): Instant { - return Instant.ofEpochSecond(mTimeInSeconds).truncatedTo(ChronoUnit.SECONDS) + internal fun getNfsCpa(connector: NFSConnector, nfsCpaFile: ChannelSftp.LsEntry): NfsCpa { + val timestamp = getLastModified(nfsCpaFile.attrs.mTime.toLong()) + val cpaContent = fetchNfsCpaContent(connector, nfsCpaFile) + val cpaId = getCpaIdFromCpaContent(cpaContent) + require(cpaId != null) { + "Regex to find CPA ID in file ${nfsCpaFile.filename} did not find any match. " + + "File corrupted or wrongful regex. Aborting sync." + } + val zippedCpaContent = zipCpaContent(cpaContent) + + return NfsCpa(cpaId, timestamp, zippedCpaContent) } - private fun isXmlFileEntry(entry: ChannelSftp.LsEntry) = if (!entry.filename.endsWith(".xml")) { - log.warn("${entry.filename} is ignored") - false - } else { - true + private fun fetchNfsCpaContent(nfsConnector: NFSConnector, nfsCpaFile: ChannelSftp.LsEntry): String { + return nfsConnector.file("/outbound/cpa/${nfsCpaFile.filename}").use { + String(it.readAllBytes()) + } + } + + private fun getCpaIdFromCpaContent(cpaContent: String): String? { + return Regex("cppa:cpaid=\"(?.+?)\"") + .find(cpaContent)?.groups?.get("cpaId")?.value } - private fun filterStaleCpaTimestamps( - filename: String, - lastModified: Instant, - cpaTimestamps: Map - ): Map { - return cpaTimestamps.filter { (cpaId, timestamp) -> isStaleCpa(cpaId, filename, timestamp, lastModified) } + internal fun getLastModified(mTimeInSeconds: Long): String { + return Instant.ofEpochSecond(mTimeInSeconds).truncatedTo(ChronoUnit.SECONDS).toString() } - private fun isStaleCpa( - cpaId: String, - filename: String, - timestamp: String, - lastModified: Instant - ): Boolean { - val formattedCpaId = cpaId.replace(":", ".") + ".xml" - return if (filename == formattedCpaId) { - if (timestamp != lastModified.toString()) { - log.info("$filename has different timestamp, should be updated") + internal fun zipCpaContent(cpaContent: String): ByteArray { + val byteStream = ByteArrayOutputStream() + GZIPOutputStream(byteStream) + .bufferedWriter(StandardCharsets.UTF_8) + .use { it.write(cpaContent) } + return byteStream.toByteArray() + } + + private suspend fun upsertFreshCpa(nfsCpaMap: Map, dbCpaMap: Map) { + nfsCpaMap.forEach { entry -> + if (shouldUpsertCpa(entry.value.timestamp, dbCpaMap[entry.key])) { + log.info("Upserting new/modified CPA: ${entry.key} - ${entry.value.timestamp}") + val unzippedCpaContent = unzipCpaContent(entry.value.content) + cpaRepoClient.putCPAinCPARepo(unzippedCpaContent, entry.value.timestamp) + } else { + log.debug("Skipping upsert for unmodified CPA: ${entry.key} - ${entry.value.timestamp}") } - false - } else { - true // the file will be deleted } } - internal fun shouldSkipFile( - filename: String, - lastModified: Instant, - cpaTimestamps: Map - ): Boolean { - return cpaTimestamps - .filterKeys { cpaId -> filename == cpaId.replace(":", ".") + ".xml" } - .filterValues { timestamp -> lastModified.toString() == timestamp } - .ifEmpty { - log.info("Could not find matching timestamp for file $filename with lastModified timestamp $lastModified") - return false - }.any() + internal fun unzipCpaContent(byteArray: ByteArray): String { + return GZIPInputStream(byteArray.inputStream()).bufferedReader(StandardCharsets.UTF_8).use { it.readText() } + } + + internal fun shouldUpsertCpa(nfsTimestamp: String, dbTimestamp: String?): Boolean { + if (dbTimestamp == null) return true + return Instant.parse(nfsTimestamp) > Instant.parse(dbTimestamp) } - internal suspend fun deleteStaleCpaEntries(cpaTimestamps: Map) { - cpaTimestamps.forEach { (cpaId) -> - cpaRepoClient.deleteCPAinCPARepo(cpaId) + private suspend fun deleteStaleCpa(nfsCpaIds: Set, dbCpaMap: Map) { + val staleCpa = dbCpaMap - nfsCpaIds + staleCpa.forEach { entry -> + log.info("Deleting stale entry: ${entry.key} - ${entry.value}") + cpaRepoClient.deleteCPAinCPARepo(entry.key) } } diff --git a/smtp-listeners/src/test/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncServiceTest.kt b/smtp-listeners/src/test/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncServiceTest.kt index c8fc97f6..f88a3797 100644 --- a/smtp-listeners/src/test/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncServiceTest.kt +++ b/smtp-listeners/src/test/kotlin/no/nav/emottak/smtp/cpasync/CpaSyncServiceTest.kt @@ -20,241 +20,307 @@ import no.nav.emottak.deleteCPAinCPARepo import no.nav.emottak.getCPATimestamps import no.nav.emottak.nfs.NFSConnector import no.nav.emottak.putCPAinCPARepo +import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows import java.io.ByteArrayInputStream +import java.io.File import java.time.Instant import java.util.* +import kotlin.test.assertEquals import kotlin.test.assertFailsWith -import kotlin.test.assertFalse import kotlin.test.assertTrue class CpaSyncServiceTest { - - private val cpaRepoClient: HttpClient = mockk(relaxed = true) + private val mockCpaRepoClient: HttpClient = mockk(relaxed = true) private val mockHttpResponse: HttpResponse = mockk(relaxed = true) - private lateinit var cpaSyncService: CpaSyncService + private val mockNFSConnector: NFSConnector = mockk(relaxed = true) @BeforeEach fun setUp() { mockkStatic("no.nav.emottak.HttpClientsKt") - clearMocks(cpaRepoClient) - coEvery { cpaRepoClient.deleteCPAinCPARepo(any()) } returns mockHttpResponse - coEvery { cpaRepoClient.putCPAinCPARepo(any(), any()) } returns mockHttpResponse + clearMocks(mockCpaRepoClient) + coEvery { mockCpaRepoClient.deleteCPAinCPARepo(any()) } returns mockHttpResponse + coEvery { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } returns mockHttpResponse } @Test - fun `sync should do nothing when all entries match own database`() = runBlocking { - val cpaTimestampsFromDb = mutableMapOf("cpa1" to "2024-01-01T00:00:00Z", "cpa2" to "2024-01-01T00:00:00Z") - val mockedAttrs = mockSftpAttrs(1704067200) - val entries = listOf( - mockLsEntry("cpa1.xml", mockedAttrs), - mockLsEntry("cpa2.xml", mockedAttrs) - ) - val mockedNFSConnector = mockNFSConnector(entries) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) + fun `should return true for XML file`() { + val lsEntry = mockLsEntry("nav.qass.12345.xml", "2024-01-01T00:00:00Z") + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNFSConnector) - coEvery { cpaRepoClient.getCPATimestamps() } returns cpaTimestampsFromDb + assertTrue(cpaSyncService.isXmlFileEntry(lsEntry)) + } - cpaSyncService.sync() + @Test + fun `should return false for invalid file type`() { + val lsEntry = mockLsEntry("nav.qass.12345.txt", "2024-01-01T00:00:00Z") + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNFSConnector) - coVerify(exactly = 0) { cpaRepoClient.putCPAinCPARepo(any(), any()) } - coVerify(exactly = 0) { cpaRepoClient.deleteCPAinCPARepo(any()) } + assertFalse(cpaSyncService.isXmlFileEntry(lsEntry)) } @Test - fun `sync should delete entry cpa2 from own database after it is gone from files`() = runBlocking { - val cpaTimestampsFromDb = mutableMapOf("cpa1" to "2024-01-01T00:00:00Z", "cpa2" to "2024-01-01T00:00:00Z") - val mockedAttrs = mockSftpAttrs(1704067200) - val entries = listOf(mockLsEntry("cpa1.xml", mockedAttrs)) - val mockedNFSConnector = mockNFSConnector(entries) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) + fun `should not send request if invalid file type`() = runBlocking { + val lsEntry = mockLsEntry("nav.qass.12345.txt", "2025-01-01T00:00:00Z") + val mockNfs = mockNfsFromEntries(listOf(lsEntry), listOf("nav:qass:12345")) - coEvery { cpaRepoClient.getCPATimestamps() } returns cpaTimestampsFromDb + mockCpaRepoFromMap(emptyMap()) + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) cpaSyncService.sync() - coVerify(exactly = 0) { cpaRepoClient.putCPAinCPARepo(any(), any()) } - coVerify(exactly = 1) { cpaRepoClient.deleteCPAinCPARepo("cpa2") } + coVerify(exactly = 0) { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } + coVerify(exactly = 0) { mockCpaRepoClient.deleteCPAinCPARepo(any()) } } @Test - fun `sync should insert new entry into our database after receiving it from files`() = runBlocking { - val cpaTimestampsFromDb = mutableMapOf("cpa1" to "2024-01-01T00:00:00Z") - val mockedAttrs = mockSftpAttrs(1704067200) - val entries = listOf( - mockLsEntry("cpa1.xml", mockedAttrs), - mockLsEntry("cpa2.xml", mockedAttrs) - ) - val mockedNFSConnector = mockNFSConnector(entries) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) + fun `should get cpaId from xml content`() = runBlocking { + val lsEntry = mockLsEntry("nav.qass.12345.xml", "2025-01-01T00:00:00Z") + val mockNfs = mockNfsFromEntries(listOf(lsEntry), listOf("nav:qass:12345")) - coEvery { cpaRepoClient.getCPATimestamps() } returns cpaTimestampsFromDb + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + val nfsCpa = cpaSyncService.getNfsCpa(mockNfs, lsEntry) - cpaSyncService.sync() + assertEquals("nav:qass:12345", nfsCpa.id) + } - coVerify(exactly = 1) { - cpaRepoClient.putCPAinCPARepo( - "simulated file content for /outbound/cpa/cpa2.xml", - any() - ) + @Test + fun `should find cpaId from an actual CPA file`() = runBlocking { + val lsEntry = mockLsEntry("nav.qass.12345.txt", "2025-01-01T00:00:00Z") + val mockNfs: NFSConnector = mockk { + every { folder() } returns Vector().apply { add(lsEntry) } + every { file(any()) } returns File(ClassLoader.getSystemResource("cpa/nav.qass.12345.xml").file).inputStream() + every { close() } just Runs } - coVerify(exactly = 0) { cpaRepoClient.deleteCPAinCPARepo(any()) } + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + val nfsCpa = cpaSyncService.getNfsCpa(mockNfs, lsEntry) + + assertEquals("nav:qass:12345", nfsCpa.id) } @Test - fun `sync should update existing entry into our database after it have been modified in files`() = runBlocking { - val lastModifiedDifferentThanFile = "2023-11-01T00:00:00Z" - val cpaTimestampsFromDb = - mutableMapOf("cpa1" to lastModifiedDifferentThanFile, "cpa2" to "2024-01-01T00:00:00Z") - val mockedAttrs = mockSftpAttrs(1704067200) - val entries = listOf( - mockLsEntry("cpa1.xml", mockedAttrs), - mockLsEntry("cpa2.xml", mockedAttrs) - ) - val mockedNFSConnector = mockNFSConnector(entries) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) - coEvery { cpaRepoClient.getCPATimestamps() } returns cpaTimestampsFromDb + fun `should throw exception if CPA ID is missing in content`() = runBlocking { + val lsEntry = mockLsEntry("nav.qass.missing.txt", "2025-01-01T00:00:00Z") + val mockNfs = mockNfsFromEntries(listOf(lsEntry), listOf("")) - cpaSyncService.sync() + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) - coVerify(exactly = 1) { - cpaRepoClient.putCPAinCPARepo( - "simulated file content for /outbound/cpa/cpa1.xml", - any() - ) + val exception = assertThrows { + cpaSyncService.getNfsCpa(mockNfs, lsEntry) } - coVerify(exactly = 0) { cpaRepoClient.deleteCPAinCPARepo(any()) } + + assertTrue(exception.message!!.contains("Regex to find CPA ID in file nav.qass.missing.txt did not find any match.")) } @Test - fun `sync should update an existing entry cpa1 and delete old entry cpa2 in database`() = runBlocking { - val lastModifiedDifferentThanFile = "2023-11-01T00:00:00Z" - val cpaTimestampsFromDb = - mutableMapOf("cpa1" to lastModifiedDifferentThanFile, "cpa2" to "2024-01-01T00:00:00Z") - val mockedAttrs = mockSftpAttrs(1704067200) - val entries = listOf( - mockLsEntry("cpa1.xml", mockedAttrs) - ) - val mockedNFSConnector = mockNFSConnector(entries) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) - coEvery { cpaRepoClient.getCPATimestamps() } returns cpaTimestampsFromDb + fun `nfs mTime conversion to db timestamp should be accurate`() { + val mTimeInSeconds = 1704067200L + val expectedTimestamp = "2024-01-01T00:00:00Z" - cpaSyncService.sync() + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNFSConnector) - coVerify(exactly = 1) { - cpaRepoClient.putCPAinCPARepo( - "simulated file content for /outbound/cpa/cpa1.xml", - any() - ) - } - coVerify(exactly = 1) { cpaRepoClient.deleteCPAinCPARepo("cpa2") } + val actualTimestamp = cpaSyncService.getLastModified(mTimeInSeconds) + + assert(expectedTimestamp == actualTimestamp) } @Test - fun `sync should insert new entry into our database only once`() = runBlocking { - val firstRunCpaTimestampsFromDb = mutableMapOf("cpa1" to "2024-01-01T00:00:00Z") - val secondRunCpaTimestampsFromDb = - mutableMapOf("cpa1" to "2024-01-01T00:00:00Z", "cpa2" to "2024-01-01T00:00:00Z") - var callCount = 0 + fun `zipping and unzipping should compress the file and return the same result`() { + val cpaFile = File(ClassLoader.getSystemResource("cpa/nav.qass.12345.xml").file).readText() - coEvery { cpaRepoClient.getCPATimestamps() } answers { - callCount++ - when (callCount) { - 1 -> firstRunCpaTimestampsFromDb - else -> secondRunCpaTimestampsFromDb - } - } + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNFSConnector) + + val zipped = cpaSyncService.zipCpaContent(cpaFile) + val unzipped = cpaSyncService.unzipCpaContent(zipped) + + assert(zipped.size < unzipped.toByteArray().size) + assert(cpaFile == unzipped) + } - val mockedAttrs = mockSftpAttrs(1704067200) - val entries = listOf( - mockLsEntry("cpa1.xml", mockedAttrs), - mockLsEntry("cpa2.xml", mockedAttrs) + @Test + fun `sync should abort if duplicate cpa IDs is found in nfs`() = runBlocking { + val lsEntries = listOf( + mockLsEntry("nav.qass.12345.xml", "2025-01-01T00:00:00Z"), + mockLsEntry("nav.qass.12345.xml", "2025-01-01T00:00:00Z") ) - val mockedNFSConnector = mockNFSConnector(entries) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) + val mockNfs = mockNfsFromEntries(lsEntries, listOf("nav:qass:12345", "nav:qass:12345")) + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + + val exception = assertThrows { + cpaSyncService.getNfsCpaMap() + } + + assertTrue(exception.message!!.contains("NFS contains duplicate CPA IDs. Aborting sync.")) + } + + @Test + fun `sync should do nothing when all entries match database`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) cpaSyncService.sync() + + coVerify(exactly = 0) { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } + coVerify(exactly = 0) { mockCpaRepoClient.deleteCPAinCPARepo(any()) } + } + + @Test + fun `sync should ignore entries when db timestamp is newer`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpa = mapOf("nav:qass:12345" to "2025-01-01T00:00:00Z") + + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) cpaSyncService.sync() + + coVerify(exactly = 0) { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } + coVerify(exactly = 0) { mockCpaRepoClient.deleteCPAinCPARepo(any()) } + } + + @Test + fun `sync should upsert when nfs timestamp is newer`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2025-01-01T00:00:00Z") + val dbCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) cpaSyncService.sync() + + coVerify(exactly = 1) { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } + } + + @Test + fun `sync should upsert when entry does not exist in db`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpa = emptyMap() + + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) cpaSyncService.sync() - coVerify(exactly = 1) { - cpaRepoClient.putCPAinCPARepo( - "simulated file content for /outbound/cpa/cpa2.xml", - any() - ) - } - coVerify(exactly = 0) { - cpaRepoClient.putCPAinCPARepo( - eq("simulated file content for /outbound/cpa/cpa1.xml"), - any() - ) - } - coVerify(exactly = 1) { - cpaRepoClient.putCPAinCPARepo( - eq("simulated file content for /outbound/cpa/cpa2.xml"), - any() - ) - } + coVerify(exactly = 1) { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } } @Test - fun `shouldSkipFile should return false (not skip) if the filename is not contained in mutable map`() { - val filename = "cpa1.xml" - val lastModified = Instant.parse("2024-01-01T00:00:00Z") - val cpaTimestamps = mutableMapOf("cpa2" to "2023-12-31T23:59:59Z", "cpa3" to "2023-11-30T23:59:59Z") - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = spyk(CpaSyncService(cpaRepoClient, mockedNFSConnector)) + fun `sync should only delete entries that are stale`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpa = mapOf( + "nav:qass:12345" to "2024-01-01T00:00:00Z", + "nav:qass:67890" to "2024-01-01T00:00:00Z" + ) + + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) - val shouldSkip = cpaSyncService.shouldSkipFile(filename, lastModified, cpaTimestamps) + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + cpaSyncService.sync() - assertFalse(shouldSkip) + coVerify(exactly = 1) { mockCpaRepoClient.deleteCPAinCPARepo("nav:qass:67890") } } @Test - fun `shouldSkipFile should return true (skip) if the filename is found and we have a matching timestamp`() { - val filename = "nav.10086.xml" - val lastModified = Instant.parse("2022-12-30T20:14:50Z") - val cpaTimestamps = mutableMapOf("nav:10086" to "2022-12-30T20:14:50Z") - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = spyk(CpaSyncService(cpaRepoClient, mockedNFSConnector)) + fun `sync should delete and upsert in same sync`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpa = mapOf("nav:qass:67890" to "2024-01-01T00:00:00Z") - val shouldSkip = cpaSyncService.shouldSkipFile(filename, lastModified, cpaTimestamps) + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) - assertTrue(shouldSkip) + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + cpaSyncService.sync() + + coVerify(exactly = 1) { mockCpaRepoClient.putCPAinCPARepo(any(), any()) } + coVerify(exactly = 1) { mockCpaRepoClient.deleteCPAinCPARepo("nav:qass:67890") } } @Test - fun `shouldSkipFile should return true (skip) if the filename is contained in mutable map`() { - val filename = "cpa1.xml" - val lastModified = Instant.parse("2024-01-01T00:00:00Z") - val cpaTimestamps = mutableMapOf("cpa1" to "2024-01-01T00:00:00Z", "cpa2" to "2023-12-31T23:59:59Z") - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = spyk(CpaSyncService(cpaRepoClient, mockedNFSConnector)) + fun `sync should upsert correct CPA content`() = runBlocking { + val nfsCpa = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpa = emptyMap() + + val mockNfs = mockNfsFromMap(nfsCpa) + mockCpaRepoFromMap(dbCpa) - val shouldSkip = cpaSyncService.shouldSkipFile(filename, lastModified, cpaTimestamps) + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + cpaSyncService.sync() + + val expectedFileContent = """ + + + + + """.trimIndent() - assertTrue(shouldSkip) + coVerify(exactly = 1) { + mockCpaRepoClient.putCPAinCPARepo(expectedFileContent, "2024-01-01T00:00:00Z") + } } @Test - fun `deleteStaleCpaEntries should delete remaining timestamps`() = runBlocking { - val cpaTimestamps = mutableMapOf("cpa1" to "2024-01-01T00:00:00Z") - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = spyk(CpaSyncService(cpaRepoClient, mockedNFSConnector)) + fun `multiple syncs should persist CPA only once`() = runBlocking { + val lsEntry = mockLsEntry("nav.qass.12345.xml", "2025-01-01T00:00:00Z") + val mockNfs: NFSConnector = mockk { + every { folder() } returns Vector().apply { add(lsEntry) } + every { file(any()) } answers { ByteArrayInputStream(simulateFileContent("nav:qass:12345").toByteArray()) } + every { close() } just Runs + } - cpaSyncService.deleteStaleCpaEntries(cpaTimestamps) + val dbCpaMapFirst = mapOf("nav:qass:12345" to "2024-01-01T00:00:00Z") + val dbCpaMapSecond = mapOf("nav:qass:12345" to "2025-01-01T00:00:00Z") - coVerify { cpaRepoClient.deleteCPAinCPARepo("cpa1") } + var callCount = 0 + coEvery { mockCpaRepoClient.getCPATimestamps() } answers { + callCount++ + when (callCount) { + 1 -> dbCpaMapFirst + else -> dbCpaMapSecond + } + } + + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNfs) + + cpaSyncService.sync() + cpaSyncService.sync() + cpaSyncService.sync() + + coVerify(exactly = 1) { + mockCpaRepoClient.putCPAinCPARepo(any(), any()) + } + coVerify(exactly = 0) { + mockCpaRepoClient.deleteCPAinCPARepo(any()) + } + } + + @Test + fun `upsert check should return true if nfs timestamp is newer than db timestamp`() { + val cpaSyncService = CpaSyncService(mockCpaRepoClient, mockNFSConnector) + + assertTrue { cpaSyncService.shouldUpsertCpa("2025-01-01T00:00:00Z", null) } + assertTrue { cpaSyncService.shouldUpsertCpa("2025-01-01T00:00:00Z", "2024-01-01T00:00:00Z") } + assertFalse { cpaSyncService.shouldUpsertCpa("2024-01-01T00:00:00Z", "2025-01-01T00:00:00Z") } + assertFalse { cpaSyncService.shouldUpsertCpa("2024-01-01T00:00:00Z", "2024-01-01T00:00:00Z") } } @Test fun `sync should handle SftpException`() = runBlocking { val expectedSftpException = SftpException(4, "SFTP error") - coEvery { cpaRepoClient.getCPATimestamps() } throws expectedSftpException - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = spyk(CpaSyncService(cpaRepoClient, mockedNFSConnector)) + coEvery { mockCpaRepoClient.getCPATimestamps() } throws expectedSftpException + val mockedNFSConnector = mockNfsFromMap(emptyMap()) + val cpaSyncService = spyk(CpaSyncService(mockCpaRepoClient, mockedNFSConnector)) val resultException = assertFailsWith { cpaSyncService.sync() @@ -267,10 +333,10 @@ class CpaSyncServiceTest { @Test fun `sync should handle a generic exception`() = runBlocking { val expectedException = Exception("generic error") - coEvery { cpaRepoClient.getCPATimestamps() } throws expectedException + coEvery { mockCpaRepoClient.getCPATimestamps() } throws expectedException - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = spyk(CpaSyncService(cpaRepoClient, mockedNFSConnector)) + val mockedNFSConnector = mockNfsFromMap(emptyMap()) + val cpaSyncService = spyk(CpaSyncService(mockCpaRepoClient, mockedNFSConnector)) val resultException = assertFailsWith { cpaSyncService.sync() @@ -280,31 +346,44 @@ class CpaSyncServiceTest { verify { cpaSyncService.logFailure(expectedException) } } - @Test - fun `mTime to seconds should be accurate`() { - val mTimeInSeconds = 1686480930L - val expectedInstant = Instant.parse("2023-06-11T10:55:30Z") + private fun mockCpaRepoFromMap(dbCpaMap: Map) { + coEvery { mockCpaRepoClient.getCPATimestamps() } returns dbCpaMap + } - val mockedNFSConnector = mockNFSConnector(emptyList()) - cpaSyncService = CpaSyncService(cpaRepoClient, mockedNFSConnector) + private fun mockNfsFromMap(nfsCpaMap: Map): NFSConnector { + val lsEntries = nfsCpaMap.map { mockLsEntry(createFilename(it.key), it.value) } - val resultInstant = cpaSyncService.getLastModifiedInstant(mTimeInSeconds) + return mockNfsFromEntries(lsEntries, nfsCpaMap.keys.toList()) + } - assert(expectedInstant == resultInstant) + private fun mockNfsFromEntries(lsEntries: List, nfsCpaIds: List): NFSConnector { + return mockk { + every { folder() } returns Vector().apply { addAll(lsEntries) } + every { file(any()) } returnsMany nfsCpaIds.map { ByteArrayInputStream(simulateFileContent(it).toByteArray()) } + every { close() } just Runs + } } - private fun mockSftpAttrs(mTime: Int): SftpATTRS = mockk { - every { this@mockk.mTime } returns mTime + private fun mockLsEntry(entryName: String, timestamp: String): ChannelSftp.LsEntry = + mockk { + every { filename } returns entryName + every { attrs } returns mockSftpAttrs(timestamp) + } + + private fun mockSftpAttrs(timestamp: String): SftpATTRS = mockk { + every { mTime } returns Instant.parse(timestamp).epochSecond.toInt() } - private fun mockLsEntry(filename: String, attrs: SftpATTRS): ChannelSftp.LsEntry = mockk { - every { this@mockk.filename } returns filename - every { this@mockk.attrs } returns attrs + private fun createFilename(cpaId: String): String { + return "${cpaId.replace(":", ".")}.xml" } - private fun mockNFSConnector(entries: List): NFSConnector = mockk { - every { folder() } returns Vector().apply { addAll(entries) } - every { file(any()) } answers { ByteArrayInputStream("simulated file content for ${it.invocation.args[0]}".toByteArray()) } - every { close() } just Runs + private fun simulateFileContent(cpaId: String): String { + return """ + + + + + """.trimIndent() } } From 6296165965cbb5a27513dc18f0109c360320971d Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 10:50:55 +0200 Subject: [PATCH 16/30] KTlintfix --- .../kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt index 8da03a74..57b8d2e9 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt @@ -1,5 +1,7 @@ package no.nav.emottak.utbetaling +import no.kith.xmlstds.msghead._2006_05_24.CS +import no.kith.xmlstds.msghead._2006_05_24.ConversationRef import no.kith.xmlstds.msghead._2006_05_24.Document import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.kith.xmlstds.msghead._2006_05_24.RefDoc @@ -18,13 +20,13 @@ class MsgHeadUtil { return msgHead.apply { msgInfo.apply { - type.apply { + type = CS().apply { dn = "Svar på forespørsel om inntekt" v = "InntektInformasjon" } genDate = Instant.now().toXMLGregorianCalendar() msgId = UUID.randomUUID().toString() - ack.apply { + ack = CS().apply { v = "N" dn = "Nei" } @@ -32,7 +34,7 @@ class MsgHeadUtil { val newSender = receiver sender.apply { organisation = newSender.organisation } receiver.apply { organisation = newReceiver.organisation } - conversationRef.apply { + conversationRef = ConversationRef().apply { refToParent = sendInRequest.messageId refToConversation = sendInRequest.conversationId } @@ -40,8 +42,8 @@ class MsgHeadUtil { document.clear() document.add( Document().apply { - refDoc.apply { - msgType.apply { + refDoc = RefDoc().apply { + msgType = CS().apply { v = "XML" dn = "XML-instans" } From f329ff0ed65aed459dd411dd4128205cb3572163 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 12:21:11 +0200 Subject: [PATCH 17/30] Add list fix --- ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt | 2 +- .../src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt | 2 +- .../src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index c5c6807e..dda3202f 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -107,7 +107,7 @@ fun Application.ebmsSendInModule() { request.messageId, request.conversationId, request.addressing.replyTo(request.addressing.service, request.addressing.action), // TODO ser feil ut? - utbetalingXmlMarshaller.marshal(it).toByteArray() + utbetalingXmlMarshaller.marshalToByteArray(it) ) ) is FrikortsporringResponse -> diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt index 57b8d2e9..c214f6a6 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt @@ -50,7 +50,7 @@ class MsgHeadUtil { mimeType = "text/xml" content = RefDoc.Content().apply { any.add( - listOf(String(fagmeldingResponse, StandardCharsets.UTF_8)) + String(fagmeldingResponse, StandardCharsets.UTF_8) ) } } diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt index acc9c92a..3b39fee8 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/XmlMarshaller.kt @@ -20,6 +20,7 @@ class XmlMarshaller { FinnUtbetalingListeRequest::class.java, FinnBrukersUtbetalteYtelserRequest::class.java, FinnUtbetalingListe::class.java, + org.oasis_open.committees.ebxml_cppa.schema.cpp_cpa_2_0.ObjectFactory::class.java, no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.meldinger.v1.ObjectFactory::class.java, no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.feil.v1.ObjectFactory::class.java, no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory::class.java, From 64ec3738640fcd69b2002b87b728adce38ce0822 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 13:03:13 +0200 Subject: [PATCH 18/30] add bytearray --- .../src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt index c214f6a6..196c43d5 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt @@ -7,7 +7,6 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.kith.xmlstds.msghead._2006_05_24.RefDoc import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.util.toXMLGregorianCalendar -import java.nio.charset.StandardCharsets import java.time.Instant import java.util.UUID @@ -50,7 +49,7 @@ class MsgHeadUtil { mimeType = "text/xml" content = RefDoc.Content().apply { any.add( - String(fagmeldingResponse, StandardCharsets.UTF_8) + fagmeldingResponse ) } } From 21267b283827abf40648cc58c0408e0b8f1fccc3 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 13:31:25 +0200 Subject: [PATCH 19/30] Wrap feil-elemnt --- .../no/nav/emottak/utbetaling/MsgHeadUtil.kt | 2 +- .../emottak/utbetaling/UtbetalingClient.kt | 39 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt index 196c43d5..7b3ffdc6 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt @@ -12,7 +12,7 @@ import java.util.UUID class MsgHeadUtil { - fun msgHeadResponse(sendInRequest: SendInRequest, fagmeldingResponse: ByteArray): MsgHead { + fun msgHeadResponse(sendInRequest: SendInRequest, fagmeldingResponse: Any): MsgHead { val msgHead: MsgHead = utbetalingXmlMarshaller .unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 302e4734..0917a0dc 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -5,6 +5,7 @@ import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnBrukersUtbe import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBaksystemIkkeTilgjengelig import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBrukerIkkeFunnet +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeFeil import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeIngenTilgangTilEnEllerFlereYtelser import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeUgyldigDato import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeUgyldigKombinasjonBrukerIdOgBrukertype @@ -32,7 +33,7 @@ class InntektsForesporselClient { } val UTBETAL_SOAP_ENDPOINT = RESOLVED_UTBETAL_URL + "/Utbetaling" - fun behandleInntektsforesporsel(payloadBytes: ByteArray): ByteArray { + fun behandleInntektsforesporsel(payloadBytes: ByteArray): Any { val msgHead = utbetalingXmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) val melding = msgHead.document.map { it.refDoc.content.any } .also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } @@ -46,27 +47,21 @@ class InntektsForesporselClient { return marshal(response).toByteArray() } catch (utbetalError: Throwable) { log.info("Handling inntektsforesporsel error: " + utbetalError.message) - return utbetalingXmlMarshaller.marshalToByteArray( - when (utbetalError) { - is FinnUtbetalingListeBrukerIkkeFunnet - -> utbetalingObjectFactory - .createFinnUtbetalingListebrukerIkkeFunnet(utbetalError.faultInfo) - is FinnUtbetalingListeBaksystemIkkeTilgjengelig - -> utbetalingObjectFactory - .createFinnUtbetalingListebaksystemIkkeTilgjengelig(utbetalError.faultInfo) - is FinnUtbetalingListeIngenTilgangTilEnEllerFlereYtelser - -> utbetalingObjectFactory - .createFinnUtbetalingListeingenTilgangTilEnEllerFlereYtelser(utbetalError.faultInfo) - is FinnUtbetalingListeUgyldigDato - -> utbetalingObjectFactory - .createFinnUtbetalingListeugyldigDato(utbetalError.faultInfo) - is FinnUtbetalingListeUgyldigKombinasjonBrukerIdOgBrukertype - -> utbetalingObjectFactory - .createFinnUtbetalingListeugyldigKombinasjonBrukerIdOgBrukertype(utbetalError.faultInfo) - else -> - throw utbetalError.also { log.error("Ukjent feiltype: " + it.message, it) } - } - ) + val feil = FinnUtbetalingListeFeil() + return when (utbetalError) { + is FinnUtbetalingListeBrukerIkkeFunnet + -> feil.finnUtbetalingListebrukerIkkeFunnet = utbetalError.faultInfo + is FinnUtbetalingListeBaksystemIkkeTilgjengelig + -> feil.finnUtbetalingListebaksystemIkkeTilgjengelig = utbetalError.faultInfo + is FinnUtbetalingListeIngenTilgangTilEnEllerFlereYtelser + -> feil.finnUtbetalingListeingenTilgangTilEnEllerFlereYtelser = utbetalError.faultInfo + is FinnUtbetalingListeUgyldigDato + -> feil.finnUtbetalingListeugyldigDato = utbetalError.faultInfo + is FinnUtbetalingListeUgyldigKombinasjonBrukerIdOgBrukertype + -> feil.finnUtbetalingListeugyldigKombinasjonBrukerIdOgBrukertype = utbetalError.faultInfo + else -> + throw utbetalError.also { log.error("Ukjent feiltype: " + it.message, it) } + } } } } From 5b88be869c8b00154dd38d240e9a3a740da5b45e Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 15:05:41 +0200 Subject: [PATCH 20/30] Fixed return statement --- .../emottak/utbetaling/UtbetalingClient.kt | 5 +- .../test/kotlin/InntektsforesporselTest.kt | 148 ++++++++++++++++-- 2 files changed, 135 insertions(+), 18 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index 0917a0dc..b2f23c93 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -44,11 +44,11 @@ class InntektsForesporselClient { is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) else -> throw IllegalStateException("Ukjent meldingstype. Classname: " + melding.javaClass.name) } - return marshal(response).toByteArray() + return marshal(response) } catch (utbetalError: Throwable) { log.info("Handling inntektsforesporsel error: " + utbetalError.message) val feil = FinnUtbetalingListeFeil() - return when (utbetalError) { + when (utbetalError) { is FinnUtbetalingListeBrukerIkkeFunnet -> feil.finnUtbetalingListebrukerIkkeFunnet = utbetalError.faultInfo is FinnUtbetalingListeBaksystemIkkeTilgjengelig @@ -62,6 +62,7 @@ class InntektsForesporselClient { else -> throw utbetalError.also { log.error("Ukjent feiltype: " + it.message, it) } } + return feil } } } diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index a8333205..82c4329a 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -1,12 +1,17 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead -import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.feil.v1.BrukerIkkeFunnet import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.feil.v1.ObjectFactory import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBrukerIkkeFunnet +import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeFeil +import no.nav.emottak.melding.model.Addressing +import no.nav.emottak.melding.model.EbmsProcessing +import no.nav.emottak.melding.model.Party +import no.nav.emottak.melding.model.PartyId +import no.nav.emottak.melding.model.SendInRequest +import no.nav.emottak.utbetaling.MsgHeadUtil import no.nav.emottak.utbetaling.unmarshal import no.nav.emottak.utbetaling.utbetalingXmlMarshaller import org.junit.jupiter.api.Test -import kotlin.reflect.full.memberFunctions class InntektsforesporselTest { @@ -27,21 +32,132 @@ class InntektsforesporselTest { fun canMarshalFaultInfo() { val stelvioFault = ObjectFactory().createBrukerIkkeFunnet() stelvioFault.errorMessage = "Ayylmaoo" - val brukerIkkeFunnetException: Exception = FinnUtbetalingListeBrukerIkkeFunnet("Ayylmaoo", stelvioFault) - val createFinnBrukersUtbetalteYtelserbrukerIkkeFunnet = - no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory() - .createFinnBrukersUtbetalteYtelserbrukerIkkeFunnet( - with(brukerIkkeFunnetException) { - this::class.memberFunctions - .find { func -> func.name == "getFaultInfo" }!! - .call(this) as BrukerIkkeFunnet - } - ) + val brukerIkkeFunnetException = FinnUtbetalingListeBrukerIkkeFunnet("Ayylmaoo", stelvioFault) - println( - String( - utbetalingXmlMarshaller.marshalToByteArray(createFinnBrukersUtbetalteYtelserbrukerIkkeFunnet) - ) + val finnUtbetalingListeFeil = FinnUtbetalingListeFeil() + finnUtbetalingListeFeil.finnUtbetalingListebrukerIkkeFunnet = brukerIkkeFunnetException.faultInfo + + val msgHeadResponse = MsgHeadUtil().msgHeadResponse( + SendInRequest( + "my-message-id", + "my-conversation-id", + "my-payload-id", + msgHeadEksempel.toByteArray(), + Addressing( + Party(listOf(PartyId("org", "12345")), "mottaker"), + Party(listOf(PartyId("org", "67890")), "innsender"), + "Inntektsforesporsel", + "Inntektsforesporsel" + ), + EbmsProcessing() + ), + finnUtbetalingListeFeil ) + + val feilElementString = String( + utbetalingXmlMarshaller.marshalToByteArray(msgHeadResponse) + ) + println(feilElementString) } + + val msgHeadEksempel = "\n" + + "\n" + + " \n" + + " \n" + + " v1.2 2006-05-24\n" + + " 2024-06-17T08:31:10\n" + + " 309c5972-b5be-4b60-b172-094c5d236713\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Tromsø kommune\n" + + " \n" + + " \n" + + " 940101808\n" + + " \n" + + " \n" + + " \n" + + " 1234\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " Økonomi og oppgjør\n" + + " \n" + + " 12345\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + " NAV Pensjon\n" + + " \n" + + " 889640782\n" + + " \n" + + " \n" + + " \n" + + " 12345\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Nordmann\n" + + " Ola\n" + + " \n" + + " 12345678965\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " Veigaten 1\n" + + " 1234\n" + + " OSLO\n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 12345678965\n" + + " PERSON\n" + + " \n" + + " KOMMUNE\n" + + " \n" + + " 2024-06-01\n" + + " 2024-06-12\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
" } From a89c4071d7a4884af6b81bd769bd8ddaa50d046d Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Tue, 10 Sep 2024 16:10:35 +0200 Subject: [PATCH 21/30] Fix Action --- ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index dda3202f..975e1936 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -106,7 +106,7 @@ fun Application.ebmsSendInModule() { SendInResponse( request.messageId, request.conversationId, - request.addressing.replyTo(request.addressing.service, request.addressing.action), // TODO ser feil ut? + request.addressing.replyTo(request.addressing.service, "InntektInformasjon"), // TODO ser feil ut? utbetalingXmlMarshaller.marshalToByteArray(it) ) ) From 27c2234fe39b4b27c2ab7410ff813a111ff30045 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 10:01:11 +0200 Subject: [PATCH 22/30] Mimeencoder --- ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt index 6ef933f6..60a7060e 100644 --- a/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -285,7 +285,7 @@ suspend fun ApplicationCall.respondEbmsDokument(ebmsDokument: EbMSDocument) { ebmsDokument.attachments.first().let { PartData.FormItem( // Base64.getMimeEncoder().encodeToString(it.bytes), // Implicit ISO_8859_1 - String(Base64.getEncoder().encode(it.bytes), StandardCharsets.UTF_8), // TODO verifiser + String(Base64.getMimeEncoder().encode(it.bytes), StandardCharsets.UTF_8), // TODO verifiser {}, HeadersBuilder().apply { append(MimeHeaders.CONTENT_TRANSFER_ENCODING, "base64") From 9ff0fea64e85501c9873fcf61ada91cc78fd6b5e Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 10:10:18 +0200 Subject: [PATCH 23/30] Marshal to bytearray --- .../src/main/kotlin/no/nav/emottak/ebms/App.kt | 4 ++-- .../emottak/fellesformat/FellesFormatWrapper.kt | 4 ++-- .../no/nav/emottak/frikort/FrikortClient.kt | 2 +- .../no/nav/emottak/frikort/XmlMarshaller.kt | 16 +++++++++++++--- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index 975e1936..c34df855 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -25,8 +25,8 @@ import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.emottak.auth.AZURE_AD_AUTH import no.nav.emottak.auth.AuthConfig import no.nav.emottak.fellesformat.wrapMessageInEIFellesFormat +import no.nav.emottak.frikort.frikortXmlMarshaller import no.nav.emottak.frikort.frikortsporring -import no.nav.emottak.frikort.marshal import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.melding.model.SendInResponse import no.nav.emottak.utbetaling.InntektsForesporselClient @@ -119,7 +119,7 @@ fun Application.ebmsSendInModule() { it.eiFellesformat.mottakenhetBlokk.ebService, it.eiFellesformat.mottakenhetBlokk.ebAction ), - marshal(it.eiFellesformat.msgHead).toByteArray() + frikortXmlMarshaller.marshalToByteArray(it.eiFellesformat.msgHead) ) ) } diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/fellesformat/FellesFormatWrapper.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/fellesformat/FellesFormatWrapper.kt index 638ac056..7f61edf9 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/fellesformat/FellesFormatWrapper.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/fellesformat/FellesFormatWrapper.kt @@ -2,8 +2,8 @@ package no.nav.emottak.fellesformat import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.emottak.ebms.log +import no.nav.emottak.frikort.frikortXmlMarshaller import no.nav.emottak.frikort.unmarshal -import no.nav.emottak.frikort.xmlMarshaller import no.nav.emottak.melding.model.Addressing import no.nav.emottak.melding.model.Party import no.nav.emottak.melding.model.PartyId @@ -32,7 +32,7 @@ fun wrapMessageInEIFellesFormat(sendInRequest: SendInRequest): EIFellesformat = it.msgHead = unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) }.also { if (getEnvVar("NAIS_CLUSTER_NAME", "local") != "prod-fss") { - log.info("Sending in request to frikort with body " + xmlMarshaller.marshal(it)) + log.info("Sending in request to frikort with body " + frikortXmlMarshaller.marshal(it)) } } diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/FrikortClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/FrikortClient.kt index c21a33fc..3a9cbb75 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/FrikortClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/FrikortClient.kt @@ -26,6 +26,6 @@ fun frikortsporring(fellesformat: EIFellesformat): FrikortsporringResponse = fri frikortObjectFactory.createFrikortsporringRequest().also { it.eiFellesformat = fellesformat } ).also { if (getEnvVar("NAIS_CLUSTER_NAME", "local") != "prod-fss") { - log.info("Send in Frikort response " + xmlMarshaller.marshal(it)) + log.info("Send in Frikort response " + frikortXmlMarshaller.marshal(it)) } } diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt index 9649c6c7..e5480d5a 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt @@ -1,13 +1,14 @@ package no.nav.emottak.frikort +import java.io.ByteArrayOutputStream import java.io.StringWriter import javax.xml.bind.JAXBContext import javax.xml.stream.XMLInputFactory -val xmlMarshaller = XmlMarshaller() +val frikortXmlMarshaller = XmlMarshaller() -fun marshal(objekt: Any) = xmlMarshaller.marshal(objekt) -fun unmarshal(xml: String, clazz: Class): T = xmlMarshaller.unmarshal(xml, clazz) +fun marshal(objekt: Any) = frikortXmlMarshaller.marshal(objekt) +fun unmarshal(xml: String, clazz: Class): T = frikortXmlMarshaller.unmarshal(xml, clazz) class XmlMarshaller { @@ -36,6 +37,15 @@ class XmlMarshaller { return writer.toString() } + fun marshalToByteArray(objekt: Any): ByteArray { + return ByteArrayOutputStream().use { + synchronized(no.nav.emottak.utbetaling.XmlMarshaller.marshlingMonitor) { + no.nav.emottak.utbetaling.XmlMarshaller.marshaller.marshal(objekt, it) + } + it.toByteArray() + } + } + fun unmarshal(xml: String, clazz: Class): T { val reader = XMLInputFactory.newInstance().createXMLStreamReader(xml.reader()) return synchronized(unmarshlingMonitor) { From 270a7e0791f2eaa873e310be8b4892f2fd6db326 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 10:13:45 +0200 Subject: [PATCH 24/30] Marshal to bytearray --- .../src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt index e5480d5a..2975944d 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt @@ -40,7 +40,7 @@ class XmlMarshaller { fun marshalToByteArray(objekt: Any): ByteArray { return ByteArrayOutputStream().use { synchronized(no.nav.emottak.utbetaling.XmlMarshaller.marshlingMonitor) { - no.nav.emottak.utbetaling.XmlMarshaller.marshaller.marshal(objekt, it) + marshaller.marshal(objekt, it) } it.toByteArray() } From bc1ead53225150963ce9d5dac269e8c68c73b19f Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 10:21:34 +0200 Subject: [PATCH 25/30] Marshal to bytearray --- .../src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt index 2975944d..42c9c260 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/frikort/XmlMarshaller.kt @@ -39,7 +39,7 @@ class XmlMarshaller { fun marshalToByteArray(objekt: Any): ByteArray { return ByteArrayOutputStream().use { - synchronized(no.nav.emottak.utbetaling.XmlMarshaller.marshlingMonitor) { + synchronized(marshlingMonitor) { marshaller.marshal(objekt, it) } it.toByteArray() From 51d77a4b48fa2cce2c962a6f42382227388df0e9 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 10:58:23 +0200 Subject: [PATCH 26/30] Fjerner ubrukt fil --- .../resources/inntektsforesporsel/SOAPrequest | 116 ------------------ 1 file changed, 116 deletions(-) delete mode 100644 ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest diff --git a/ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest b/ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest deleted file mode 100644 index 581bd258..00000000 --- a/ebms-send-in/src/test/resources/inntektsforesporsel/SOAPrequest +++ /dev/null @@ -1,116 +0,0 @@ -SOAPAction:"ebXML"\r\nX-Request-ID:275622fe2d19beb72b1fcef649454f9c\r\nX-Original-Forwarded-For:10.49.1.253\r\nX-Forwarded-Host:ebms-sync-router.dev.intern.nav.no:443\r\nX-Forwarded-Proto:https\r\nHost:ebms-sync-router.dev.intern.nav.no:443\r\norigHost:nhn-gw-q.nav.no:9443\r\nContent-Transfer-Encoding:8bit\r\nX-Global-Transaction-ID:da10915d667aac0901282273\r\nX-Forwarded-Port:443\r\nX-Client-IP:10.48.65.200\r\nVia:1.1 XMLFW-emottak-ebxml\r\nX-Forwarded-For:10.49.1.253\r\nContent-Length:12948\r\nX-Real-IP:10.49.1.253\r\nX-Forwarded-Scheme:https\r\nX-Scheme:https\r\nContent-Type:multipart/related; boundary="----=_Part_22_77333660.1264086702625"; type="text/xml"; start=""\r\n - -------=_Part_22_77333660.1264086702625 -Content-Type: text/xml; charset=UTF-8 -Content-Transfer-Encoding: binary -Content-ID: - - -8138375Fordringshaver111949Ytelsesutbetalernav:qass:308232b99d7a7-d70d-4dd2-8869-3448fd7df6bbInntektsforesporselForesporsel15552ce2-67e8-415f-a536-99c323cdea532024-06-25T13:37:45sI0z2uKiVArIF/hoCJK708KoJm0=K+a/pYe9VeySvC53uaCXs9omFtU=YFH5NzQDXZv0fp+NlptPHZxq6i4P2kqp+cDPs8mpB2280Rze5NmDrx7UO4uMYZiylEc0Ckp/bWfGotoT35oZeld0vyKqXdZW1aCoiHuM+krkVmY9JJxao6jZdT8LYCZBsVd6DkKKDOHQgjHd58GupcR0jeRShP7OVMlBR1XHh8oKIBIsvpHyrzuGwqYm4d5lBDtXReFCth06PNgTvOfoGuQzFzZpnqcA7a00dPcwleXjVllzlG6+M2BOsEGPKzwUkI2REigxsZMTg6Gtj2rzQyLtfpctru1wfr3VtYJGnGXBwzklAAzTUAkdpSVS2DAsWXLu95Xs1RRKedTo4YW++cox7dkhCIQc8NzoGDithSpaERtg9df8s4VUXbDHGzlJwmZS5xmbYfQdjtkJsHz91CKBRBO5UC6pGJqV7y8p2kVkrzAIvhCRrZyftnN+wbyGsR7aVNas2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p8jFqV2UOR8nNMDSP8JWDlhJr+cAtmC+0bevGfjl -------=_Part_22_77333660.1264086702625 -Content-Type: text/xml -Content-ID: -Content-Transfer-Encoding: base64 - -MIIWXAYJKoZIhvcNAQcDoIIWTTCCFkkCAQAxggIZMIICFQIBADB9MG4xCzAJBgNVBAYTAk5PMRgw -FgYDVQRhDA9OVFJOTy05ODMxNjMzMjcxEzARBgNVBAoMCkJ1eXBhc3MgQVMxMDAuBgNVBAMMJ0J1 -eXBhc3MgQ2xhc3MgMyBUZXN0NCBDQSBHMiBTVCBCdXNpbmVzcwILAZUu998EpC5cTMkwDQYJKoZI -hvcNAQEBBQAEggGAJ1ZIrMf1v/lBmMdFRZO7K2F3q/dsp2bPSm/J0ujbIyueGlYw4nsFvCa9zXBy -ciO79vPLTBHTdkpgp8LVTd7H1eZiauthO40GaXkJs9y69s2fc1cYMhvY5DghjM70fLnPdFn7vpNd -zX1hYw7VX9n145ErJiXlsKhxF4fdPWLu7Qei73tPNI2+X5M+xycHj4NhpxAtOZi1B7t0X18XyaaL -Cdn0izbOoq/smDvXuJ75RGJIOESls6uG+Irycm80LqxnaNQI6N7snYKrQQVDmJSQMW+4OeFKZOYx -4vo7HguBXEawi073o9aL9ObwzFTWivPsjyWyKA/MdfPK7xQVvfLQEOfyioYCLtCOAHO4hoy9UV0i -0FahULNVBafYL0WN+MbZKDOriW+txC/jYjeq9vZMH7eB2RI1ohhQXHxymdFOtF3/oBPThFrEy8P9 -03WjbzfD1qyH0usJuKHl7uNruUZl2RKf+vQ2jsrqwVG+4hiqH9aFugXBvbxG8jcgRTmJbf9RMIIU -JQYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAjNkALW0aQZJ4CCFABOh/FWAi9kJSlKz7BpMd65lIvR -xBGW8tkBwRBRmJepsBTeH9V38QcqHtiX8P6f0sfoaKmDw5uvleuvpkSnLPd4II9zvn0vLK0Q20P5 -vAvDejbh7qa9NNB7/MdxHkW+DMtYtv87zWVRa2f5oQSa2PZcl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QG5wyFeyBmiSIs9FoxiCHQYE4TewDzd5KQZ71Lne -m6ptzORWAstQILzU8p+hz+6+WpOahvYriKJzcVI5h9fpUEZhFmztpgeycURcUwur6BMQWcPOESvM -JqSY13Hva+uwe7HYNkqKyl3bOtXrFgsH4kGM9/Xt/GkZjJtoY/pTKm5Hb7CQytTvk/nc6OJJCxQf -gyyQQoz8twPotVZtxnLbWw19qYH7MrdUXgwwf2G47z6PTlTpT42kI5rwU0MPL5xm2LJ3XwA4nZ0K -0lEzJe0ZRD0O0QGEUM133Eu/cP67VYSr1qvNCw+AqOe0bCwq6QyJI6fP50BrBAYawVu+wVoXB+Ex -6uYIcvr0LZONUOh0ktHqs4SzG51eaTr1D6LVgQ== -------=_Part_22_77333660.1264086702625-- \ No newline at end of file From 8ce4d77c8d0e1ed7914ddceffa7f5235a0263299 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 12:39:18 +0200 Subject: [PATCH 27/30] Fjerner todo --- ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index c34df855..e0a928da 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -106,7 +106,7 @@ fun Application.ebmsSendInModule() { SendInResponse( request.messageId, request.conversationId, - request.addressing.replyTo(request.addressing.service, "InntektInformasjon"), // TODO ser feil ut? + request.addressing.replyTo(request.addressing.service, "InntektInformasjon"), utbetalingXmlMarshaller.marshalToByteArray(it) ) ) From c104744845885f0ffba176864f910179fc628f63 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 14:24:48 +0200 Subject: [PATCH 28/30] Refactor litt sendin app --- .../main/kotlin/no/nav/emottak/ebms/App.kt | 52 +++++------- .../no/nav/emottak/utbetaling/MsgHeadUtil.kt | 83 +++++++++---------- .../emottak/utbetaling/UtbetalingClient.kt | 11 +-- .../test/kotlin/InntektsforesporselTest.kt | 4 +- 4 files changed, 68 insertions(+), 82 deletions(-) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index e0a928da..25a6668d 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -21,7 +21,6 @@ import io.micrometer.prometheus.PrometheusConfig import io.micrometer.prometheus.PrometheusMeterRegistry import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import no.kith.xmlstds.msghead._2006_05_24.MsgHead import no.nav.emottak.auth.AZURE_AD_AUTH import no.nav.emottak.auth.AuthConfig import no.nav.emottak.fellesformat.wrapMessageInEIFellesFormat @@ -30,12 +29,10 @@ import no.nav.emottak.frikort.frikortsporring import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.melding.model.SendInResponse import no.nav.emottak.utbetaling.InntektsForesporselClient -import no.nav.emottak.utbetaling.MsgHeadUtil import no.nav.emottak.utbetaling.utbetalingXmlMarshaller import no.nav.emottak.util.getEnvVar import no.nav.emottak.util.marker import no.nav.security.token.support.v2.tokenValidationSupport -import no.nav.tjeneste.ekstern.frikort.v1.types.FrikortsporringResponse import org.slf4j.LoggerFactory internal val log = LoggerFactory.getLogger("no.nav.emottak.ebms.App") @@ -74,7 +71,6 @@ fun Application.ebmsSendInModule() { } routing { - val inntektsForesporselClient = InntektsForesporselClient() authenticate(AZURE_AD_AUTH) { post("/fagmelding/synkron") { val request = this.call.receive(SendInRequest::class) @@ -84,14 +80,28 @@ fun Application.ebmsSendInModule() { when (request.addressing.service) { "Inntektsforesporsel" -> timed(appMicrometerRegistry, "Inntektsforesporsel") { - MsgHeadUtil().msgHeadResponse( - request, - inntektsForesporselClient.behandleInntektsforesporsel(request.payload) - ) + InntektsForesporselClient.behandleInntektsforesporsel(request).let { + SendInResponse( + request.messageId, + request.conversationId, + request.addressing.replyTo(request.addressing.service, it.msgInfo.type.v), + utbetalingXmlMarshaller.marshalToByteArray(it) + ) + } } else -> timed(appMicrometerRegistry, "frikort-sporing") { - frikortsporring(wrapMessageInEIFellesFormat(request)) + frikortsporring(wrapMessageInEIFellesFormat(request)).let { + SendInResponse( + request.messageId, + request.conversationId, + request.addressing.replyTo( + it.eiFellesformat.mottakenhetBlokk.ebService, + it.eiFellesformat.mottakenhetBlokk.ebAction + ), + frikortXmlMarshaller.marshalToByteArray(it.eiFellesformat.msgHead) + ) + } } } } @@ -100,29 +110,7 @@ fun Application.ebmsSendInModule() { request.marker(), "Payload ${request.payloadId} videresending til fagsystem ferdig, svar mottatt og returnerert" ) - when (it) { // TODO gjerne tenk igjennom en bedre flyt, kanskje alt burde få MsgHead - is MsgHead -> - call.respond( - SendInResponse( - request.messageId, - request.conversationId, - request.addressing.replyTo(request.addressing.service, "InntektInformasjon"), - utbetalingXmlMarshaller.marshalToByteArray(it) - ) - ) - is FrikortsporringResponse -> - call.respond( - SendInResponse( - request.messageId, - request.conversationId, - request.addressing.replyTo( - it.eiFellesformat.mottakenhetBlokk.ebService, - it.eiFellesformat.mottakenhetBlokk.ebAction - ), - frikortXmlMarshaller.marshalToByteArray(it.eiFellesformat.msgHead) - ) - ) - } + call.respond(it) }.onFailure { log.error(request.marker(), "Payload ${request.payloadId} videresending feilet", it) call.respond(HttpStatusCode.BadRequest, it.localizedMessage) diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt index 7b3ffdc6..151e8638 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt @@ -10,52 +10,49 @@ import no.nav.emottak.util.toXMLGregorianCalendar import java.time.Instant import java.util.UUID -class MsgHeadUtil { +fun msgHeadResponse(sendInRequest: SendInRequest, fagmeldingResponse: Any): MsgHead { + val msgHead: MsgHead = + utbetalingXmlMarshaller + .unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) - fun msgHeadResponse(sendInRequest: SendInRequest, fagmeldingResponse: Any): MsgHead { - val msgHead: MsgHead = - utbetalingXmlMarshaller - .unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) - - return msgHead.apply { - msgInfo.apply { - type = CS().apply { - dn = "Svar på forespørsel om inntekt" - v = "InntektInformasjon" - } - genDate = Instant.now().toXMLGregorianCalendar() - msgId = UUID.randomUUID().toString() - ack = CS().apply { - v = "N" - dn = "Nei" - } - val newReceiver = sender - val newSender = receiver - sender.apply { organisation = newSender.organisation } - receiver.apply { organisation = newReceiver.organisation } - conversationRef = ConversationRef().apply { - refToParent = sendInRequest.messageId - refToConversation = sendInRequest.conversationId - } + return msgHead.apply { + msgInfo.apply { + type = CS().apply { + dn = "Svar på forespørsel om inntekt" + v = "InntektInformasjon" + } + genDate = Instant.now().toXMLGregorianCalendar() + msgId = UUID.randomUUID().toString() + ack = CS().apply { + v = "N" + dn = "Nei" } - document.clear() - document.add( - Document().apply { - refDoc = RefDoc().apply { - msgType = CS().apply { - v = "XML" - dn = "XML-instans" - } - mimeType = "text/xml" - content = RefDoc.Content().apply { - any.add( - fagmeldingResponse - ) - } + val newReceiver = sender + val newSender = receiver + sender.apply { organisation = newSender.organisation } + receiver.apply { organisation = newReceiver.organisation } + conversationRef = ConversationRef().apply { + refToParent = sendInRequest.messageId + refToConversation = sendInRequest.conversationId + } + } + document.clear() + document.add( + Document().apply { + refDoc = RefDoc().apply { + msgType = CS().apply { + v = "XML" + dn = "XML-instans" + } + mimeType = "text/xml" + content = RefDoc.Content().apply { + any.add( + fagmeldingResponse + ) } } - ) - signature = null // TODO? - } + } + ) + signature = null // TODO? (Dette er ikke "send-in" sin jobb, blir gjort senere) } } diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index b2f23c93..cd08ab98 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -10,12 +10,13 @@ import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingL import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeUgyldigDato import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeUgyldigKombinasjonBrukerIdOgBrukertype import no.nav.emottak.cxf.ServiceBuilder +import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.util.getEnvVar import org.slf4j.LoggerFactory import java.io.FileInputStream import javax.xml.namespace.QName -class InntektsForesporselClient { +object InntektsForesporselClient { val log = LoggerFactory.getLogger(InntektsForesporselClient::class.java) @@ -33,8 +34,8 @@ class InntektsForesporselClient { } val UTBETAL_SOAP_ENDPOINT = RESOLVED_UTBETAL_URL + "/Utbetaling" - fun behandleInntektsforesporsel(payloadBytes: ByteArray): Any { - val msgHead = utbetalingXmlMarshaller.unmarshal(String(payloadBytes), MsgHead::class.java) + fun behandleInntektsforesporsel(sendInRequest: SendInRequest): MsgHead { + val msgHead = utbetalingXmlMarshaller.unmarshal(String(sendInRequest.payload), MsgHead::class.java) val melding = msgHead.document.map { it.refDoc.content.any } .also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() @@ -44,7 +45,7 @@ class InntektsForesporselClient { is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) else -> throw IllegalStateException("Ukjent meldingstype. Classname: " + melding.javaClass.name) } - return marshal(response) + return msgHeadResponse(sendInRequest, marshal(response)) } catch (utbetalError: Throwable) { log.info("Handling inntektsforesporsel error: " + utbetalError.message) val feil = FinnUtbetalingListeFeil() @@ -62,7 +63,7 @@ class InntektsForesporselClient { else -> throw utbetalError.also { log.error("Ukjent feiltype: " + it.message, it) } } - return feil + return msgHeadResponse(sendInRequest, feil) } } } diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index 82c4329a..ed57054f 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -8,7 +8,7 @@ import no.nav.emottak.melding.model.EbmsProcessing import no.nav.emottak.melding.model.Party import no.nav.emottak.melding.model.PartyId import no.nav.emottak.melding.model.SendInRequest -import no.nav.emottak.utbetaling.MsgHeadUtil +import no.nav.emottak.utbetaling.msgHeadResponse import no.nav.emottak.utbetaling.unmarshal import no.nav.emottak.utbetaling.utbetalingXmlMarshaller import org.junit.jupiter.api.Test @@ -37,7 +37,7 @@ class InntektsforesporselTest { val finnUtbetalingListeFeil = FinnUtbetalingListeFeil() finnUtbetalingListeFeil.finnUtbetalingListebrukerIkkeFunnet = brukerIkkeFunnetException.faultInfo - val msgHeadResponse = MsgHeadUtil().msgHeadResponse( + val msgHeadResponse = msgHeadResponse( SendInRequest( "my-message-id", "my-conversation-id", From d0ba36d588aff965535e31b551f0e5ac95061f10 Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 15:02:56 +0200 Subject: [PATCH 29/30] Navn mismatch og fjerne override --- .../main/kotlin/no/nav/emottak/cpa/Routes.kt | 9 +-- .../main/kotlin/no/nav/emottak/ebms/App.kt | 4 +- .../no/nav/emottak/utbetaling/MsgHeadUtil.kt | 58 ----------------- .../emottak/utbetaling/UtbetalingClient.kt | 62 +++++++++++++++++-- .../test/kotlin/InntektsforesporselTest.kt | 2 + 5 files changed, 62 insertions(+), 73 deletions(-) delete mode 100644 ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt diff --git a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt index b0378085..f58c4adb 100644 --- a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt +++ b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt @@ -182,13 +182,8 @@ fun Route.validateCpa(cpaRepository: CPARepository) = post("/cpa/validate/{$CONT val validateRequest = call.receive(ValidationRequest::class) try { log.info(validateRequest.marker(), "Validerer ebms mot CPA") - val cpa = - // TODO fjern override CPA for Inntektsforesporsel test: - if (validateRequest.cpaId == "nav:qass:30823") { - loadOverrideCPA() - } else { - cpaRepository.findCpa(validateRequest.cpaId) ?: throw NotFoundException("Fant ikke CPA (${validateRequest.cpaId})") - } + val cpa = cpaRepository.findCpa(validateRequest.cpaId) + ?: throw NotFoundException("Fant ikke CPA (${validateRequest.cpaId})") cpa.validate(validateRequest) // Delivery Failure val partyInfo = cpa.getPartyInfoByTypeAndID(validateRequest.addressing.from.partyId) // Delivery Failure val encryptionCertificate = partyInfo.getCertificateForEncryption() // Security Failure diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt index 25a6668d..c6582b6c 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/ebms/App.kt @@ -28,7 +28,7 @@ import no.nav.emottak.frikort.frikortXmlMarshaller import no.nav.emottak.frikort.frikortsporring import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.melding.model.SendInResponse -import no.nav.emottak.utbetaling.InntektsForesporselClient +import no.nav.emottak.utbetaling.UtbetalingClient import no.nav.emottak.utbetaling.utbetalingXmlMarshaller import no.nav.emottak.util.getEnvVar import no.nav.emottak.util.marker @@ -80,7 +80,7 @@ fun Application.ebmsSendInModule() { when (request.addressing.service) { "Inntektsforesporsel" -> timed(appMicrometerRegistry, "Inntektsforesporsel") { - InntektsForesporselClient.behandleInntektsforesporsel(request).let { + UtbetalingClient.behandleInntektsforesporsel(request).let { SendInResponse( request.messageId, request.conversationId, diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt deleted file mode 100644 index 151e8638..00000000 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/MsgHeadUtil.kt +++ /dev/null @@ -1,58 +0,0 @@ -package no.nav.emottak.utbetaling - -import no.kith.xmlstds.msghead._2006_05_24.CS -import no.kith.xmlstds.msghead._2006_05_24.ConversationRef -import no.kith.xmlstds.msghead._2006_05_24.Document -import no.kith.xmlstds.msghead._2006_05_24.MsgHead -import no.kith.xmlstds.msghead._2006_05_24.RefDoc -import no.nav.emottak.melding.model.SendInRequest -import no.nav.emottak.util.toXMLGregorianCalendar -import java.time.Instant -import java.util.UUID - -fun msgHeadResponse(sendInRequest: SendInRequest, fagmeldingResponse: Any): MsgHead { - val msgHead: MsgHead = - utbetalingXmlMarshaller - .unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) - - return msgHead.apply { - msgInfo.apply { - type = CS().apply { - dn = "Svar på forespørsel om inntekt" - v = "InntektInformasjon" - } - genDate = Instant.now().toXMLGregorianCalendar() - msgId = UUID.randomUUID().toString() - ack = CS().apply { - v = "N" - dn = "Nei" - } - val newReceiver = sender - val newSender = receiver - sender.apply { organisation = newSender.organisation } - receiver.apply { organisation = newReceiver.organisation } - conversationRef = ConversationRef().apply { - refToParent = sendInRequest.messageId - refToConversation = sendInRequest.conversationId - } - } - document.clear() - document.add( - Document().apply { - refDoc = RefDoc().apply { - msgType = CS().apply { - v = "XML" - dn = "XML-instans" - } - mimeType = "text/xml" - content = RefDoc.Content().apply { - any.add( - fagmeldingResponse - ) - } - } - } - ) - signature = null // TODO? (Dette er ikke "send-in" sin jobb, blir gjort senere) - } -} diff --git a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt index cd08ab98..3d9cbd80 100644 --- a/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt +++ b/ebms-send-in/src/main/kotlin/no/nav/emottak/utbetaling/UtbetalingClient.kt @@ -1,6 +1,10 @@ package no.nav.emottak.utbetaling +import no.kith.xmlstds.msghead._2006_05_24.CS +import no.kith.xmlstds.msghead._2006_05_24.ConversationRef +import no.kith.xmlstds.msghead._2006_05_24.Document import no.kith.xmlstds.msghead._2006_05_24.MsgHead +import no.kith.xmlstds.msghead._2006_05_24.RefDoc import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnBrukersUtbetalteYtelser import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListe import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingListeBaksystemIkkeTilgjengelig @@ -12,13 +16,16 @@ import no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.FinnUtbetalingL import no.nav.emottak.cxf.ServiceBuilder import no.nav.emottak.melding.model.SendInRequest import no.nav.emottak.util.getEnvVar +import no.nav.emottak.util.toXMLGregorianCalendar import org.slf4j.LoggerFactory import java.io.FileInputStream +import java.time.Instant +import java.util.UUID import javax.xml.namespace.QName -object InntektsForesporselClient { +object UtbetalingClient { - val log = LoggerFactory.getLogger(InntektsForesporselClient::class.java) + val log = LoggerFactory.getLogger(UtbetalingClient::class.java) val utbetalingObjectFactory: no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory = no.nav.ekstern.virkemiddelokonomi.tjenester.utbetaling.v1.ObjectFactory() @@ -35,8 +42,8 @@ object InntektsForesporselClient { val UTBETAL_SOAP_ENDPOINT = RESOLVED_UTBETAL_URL + "/Utbetaling" fun behandleInntektsforesporsel(sendInRequest: SendInRequest): MsgHead { - val msgHead = utbetalingXmlMarshaller.unmarshal(String(sendInRequest.payload), MsgHead::class.java) - val melding = msgHead.document.map { it.refDoc.content.any } + val msgHeadRequest = utbetalingXmlMarshaller.unmarshal(sendInRequest.payload.toString(Charsets.UTF_8), MsgHead::class.java) + val melding = msgHeadRequest.document.map { it.refDoc.content.any } .also { if (it.size > 1) log.warn("Inntektsforesporsel refdoc har size >1") } .first().also { if (it.size > 1) log.warn("Inntektsforesporsel content har size >1") }.first() try { @@ -45,7 +52,7 @@ object InntektsForesporselClient { is FinnBrukersUtbetalteYtelser -> inntektsforesporselSoapEndpoint.finnBrukersUtbetalteYtelser(melding.request) else -> throw IllegalStateException("Ukjent meldingstype. Classname: " + melding.javaClass.name) } - return msgHeadResponse(sendInRequest, marshal(response)) + return msgHeadResponse(msgHeadRequest, sendInRequest, marshal(response)) } catch (utbetalError: Throwable) { log.info("Handling inntektsforesporsel error: " + utbetalError.message) val feil = FinnUtbetalingListeFeil() @@ -63,7 +70,7 @@ object InntektsForesporselClient { else -> throw utbetalError.also { log.error("Ukjent feiltype: " + it.message, it) } } - return msgHeadResponse(sendInRequest, feil) + return msgHeadResponse(msgHeadRequest, sendInRequest, feil) } } } @@ -91,3 +98,46 @@ val inntektsforesporselSoapEndpoint: no.nav.ekstern.virkemiddelokonomi.tjenester } ) .get() + +fun msgHeadResponse(incomingMsgHead: MsgHead, sendInRequest: SendInRequest, fagmeldingResponse: Any): MsgHead { + return incomingMsgHead.apply { + msgInfo.apply { + type = CS().apply { + dn = "Svar på forespørsel om inntekt" + v = "InntektInformasjon" + } + genDate = Instant.now().toXMLGregorianCalendar() + msgId = UUID.randomUUID().toString() + ack = CS().apply { + v = "N" + dn = "Nei" + } + val newReceiver = sender + val newSender = receiver + sender.apply { organisation = newSender.organisation } + receiver.apply { organisation = newReceiver.organisation } + conversationRef = ConversationRef().apply { + refToParent = sendInRequest.messageId + refToConversation = sendInRequest.conversationId + } + } + document.clear() + document.add( + Document().apply { + refDoc = RefDoc().apply { + msgType = CS().apply { + v = "XML" + dn = "XML-instans" + } + mimeType = "text/xml" + content = RefDoc.Content().apply { + any.add( + fagmeldingResponse + ) + } + } + } + ) + signature = null // TODO? (Dette er ikke "send-in" sin jobb, blir gjort senere) + } +} diff --git a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt index ed57054f..3a27c3d6 100644 --- a/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt +++ b/ebms-send-in/src/test/kotlin/InntektsforesporselTest.kt @@ -37,7 +37,9 @@ class InntektsforesporselTest { val finnUtbetalingListeFeil = FinnUtbetalingListeFeil() finnUtbetalingListeFeil.finnUtbetalingListebrukerIkkeFunnet = brukerIkkeFunnetException.faultInfo + val msgHeadRequest = utbetalingXmlMarshaller.unmarshal(msgHeadEksempel, MsgHead::class.java) val msgHeadResponse = msgHeadResponse( + msgHeadRequest, SendInRequest( "my-message-id", "my-conversation-id", From 14f939b4cef847b4150216d78049f4e1a2a7a36d Mon Sep 17 00:00:00 2001 From: Chris Olsen Date: Wed, 11 Sep 2024 15:06:42 +0200 Subject: [PATCH 30/30] Sletter overrideCpa func --- cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt index f58c4adb..f4c7f28f 100644 --- a/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt +++ b/cpa-repo/src/main/kotlin/no/nav/emottak/cpa/Routes.kt @@ -173,11 +173,6 @@ fun Route.postCpa(cpaRepository: CPARepository) = post("/cpa") { } } -fun loadOverrideCPA(): CollaborationProtocolAgreement { - val cpaString = String(object {}::class.java.classLoader.getResource("cpa/nav_qass_30823_modified.xml").readBytes()) - return xmlMarshaller.unmarshal(cpaString, CollaborationProtocolAgreement::class.java) -} - fun Route.validateCpa(cpaRepository: CPARepository) = post("/cpa/validate/{$CONTENT_ID}") { val validateRequest = call.receive(ValidationRequest::class) try {