Search in sources :

Example 16 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class IntygIntegrationServiceImplTest method userIsAuthorizedToHandleSekretessmarkeradPatient.

@Test
public void userIsAuthorizedToHandleSekretessmarkeradPatient() {
    // given
    when(utkastRepository.findOne(anyString())).thenReturn(createUtkast());
    when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.TRUE);
    IntegrationParameters parameters = new IntegrationParameters(null, null, ALTERNATE_SSN, "Nollan", null, "Nollansson", "Nollgatan", "000000", "Nollby", false, false, false, false);
    Privilege p = createPrivilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, // p1 is restricted to these intygstyper
    Arrays.asList("lisjp", "ts-bas"), Arrays.asList(createRequestOrigin(UserOriginType.DJUPINTEGRATION.name(), Arrays.asList("lisjp")), createRequestOrigin(UserOriginType.DJUPINTEGRATION.name(), Arrays.asList("ts-bas"))));
    WebCertUser user = createDefaultUser();
    user.setParameters(parameters);
    user.getAuthorities().put(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT, p);
    // when
    PrepareRedirectToIntyg prepareRedirectToIntyg = testee.prepareRedirectToIntyg(INTYGSTYP, INTYGSID, user);
    // then
    verify(utkastRepository).findOne(anyString());
    verify(patientDetailsResolver).getSekretessStatus(any(Personnummer.class));
    assertEquals(INTYGSTYP, prepareRedirectToIntyg.getIntygTyp());
    assertEquals(INTYGSID, prepareRedirectToIntyg.getIntygId());
    assertTrue(prepareRedirectToIntyg.isUtkast());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) PrepareRedirectToIntyg(se.inera.intyg.webcert.web.web.controller.integration.dto.PrepareRedirectToIntyg) Privilege(se.inera.intyg.infra.security.common.model.Privilege) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 17 with Privilege

use of se.inera.intyg.infra.security.common.model.Privilege in project webcert by sklintyg.

the class BaseCreateDraftCertificateTest method createPrivilege.

private Privilege createPrivilege(String privilege) {
    Privilege priv = new Privilege();
    priv.setName(privilege);
    RequestOrigin requestOrigin = new RequestOrigin();
    requestOrigin.setName(UserOriginType.DJUPINTEGRATION.name());
    requestOrigin.setIntygstyper(Arrays.asList(FK7263, TSBAS));
    priv.setRequestOrigins(Arrays.asList(requestOrigin));
    priv.setIntygstyper(Arrays.asList(FK7263, TSBAS));
    return priv;
}
Also used : RequestOrigin(se.inera.intyg.infra.security.common.model.RequestOrigin) Privilege(se.inera.intyg.infra.security.common.model.Privilege)

Aggregations

Privilege (se.inera.intyg.infra.security.common.model.Privilege)17 RequestOrigin (se.inera.intyg.infra.security.common.model.RequestOrigin)8 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)7 Role (se.inera.intyg.infra.security.common.model.Role)5 HashMap (java.util.HashMap)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)3 Test (org.junit.Test)2 Feature (se.inera.intyg.infra.security.common.model.Feature)2 IOException (java.io.IOException)1 List (java.util.List)1 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)1 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)1 AuthoritiesConfiguration (se.inera.intyg.infra.security.authorities.AuthoritiesConfiguration)1 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)1 Title (se.inera.intyg.infra.security.common.model.Title)1 TitleCode (se.inera.intyg.infra.security.common.model.TitleCode)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 PrepareRedirectToIntyg (se.inera.intyg.webcert.web.web.controller.integration.dto.PrepareRedirectToIntyg)1