use of se.inera.intyg.webcert.web.auth.eleg.FakeElegCredentials in project webcert by sklintyg.
the class UtkastModuleApiControllerIT method testServerSigneraUtkastMedGrp.
@Test
public void testServerSigneraUtkastMedGrp() throws IOException {
FakeElegCredentials fakeElegCredentials = new FakeElegCredentials();
fakeElegCredentials.setPersonId(TOLVAN_PERSON_ID);
fakeElegCredentials.setPrivatLakare(true);
RestAssured.sessionId = getAuthSession(fakeElegCredentials);
Intyg intyg = createIntyg();
// var knownSignStatuses = {'BEARBETAR':'', 'VANTA_SIGN':'', 'NO_CLIENT':'', 'SIGNERAD':'', 'OKAND': ''};
// Påbörja signering
Response responseTicket = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().post(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + intyg.getId() + "/" + intyg.getVersion() + "/grp/signeraserver").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).body("status", equalTo("BEARBETAR")).extract().response();
// Hämta ut biljett-id från svaret
JsonPath model = new JsonPath(responseTicket.body().asString());
String biljettId = model.getString("id");
// biljettId är inte samma sak som orderRef.
// Hämta ut orderRef först
Response responseOrderRef = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.TEXT).expect().statusCode(200).when().get(GRPAPI_STUBBE_BASE + "/orderref/" + biljettId).then().extract().response();
String orderRef = responseOrderRef.body().asString();
// Ändra GRP-status till USER_SIGN och kontrollera
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(createGrpSignatureStatus(orderRef, ProgressStatusType.USER_SIGN)).expect().statusCode(200).when().put(GRPAPI_STUBBE_BASE + "/status");
// Simulera väntetid vid pollning mot riktig GPR-tjänst
sleep();
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + biljettId + "/signeringsstatus").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).body("status", equalTo("VANTA_SIGN"));
// Ändra GRP-status till COMPLETE och kontrollera
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(createGrpSignatureStatus(orderRef, ProgressStatusType.COMPLETE)).expect().statusCode(200).when().put(GRPAPI_STUBBE_BASE + "/status");
// Simulera väntetid vid pollning mot riktig GPR-tjänst
sleep();
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + biljettId + "/signeringsstatus").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).body("status", equalTo("SIGNERAD"));
}
use of se.inera.intyg.webcert.web.auth.eleg.FakeElegCredentials in project webcert by sklintyg.
the class FakeAuthenticationFilter method performFakeElegAuthentication.
private Authentication performFakeElegAuthentication(String json) {
try {
FakeElegCredentials fakeElegCredentials = new ObjectMapper().readValue(json, FakeElegCredentials.class);
LOG.info("Detected fake credentials " + fakeElegCredentials);
return getAuthenticationManager().authenticate(new FakeElegAuthenticationToken(fakeElegCredentials));
} catch (IOException e) {
String message = "Failed to parse JSON for fake E-leg: " + json;
LOG.error(message, e);
throw new RuntimeException(message, e);
}
}
use of se.inera.intyg.webcert.web.auth.eleg.FakeElegCredentials in project webcert by sklintyg.
the class CertificateIntegrationControllerIT method testRedirectWithTypeFailsWithInvalidRole.
@Test
public void testRedirectWithTypeFailsWithInvalidRole() {
FakeElegCredentials fakeElegCredentials = new FakeElegCredentials();
fakeElegCredentials.setPersonId("19121212-1212");
fakeElegCredentials.setPrivatLakare(true);
RestAssured.sessionId = getAuthSession(fakeElegCredentials);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).redirects().follow(false).and().pathParams("intygsId", DEFAULT_INTYGSID, "intygsTyp", INTYGSTYP).expect().statusCode(HttpServletResponse.SC_TEMPORARY_REDIRECT).when().get("webcert/web/user/basic-certificate/{intygsTyp}/{intygsId}/questions").then().header(HttpHeaders.LOCATION, endsWith("/error.jsp?reason=auth-exception"));
}
use of se.inera.intyg.webcert.web.auth.eleg.FakeElegCredentials in project webcert by sklintyg.
the class CertificateIntegrationControllerIT method testRedirectFailsWithInvalidRole.
@Test
public void testRedirectFailsWithInvalidRole() {
FakeElegCredentials fakeElegCredentials = new FakeElegCredentials();
fakeElegCredentials.setPersonId("19121212-1212");
fakeElegCredentials.setPrivatLakare(true);
RestAssured.sessionId = getAuthSession(fakeElegCredentials);
given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).redirects().follow(false).and().pathParam("intygsId", DEFAULT_INTYGSID).expect().statusCode(HttpServletResponse.SC_TEMPORARY_REDIRECT).when().get("webcert/web/user/basic-certificate/{intygsId}/questions").then().header(HttpHeaders.LOCATION, endsWith("/error.jsp?reason=auth-exception"));
}
Aggregations