use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class UserApiControllerTest method testUserFeaturesDisableEnabled.
@Test
public void testUserFeaturesDisableEnabled() {
// Given
final WebUserFeaturesRequest webUserFeaturesRequest = new WebUserFeaturesRequest();
webUserFeaturesRequest.setJsLoggning(false);
final HashMap<String, Feature> features = new HashMap<>();
Feature f1 = new Feature();
f1.setName(AuthoritiesConstants.FEATURE_JS_LOGGNING);
features.put(f1.getName(), f1);
when(webCertUser.getFeatures()).thenReturn(features);
// When
userApiController.userFeatures(webUserFeaturesRequest);
// Then
Mockito.verify(webCertUser, times(1)).setFeatures(captor.capture());
assertFalse(captor.getValue().containsKey(AuthoritiesConstants.FEATURE_JS_LOGGNING));
}
use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class UserApiControllerTest method testUserFeaturesEnableEnabled.
@Test
public void testUserFeaturesEnableEnabled() {
// Given
final WebUserFeaturesRequest webUserFeaturesRequest = new WebUserFeaturesRequest();
webUserFeaturesRequest.setJsLoggning(true);
final HashMap<String, Feature> features = new HashMap<>();
Feature f1 = new Feature();
f1.setName(AuthoritiesConstants.FEATURE_JS_LOGGNING);
features.put(f1.getName(), f1);
when(webCertUser.getFeatures()).thenReturn(features);
// When
userApiController.userFeatures(webUserFeaturesRequest);
// Then
Mockito.verify(webCertUser, times(1)).setFeatures(captor.capture());
assertTrue(captor.getValue().containsKey(AuthoritiesConstants.FEATURE_JS_LOGGNING));
}
use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class UtkastApiControllerTest method setupUser.
private void setupUser(String privilegeString, String intygType, String... features) {
WebCertUser user = new WebCertUser();
user.setAuthorities(new HashMap<>());
user.getFeatures().putAll(Stream.of(features).collect(Collectors.toMap(Function.identity(), s -> {
Feature feature = new Feature();
feature.setName(s);
feature.setIntygstyper(Arrays.asList(intygType));
feature.setGlobal(true);
return feature;
})));
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");
user.setValdVardenhet(buildVardenhet());
user.setValdVardgivare(buildVardgivare());
when(webcertUserService.getUser()).thenReturn(user);
}
use of se.inera.intyg.infra.security.common.model.Feature 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);
}
use of se.inera.intyg.infra.security.common.model.Feature in project webcert by sklintyg.
the class UserApiControllerTest method testUserFeaturesEnableDisabled.
@Test
public void testUserFeaturesEnableDisabled() {
// Given
final WebUserFeaturesRequest webUserFeaturesRequest = new WebUserFeaturesRequest();
webUserFeaturesRequest.setJsLoggning(true);
final HashMap<String, Feature> features = new HashMap<>();
when(webCertUser.getFeatures()).thenReturn(features);
// When
userApiController.userFeatures(webUserFeaturesRequest);
// Then
Mockito.verify(webCertUser, times(1)).setFeatures(captor.capture());
assertTrue(captor.getValue().containsKey(AuthoritiesConstants.FEATURE_JS_LOGGNING));
}
Aggregations