use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCreateRenewalBasedOnIntygFromDifferentCareUnitWithCoherentJournalingFail.
@Test
public void testCreateRenewalBasedOnIntygFromDifferentCareUnitWithCoherentJournalingFail() throws IOException {
// First use DEFAULT_LAKARE to create a signed certificate on care unit A.
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
String intygsId = createUtkast("lisjp", DEFAULT_PATIENT_PERSONNUMMER);
// Then logout
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).redirects().follow(false).expect().statusCode(HttpServletResponse.SC_FOUND).when().get("logout");
// Next, create new user credentials with another care unit B, and attempt to access the certificate created in
// previous step.
RestAssured.sessionId = getAuthSession(LEONIE_KOEHL);
changeOriginTo("DJUPINTEGRATION");
// coherentJournaling defaults to false, so don't set it here.
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(DEFAULT_PATIENT_PERSONNUMMER));
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "lisjp");
pathParams.put("intygsId", intygsId);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/fornya").then().body("errorCode", equalTo(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM.name())).body("message", not(isEmptyString()));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCreateRenewalBasedOnExistingUtkastWithInvalidPatientpersonNummer.
/**
* Check that trying to copy utkast with bad input gives error response.
*/
@Test
public void testCreateRenewalBasedOnExistingUtkastWithInvalidPatientpersonNummer() {
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
changeOriginTo("DJUPINTEGRATION");
String utkastId = createUtkast("lisjp", DEFAULT_PATIENT_PERSONNUMMER);
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(null);
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "lisjp");
pathParams.put("intygsId", utkastId);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(500).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/fornya").then().body("errorCode", equalTo(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM.name())).body("message", not(isEmptyString()));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCreateRenewalBasedOnExistingUtkast.
@Test
public void testCreateRenewalBasedOnExistingUtkast() {
final String personnummer = "19121212-1212";
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
changeOriginTo("DJUPINTEGRATION");
String utkastId = createUtkast("lisjp", personnummer);
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(personnummer));
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "lisjp");
pathParams.put("intygsId", utkastId);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(200).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/fornya").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(utkastId))).body("intygsTyp", equalTo("lisjp"));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCreateRenewalBasedOnExistingUtkastFailsForMissingPriveliges.
@Test
public void testCreateRenewalBasedOnExistingUtkastFailsForMissingPriveliges() {
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
String utkastId = createUtkast("lisjp", DEFAULT_PATIENT_PERSONNUMMER);
// Lakare role has the FORNYA_INTYG priviledge, but the privilege is restricted to origintype=NORMAL /
// DJUPINTEGRERAD.
// We change the current users origin to be uthop which should trigger an auth exception response.
changeOriginTo(UserOriginType.UTHOPP.name());
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(DEFAULT_PATIENT_PERSONNUMMER));
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "lisjp");
pathParams.put("intygsId", utkastId);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(500).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/fornya").then().body("errorCode", equalTo(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM.name())).body("message", not(isEmptyString()));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest in project webcert by sklintyg.
the class IntygModuleApiControllerIT method testCreateRenewalBasedOnIntygFromDifferentCareUnitWithCoherentJournalingSuccess.
@Test
public void testCreateRenewalBasedOnIntygFromDifferentCareUnitWithCoherentJournalingSuccess() throws IOException {
// First use DEFAULT_LAKARE to create a signed certificate on care unit A.
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
String intygsId = createUtkast("lisjp", DEFAULT_PATIENT_PERSONNUMMER);
// Then logout
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).redirects().follow(false).expect().statusCode(HttpServletResponse.SC_FOUND).when().get("logout");
// Next, create new user credentials with another care unit B, and attempt to access the certificate created in
// previous step.
RestAssured.sessionId = getAuthSession(LEONIE_KOEHL);
changeOriginTo("DJUPINTEGRATION");
setSjf();
// Set coherentJournaling=true in copyIntygRequest, this is normally done in the js using the copyService.
CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
copyIntygRequest.setPatientPersonnummer(createPnr(DEFAULT_PATIENT_PERSONNUMMER));
Map<String, String> pathParams = new HashMap<>();
pathParams.put("intygsTyp", "lisjp");
pathParams.put("intygsId", intygsId);
String newIntygsId = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(HttpServletResponse.SC_OK).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/fornya").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(intygsId))).body("intygsTyp", equalTo("lisjp")).extract().path("intygsUtkastId");
// Check that the copy contains the correct stuff
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get("moduleapi/intyg/lisjp/" + newIntygsId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-intyg-response-schema.json")).body("contents.grundData.skapadAv.personId", equalTo(LEONIE_KOEHL.getHsaId())).body("contents.grundData.patient.personId", equalTo(formatPersonnummer(DEFAULT_PATIENT_PERSONNUMMER)));
}
Aggregations