Search in sources :

Example 61 with WebCertUser

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;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 62 with WebCertUser

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);
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) HashSet(java.util.HashSet) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Before(org.junit.Before)

Example 63 with WebCertUser

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));
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 64 with WebCertUser

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));
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 65 with WebCertUser

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();
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Aggregations

WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)217 Test (org.junit.Test)123 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)32 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)31 Personnummer (se.inera.intyg.schemas.contract.Personnummer)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)23 Role (se.inera.intyg.infra.security.common.model.Role)18 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)16 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)15 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)15 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)14 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)14 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)13 Feature (se.inera.intyg.infra.security.common.model.Feature)13 HashMap (java.util.HashMap)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)12 Transactional (org.springframework.transaction.annotation.Transactional)11 Path (javax.ws.rs.Path)10