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());
}
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;
}
Aggregations