use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class IntygServiceSendTest method createUser.
private WebCertUser createUser() {
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
WebCertUser user = new WebCertUser();
user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
user.setParameters(new IntegrationParameters("", "", "", "", "", "", "", "", "", false, false, false, true));
user.setRoles(AuthoritiesResolverUtil.toMap(role));
user.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
return user;
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class IntygServiceTest method setupDefaultAuthorization.
@Before
public void setupDefaultAuthorization() {
Set<String> set = new HashSet<>();
set.add("fk7263");
when(webCertUserService.getUser()).thenReturn(webcertUser);
when(webcertUser.getOrigin()).thenReturn(UserOriginType.NORMAL.name());
when(webcertUser.getParameters()).thenReturn(new IntegrationParameters(USER_REFERENCE, "", "", "", "", "", "", "", "", false, false, false, true));
when(webCertUserService.isAuthorizedForUnit(any(String.class), any(String.class), eq(true))).thenReturn(true);
when(authoritiesHelper.getIntygstyperForPrivilege(any(WebCertUser.class), anyString())).thenReturn(set);
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class WebCertUserServiceTest method testUserHasNoReadOnlyAccessToParentVardEnhetWhenDJUPINTEGRATION.
@Test
public void testUserHasNoReadOnlyAccessToParentVardEnhetWhenDJUPINTEGRATION() {
WebCertUser user = setupUserMottagningAccessTest();
user.changeValdVardenhet(MOTTAGNING_1);
user.setOrigin(UserOriginType.DJUPINTEGRATION.name());
assertFalse(webcertUserService.isAuthorizedForUnit(VARDENHET_1, true));
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class WebCertUserServiceTest method testCheckIfAuthorizedForUnitWhenIntegrated.
@Test
public void testCheckIfAuthorizedForUnitWhenIntegrated() {
// anv i JS-läge inloggad på VE1 på VG1
WebCertUser user = createWebCertUser(true);
assertTrue("ska kunna titta på ett intyg inom VE1", webcertUserService.checkIfAuthorizedForUnit(user, VARDGIVARE_1, VARDENHET_1, true));
assertTrue("ska kunna titta på ett intyg inom VE2", webcertUserService.checkIfAuthorizedForUnit(user, VARDGIVARE_1, VARDENHET_2, true));
assertTrue("ska kunna redigera ett intyg inom VE1", webcertUserService.checkIfAuthorizedForUnit(user, VARDGIVARE_1, VARDENHET_1, false));
assertFalse("ska INTE kunna redigera ett intyg inom VE2", webcertUserService.checkIfAuthorizedForUnit(user, VARDGIVARE_1, VARDENHET_2, false));
}
use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.
the class WebCertUserServiceTest method testUserHasAccessToChildMottagning.
@Test
public void testUserHasAccessToChildMottagning() {
WebCertUser user = setupUserMottagningAccessTest();
user.changeValdVardenhet(VARDENHET_1);
assertUserHasExpectedAccess();
}
Aggregations