use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class FragaSvarServiceImplTest method buildUserOfRole.
private WebCertUser buildUserOfRole(Role role) {
WebCertUser user = new WebCertUser();
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
user.setOrigin("NORMAL");
user.setHsaId("testuser");
user.setNamn("test userman");
Feature feature = new Feature();
feature.setName(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR);
feature.setGlobal(true);
feature.setIntygstyper(ImmutableList.of("fk7263"));
user.setFeatures(ImmutableMap.of(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR, feature));
Vardenhet vardenhet = new Vardenhet("enhet", "Enhet");
Vardgivare vardgivare = new Vardgivare("vardgivare", "Vardgivaren");
vardgivare.getVardenheter().add(vardenhet);
user.setVardgivare(Collections.singletonList(vardgivare));
user.setValdVardenhet(vardenhet);
return user;
}
use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class BaseCreateDraftCertificateValidatorTest method buildUser.
protected WebCertUser buildUser() {
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));
Feature feature = new Feature();
feature.setName(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
feature.setIntygstyper(Arrays.asList(Fk7263EntryPoint.MODULE_ID, TsBasEntryPoint.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 createDefaultUser.
private WebCertUser createDefaultUser() {
Map<String, Feature> featureMap = new HashMap<>();
Feature feature1 = new Feature();
feature1.setName(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
feature1.setIntygstyper(Collections.singletonList("fk7263"));
featureMap.put(feature1.getName(), feature1);
Feature feature2 = new Feature();
feature2.setName("base_feature");
feature2.setIntygstyper(Collections.emptyList());
featureMap.put(feature2.getName(), feature2);
return createUser(AuthoritiesConstants.ROLE_LAKARE, createPrivilege("p1", // p1 is restricted to these intygstyper
Arrays.asList("fk7263", "ts-bas"), Arrays.asList(createRequestOrigin(UserOriginType.NORMAL.name(), Arrays.asList("fk7263")), // Normal restricted to fk7263
createRequestOrigin(UserOriginType.DJUPINTEGRATION.name(), Arrays.asList("ts-bas")))), featureMap, // is not.
UserOriginType.NORMAL.name());
}
use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class AuthoritiesValidatorTest method testMustHaveSomeFeature.
@Test
public void testMustHaveSomeFeature() {
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, "fk7263").features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST, AuthoritiesConstants.FEATURE_ARBETSGIVARUTSKRIFT).isVerified());
}
use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class AuthoritiesValidatorTest method testMustHaveFeature.
@Test
public void testMustHaveFeature() {
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, "fk7263").features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST).features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR).notFeatures(AuthoritiesConstants.FEATURE_FORNYA_INTYG).isVerified());
}
Aggregations