Search in sources :

Example 1 with SAMLCredential

use of org.springframework.security.saml.SAMLCredential 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 2 with SAMLCredential

use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.

the class ElegWebCertUserDetailsServiceTest method testNotFoundInHSAThrowsException.

@Test
public void testNotFoundInHSAThrowsException() {
    reset(ppService);
    when(ppService.validatePrivatePractitioner(any(), any(), any())).thenReturn(true);
    when(ppService.getPrivatePractitioner(any(), any(), any())).thenReturn(null);
    thrown.expect(HsaServiceException.class);
    testee.loadUserBySAML(new SAMLCredential(mock(NameID.class), assertionPrivatlakare, REMOTE_ENTITY_ID, LOCAL_ENTITY_ID));
}
Also used : SAMLCredential(org.springframework.security.saml.SAMLCredential) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 3 with SAMLCredential

use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.

the class ElegWebCertUserDetailsServiceTest method testNotValidPrivatePractitionerThrowsException.

@Test
public void testNotValidPrivatePractitionerThrowsException() {
    reset(ppService);
    when(ppService.validatePrivatePractitioner(any(), any(), any())).thenReturn(false);
    thrown.expect(PrivatePractitionerAuthorizationException.class);
    testee.loadUserBySAML(new SAMLCredential(mock(NameID.class), assertionPrivatlakare, REMOTE_ENTITY_ID, LOCAL_ENTITY_ID));
}
Also used : SAMLCredential(org.springframework.security.saml.SAMLCredential) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 4 with SAMLCredential

use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.

the class ElegWebCertUserDetailsServiceTest method testLoginPUErrorThrowsException.

@Test
public void testLoginPUErrorThrowsException() {
    reset(puService);
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar(true, PersonSvar.Status.ERROR));
    thrown.expect(HsaServiceException.class);
    testee.loadUserBySAML(new SAMLCredential(mock(NameID.class), assertionPrivatlakare, REMOTE_ENTITY_ID, LOCAL_ENTITY_ID));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) SAMLCredential(org.springframework.security.saml.SAMLCredential) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 5 with SAMLCredential

use of org.springframework.security.saml.SAMLCredential 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)

Aggregations

SAMLCredential (org.springframework.security.saml.SAMLCredential)12 Test (org.junit.Test)8 BaseSAMLCredentialTest (se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest)8 NameID (org.opensaml.saml2.core.NameID)4 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 Assertion (org.opensaml.saml2.core.Assertion)2 AttributeStatement (org.opensaml.saml2.core.AttributeStatement)2 AssertionBuilder (org.opensaml.saml2.core.impl.AssertionBuilder)2 AttributeStatementBuilder (org.opensaml.saml2.core.impl.AttributeStatementBuilder)2 NameIDBuilder (org.opensaml.saml2.core.impl.NameIDBuilder)2 ExpiringUsernameAuthenticationToken (org.springframework.security.providers.ExpiringUsernameAuthenticationToken)2 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)2 BaseSakerhetstjanstAssertion (se.inera.intyg.infra.security.siths.BaseSakerhetstjanstAssertion)1 FakeCredentials (se.inera.intyg.webcert.web.auth.fake.FakeCredentials)1