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;
}
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;
}
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();
}
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());
}
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());
}
Aggregations