Search in sources :

Example 11 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class FragaSvarModuleApiControllerTest method createPrivilege.

protected Privilege createPrivilege(String privilege) {
    Privilege priv = new Privilege();
    priv.setName(privilege);
    RequestOrigin requestOrigin = new RequestOrigin();
    requestOrigin.setName(UserOriginType.UTHOPP.name());
    requestOrigin.setIntygstyper(Arrays.asList(FK7263));
    priv.setRequestOrigins(Arrays.asList(requestOrigin));
    priv.setIntygstyper(Arrays.asList(FK7263));
    return priv;
}
Also used : RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Privilege(se.inera.intyg.infra.security.common.model.Privilege)

Example 12 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class IntygModuleApiControllerTest method addPrivileges.

private void addPrivileges(WebCertUser user, String intygType, String... privileges) {
    user.setAuthorities(new HashMap<>());
    Privilege privilege = new Privilege();
    privilege.setIntygstyper(Arrays.asList(intygType));
    RequestOrigin requestOrigin = new RequestOrigin();
    requestOrigin.setName("NORMAL");
    requestOrigin.setIntygstyper(privilege.getIntygstyper());
    privilege.setRequestOrigins(Arrays.asList(requestOrigin));
    for (String privilegeString : privileges) {
        user.getAuthorities().put(privilegeString, privilege);
    }
}
Also used : RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Privilege(se.inera.intyg.infra.security.common.model.Privilege)

Example 13 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class IntygModuleApiControllerTest method setupUser.

private void setupUser(String privilegeString, String intygType, boolean coherentJournaling, boolean copyOk, String... features) {
    WebCertUser user = new WebCertUser();
    user.setAuthorities(new HashMap<>());
    addFeatures(user, intygType, features);
    user.setParameters(new IntegrationParameters(null, null, null, null, null, null, null, null, null, coherentJournaling, false, false, copyOk));
    Privilege privilege = new Privilege();
    privilege.setIntygstyper(Arrays.asList(intygType));
    RequestOrigin requestOrigin = new RequestOrigin();
    requestOrigin.setName("NORMAL");
    requestOrigin.setIntygstyper(privilege.getIntygstyper());
    privilege.setRequestOrigins(Arrays.asList(requestOrigin));
    user.getAuthorities().put(privilegeString, privilege);
    user.setOrigin("NORMAL");
    when(webcertUserService.getUser()).thenReturn(user);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Privilege(se.inera.intyg.infra.security.common.model.Privilege) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 14 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method setupUser.

private void setupUser(String privilegeString, String intygType, boolean coherentJournaling, String... features) {
    WebCertUser user = new WebCertUser();
    user.setAuthorities(new HashMap<>());
    user.setFeatures(Stream.of(features).collect(Collectors.toMap(Function.identity(), s -> {
        Feature feature = new Feature();
        feature.setName(s);
        feature.setIntygstyper(Arrays.asList(intygType));
        return feature;
    })));
    user.setParameters(new IntegrationParameters("", "", "", "", "", "", "", "", "", coherentJournaling, false, false, true));
    Privilege privilege = new Privilege();
    privilege.setIntygstyper(Arrays.asList(intygType));
    RequestOrigin requestOrigin = new RequestOrigin();
    requestOrigin.setName("NORMAL");
    requestOrigin.setIntygstyper(privilege.getIntygstyper());
    privilege.setRequestOrigins(Arrays.asList(requestOrigin));
    user.getAuthorities().put(privilegeString, privilege);
    user.setOrigin("NORMAL");
    when(webcertUserService.getUser()).thenReturn(user);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Privilege(se.inera.intyg.infra.security.common.model.Privilege) Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 15 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class IntygIntegrationControllerTest method createPrivilege.

private Privilege createPrivilege(String name, List<String> intygsTyper, List<RequestOrigin> requestOrigins) {
    Privilege p = new Privilege();
    p.setName(name);
    p.setIntygstyper(intygsTyper);
    p.setRequestOrigins(requestOrigins);
    return p;
}
Also used : Privilege(se.inera.intyg.infra.security.common.model.Privilege)

Aggregations

Privilege (se.inera.intyg.infra.security.common.model.Privilege)17 RequestOrigin (se.inera.intyg.infra.security.common.model.RequestOrigin)8 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)7 Role (se.inera.intyg.infra.security.common.model.Role)5 HashMap (java.util.HashMap)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)3 Test (org.junit.Test)2 Feature (se.inera.intyg.infra.security.common.model.Feature)2 IOException (java.io.IOException)1 List (java.util.List)1 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)1 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)1 AuthoritiesConfiguration (se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration)1 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)1 Title (se.inera.intyg.infra.security.common.model.Title)1 TitleCode (se.inera.intyg.infra.security.common.model.TitleCode)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 PrepareRedirectToIntyg (se.inera.intyg.webcert.web.web.controller.integration.dto.PrepareRedirectToIntyg)1