Search in sources :

Example 6 with FakeCredentials

use of se.inera.intyg.webcert.web.auth.fake.FakeCredentials in project webcert by sklintyg.

the class CommonFakeAuthenticationProvider method overrideSekretessMarkeringFromFakeCredentials.

private void overrideSekretessMarkeringFromFakeCredentials(Authentication token, Object details) {
    if (details instanceof IntygUser) {
        IntygUser user = (IntygUser) details;
        final FakeCredentials fakeCredentials = (FakeCredentials) token.getCredentials();
        // Only override if set
        if (fakeCredentials.getSekretessMarkerad() != null) {
            user.setSekretessMarkerad(fakeCredentials.getSekretessMarkerad());
        }
    }
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser)

Example 7 with FakeCredentials

use of se.inera.intyg.webcert.web.auth.fake.FakeCredentials in project webcert by sklintyg.

the class UserApiControllerIT method testAndraValdEnhet.

@Test
public void testAndraValdEnhet() {
    // Log in as user having medarbetaruppdrag at several vardenheter.
    FakeCredentials user = new FakeCredentials.FakeCredentialsBuilder("IFV1239877878-104B", "IFV1239877878-1042").legitimeradeYrkesgrupper(asList("Läkare")).build();
    RestAssured.sessionId = getAuthSession(user);
    // An improvement of this would be to call hsaStub rest api to add testa data as we want it to
    // avoid "magic" ids and the dependency to bootstrapped data?
    final String vardEnhetToChangeTo = "IFV1239877878-1045";
    ChangeSelectedUnitRequest changeRequest = new ChangeSelectedUnitRequest();
    changeRequest.setId(vardEnhetToChangeTo);
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().body(changeRequest).when().post("api/anvandare/andraenhet").then().statusCode(200).body(matchesJsonSchemaInClasspath("jsonschema/webcert-user-response-schema.json")).body("valdVardenhet.id", equalTo(vardEnhetToChangeTo));
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) ChangeSelectedUnitRequest(se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Aggregations

FakeCredentials (se.inera.intyg.webcert.web.auth.fake.FakeCredentials)7 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)4 Test (org.junit.Test)2 AuthoritiesException (se.inera.intyg.infra.security.authorities.AuthoritiesException)2 ChangeSelectedUnitRequest (se.inera.intyg.webcert.web.web.controller.api.dto.ChangeSelectedUnitRequest)2 BaseRestIntegrationTest (se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)2 Assertion (org.opensaml.saml2.core.Assertion)1 AttributeStatement (org.opensaml.saml2.core.AttributeStatement)1 NameID (org.opensaml.saml2.core.NameID)1 AssertionBuilder (org.opensaml.saml2.core.impl.AssertionBuilder)1 AttributeStatementBuilder (org.opensaml.saml2.core.impl.AttributeStatementBuilder)1 NameIDBuilder (org.opensaml.saml2.core.impl.NameIDBuilder)1 SAMLCredential (org.springframework.security.saml.SAMLCredential)1 AuthenticationMethod (se.inera.intyg.infra.security.common.model.AuthenticationMethod)1 BaseSakerhetstjanstAssertion (se.inera.intyg.infra.security.siths.BaseSakerhetstjanstAssertion)1