Search in sources :

Example 11 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class TermsFilterTest method buildWebCertUser.

private WebCertUser buildWebCertUser(String authScheme) {
    Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
    WebCertUser webCertUser = new WebCertUser();
    webCertUser.setRoles(AuthoritiesResolverUtil.toMap(role));
    webCertUser.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
    webCertUser.setAuthenticationScheme(authScheme);
    return webCertUser;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 12 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class ElegWebCertUserDetailsServiceTest method testSuccessfulLoginSekretessMarkerad.

@Test
public void testSuccessfulLoginSekretessMarkerad() {
    reset(puService);
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar(true, PersonSvar.Status.FOUND));
    WebCertUser user = (WebCertUser) testee.loadUserBySAML(new SAMLCredential(mock(NameID.class), assertionPrivatlakare, REMOTE_ENTITY_ID, LOCAL_ENTITY_ID));
    assertNotNull(user);
    assertTrue(user.isSekretessMarkerad());
    // WEBCERT-2028
    verify(avtalService, times(1)).userHasApprovedLatestAvtal(anyString());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) SAMLCredential(org.springframework.security.saml.SAMLCredential) NameID(org.opensaml.saml2.core.NameID) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 13 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class ElegWebCertUserDetailsServiceTest method testSuccessfulLogin.

@Test
public void testSuccessfulLogin() {
    WebCertUser user = (WebCertUser) testee.loadUserBySAML(new SAMLCredential(mock(NameID.class), assertionPrivatlakare, REMOTE_ENTITY_ID, LOCAL_ENTITY_ID));
    assertNotNull(user);
    assertFalse(user.isSekretessMarkerad());
    assertEquals(expectedPreferences, user.getAnvandarPreference());
    // WEBCERT-2028
    verify(avtalService, times(1)).userHasApprovedLatestAvtal(anyString());
}
Also used : SAMLCredential(org.springframework.security.saml.SAMLCredential) NameID(org.opensaml.saml2.core.NameID) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 14 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class AuthoritiesValidatorTest method testMustHaveFeatureFail.

@Test
public void testMustHaveFeatureFail() {
    WebCertUser user = createDefaultUser();
    assertFalse(validator.given(user, "fk7263").features(AuthoritiesConstants.FEATURE_ARBETSGIVARUTSKRIFT).isVerified());
    thrown.expect(AuthoritiesException.class);
    validator.given(user, "fk7263").features(AuthoritiesConstants.FEATURE_ARBETSGIVARUTSKRIFT).orThrow();
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 15 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class AuthoritiesValidatorTest method testMusthaveOrigin.

@Test
public void testMusthaveOrigin() {
    WebCertUser user = createDefaultUser();
    assertTrue(validator.given(user).origins(UserOriginType.NORMAL).isVerified());
}
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