Search in sources :

Example 1 with Feature

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

the class BaseCreateDraftCertificateTest method buildWebCertUser.

protected WebCertUser buildWebCertUser() {
    WebCertUser user = new WebCertUser();
    user.setAuthorities(new HashMap<>());
    user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, createPrivilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT));
    user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, createPrivilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG));
    // TODO
    user.setFeatures(Stream.of(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_TAK_KONTROLL).collect(Collectors.toMap(Function.identity(), s -> {
        Feature feature = new Feature();
        feature.setName(s);
        feature.setGlobal(true);
        feature.setIntygstyper(Arrays.asList(FK7263, TSBAS));
        return feature;
    })));
    user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
    user.setBefattningar(Arrays.asList(TITLE_CODE));
    user.setSpecialiseringar(Arrays.asList(ALLMAN_MEDICIN, INVARTES_MEDICIN));
    user.setTitel(TITLE_NAME);
    user.setVardgivare(Arrays.asList(createVardgivare()));
    user.setMiuNamnPerEnhetsId(createMiuNamnPerEnhetsId());
    return user;
}
Also used : Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 2 with Feature

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

the class BaseCreateDraftCertificateValidatorTest method buildUserUnauthorized.

protected WebCertUser buildUserUnauthorized() {
    WebCertUser user = new WebCertUser();
    user.setAuthorities(new HashMap<>());
    user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, createPrivilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, ALL_INTYG_TYPES));
    user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, createPrivilege(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, ALL_INTYG_TYPES));
    Feature feature = new Feature();
    feature.setName(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    feature.setIntygstyper(Arrays.asList(Fk7263EntryPoint.MODULE_ID, TsBasEntryPoint.MODULE_ID, TsDiabetesEntryPoint.MODULE_ID, LisjpEntryPoint.MODULE_ID, LuaenaEntryPoint.MODULE_ID, LuaefsEntryPoint.MODULE_ID, LuseEntryPoint.MODULE_ID, DbModuleEntryPoint.MODULE_ID, DoiModuleEntryPoint.MODULE_ID));
    user.setFeatures(Collections.singletonMap(feature.getName(), feature));
    user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
    return user;
}
Also used : Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 3 with Feature

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

the class AuthoritiesValidatorTest method testMustNotHaveAnyFeatureFails.

@Test
public void testMustNotHaveAnyFeatureFails() {
    WebCertUser user = createDefaultUser();
    user.setFeatures(Stream.of(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_HANTERA_FRAGOR).collect(Collectors.toMap(Function.identity(), s -> {
        Feature feature = new Feature();
        feature.setName(s);
        feature.setIntygstyper(Collections.singletonList("fk7263"));
        return feature;
    })));
    assertFalse(validator.given(user, "fk7263").notFeatures(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_FORNYA_INTYG).isVerified());
    thrown.expect(AuthoritiesException.class);
    validator.given(user, "fk7263").notFeatures(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_FORNYA_INTYG).orThrow();
}
Also used : Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 4 with Feature

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

the class AuthoritiesValidatorTest method testMustNotHaveAnyFeature.

@Test
public void testMustNotHaveAnyFeature() {
    WebCertUser user = createDefaultUser();
    user.setFeatures(Stream.of(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_HANTERA_FRAGOR).collect(Collectors.toMap(Function.identity(), s -> {
        Feature feature = new Feature();
        feature.setName(s);
        feature.setIntygstyper(Collections.singletonList("fk7263"));
        return feature;
    })));
    assertTrue(validator.given(user).notFeatures(AuthoritiesConstants.FEATURE_ARBETSGIVARUTSKRIFT, AuthoritiesConstants.FEATURE_FORNYA_INTYG).isVerified());
}
Also used : Feature(se.inera.intyg.infra.security.common.model.Feature) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 5 with Feature

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

the class TakServiceImplTest method createDefaultUser.

private IntygUser createDefaultUser() {
    return createUser(AuthoritiesConstants.ROLE_LAKARE, createPrivilege("p1", Arrays.asList("fk7263", "ts-bas", "luse"), Arrays.asList(createRequestOrigin(UserOriginType.NORMAL.name(), Arrays.asList("fk7263", "ts-bas", "luse")), createRequestOrigin(UserOriginType.DJUPINTEGRATION.name(), Collections.singletonList("ts-bas")))), Stream.of(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR, AuthoritiesConstants.FEATURE_TAK_KONTROLL_TRADKLATTRING).collect(Collectors.toMap(Function.identity(), s -> {
        Feature feature = new Feature();
        feature.setName(s);
        feature.setGlobal(true);
        feature.setIntygstyper(Arrays.asList("fk7263", "luse"));
        return feature;
    })), UserOriginType.NORMAL.name());
}
Also used : Feature(se.inera.intyg.infra.security.common.model.Feature)

Aggregations

Feature (se.inera.intyg.infra.security.common.model.Feature)25 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)13 Test (org.junit.Test)10 HashMap (java.util.HashMap)6 WebUserFeaturesRequest (se.inera.intyg.webcert.web.web.controller.api.dto.WebUserFeaturesRequest)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Privilege (se.inera.intyg.infra.security.common.model.Privilege)2 RequestOrigin (se.inera.intyg.infra.security.common.model.RequestOrigin)2 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)2 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)1 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)1 Role (se.inera.intyg.infra.security.common.model.Role)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)1 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)1 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)1