Search in sources :

Example 1 with DefaultRegisteredServiceConsentPolicy

use of org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy in project cas by apereo.

the class AbstractResourceBasedServiceRegistryTests method execSaveMethodWithConsentPolicy.

@Test
public void execSaveMethodWithConsentPolicy() {
    final RegexRegisteredService r = new RegexRegisteredService();
    r.setName("execSaveMethodWithConsentPolicy");
    r.setServiceId(SERVICE_ID);
    r.setTheme(THEME);
    r.setDescription(DESCRIPTION);
    final ReturnAllAttributeReleasePolicy policy = new ReturnAllAttributeReleasePolicy();
    policy.setConsentPolicy(new DefaultRegisteredServiceConsentPolicy(CollectionUtils.wrapSet("test"), CollectionUtils.wrapSet("test")));
    r.setAttributeReleasePolicy(policy);
    final RegisteredService r2 = this.dao.save(r);
    assertEquals(r2, r);
}
Also used : DefaultRegisteredServiceConsentPolicy(org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy) Test(org.junit.Test)

Example 2 with DefaultRegisteredServiceConsentPolicy

use of org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy in project cas by apereo.

the class AbstractServiceRegistryTests method execSaveMethodWithConsentPolicy.

@ParameterizedTest
@MethodSource(GET_PARAMETERS)
public void execSaveMethodWithConsentPolicy(final Class<? extends RegisteredService> registeredServiceClass) {
    val r = buildRegisteredServiceInstance(RandomUtils.nextInt(), registeredServiceClass);
    val policy = new ReturnAllAttributeReleasePolicy();
    policy.setConsentPolicy(new DefaultRegisteredServiceConsentPolicy(CollectionUtils.wrapSet("test"), CollectionUtils.wrapSet("test")));
    r.setAttributeReleasePolicy(policy);
    val r2 = this.serviceRegistry.save(r);
    val r3 = this.serviceRegistry.findServiceById(r2.getId());
    assertEquals(r2, r3);
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceConsentPolicy(org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with DefaultRegisteredServiceConsentPolicy

use of org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy in project cas by apereo.

the class DefaultConsentEngineTests method verifyConsentIgnored.

@Test
public void verifyConsentIgnored() {
    val authentication = CoreAuthenticationTestUtils.getAuthentication(UUID.randomUUID().toString());
    val service = CoreAuthenticationTestUtils.getService();
    val consentService = RegisteredServiceTestUtils.getRegisteredService("consentService");
    val policy = new ReturnAllAttributeReleasePolicy();
    policy.setConsentPolicy(new DefaultRegisteredServiceConsentPolicy());
    consentService.setAttributeReleasePolicy(policy);
    assertTrue(consentEngine.isConsentRequiredFor(service, consentService, authentication).isRequired());
}
Also used : lombok.val(lombok.val) ReturnAllAttributeReleasePolicy(org.apereo.cas.services.ReturnAllAttributeReleasePolicy) DefaultRegisteredServiceConsentPolicy(org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with DefaultRegisteredServiceConsentPolicy

use of org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy in project cas by apereo.

the class DefaultConsentEngineTests method verifyConsentIsRequiredByAttributeName.

@Test
public void verifyConsentIsRequiredByAttributeName() throws Exception {
    val authentication = CoreAuthenticationTestUtils.getAuthentication(UUID.randomUUID().toString());
    val service = CoreAuthenticationTestUtils.getService();
    val consentService = CoreAuthenticationTestUtils.getRegisteredService("consentService");
    val policy = new ReturnAllAttributeReleasePolicy();
    policy.setConsentPolicy(new DefaultRegisteredServiceConsentPolicy());
    when(consentService.getAttributeReleasePolicy()).thenReturn(policy);
    val decision = this.consentEngine.storeConsentDecision(service, consentService, authentication, 14, ChronoUnit.DAYS, ConsentReminderOptions.ATTRIBUTE_NAME);
    assertNotNull(decision);
    val result = this.consentEngine.isConsentRequiredFor(service, consentService, authentication);
    assertNotNull(result);
    assertFalse(result.isRequired());
}
Also used : lombok.val(lombok.val) ReturnAllAttributeReleasePolicy(org.apereo.cas.services.ReturnAllAttributeReleasePolicy) DefaultRegisteredServiceConsentPolicy(org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with DefaultRegisteredServiceConsentPolicy

use of org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy in project cas by apereo.

the class CheckConsentRequiredActionTests method getRegisteredServiceWithConsentStatus.

private RegisteredService getRegisteredServiceWithConsentStatus(final TriStateBoolean status) {
    val id = UUID.randomUUID().toString();
    val registeredService = RegisteredServiceTestUtils.getRegisteredService(id);
    val attrPolicy = new ReturnAllAttributeReleasePolicy();
    attrPolicy.setConsentPolicy(new DefaultRegisteredServiceConsentPolicy().setStatus(status));
    registeredService.setAttributeReleasePolicy(attrPolicy);
    servicesManager.save(registeredService);
    return registeredService;
}
Also used : lombok.val(lombok.val) ReturnAllAttributeReleasePolicy(org.apereo.cas.services.ReturnAllAttributeReleasePolicy) DefaultRegisteredServiceConsentPolicy(org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy)

Aggregations

DefaultRegisteredServiceConsentPolicy (org.apereo.cas.services.consent.DefaultRegisteredServiceConsentPolicy)14 lombok.val (lombok.val)11 ReturnAllAttributeReleasePolicy (org.apereo.cas.services.ReturnAllAttributeReleasePolicy)9 Test (org.junit.jupiter.api.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)2 Test (org.junit.Test)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SneakyThrows (lombok.SneakyThrows)1 AcceptUsersAuthenticationHandler (org.apereo.cas.authentication.AcceptUsersAuthenticationHandler)1 ConsentServiceRegistry (org.apereo.cas.consent.services.ConsentServiceRegistry)1 DefaultRegisteredServiceUsernameProvider (org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider)1 RegisteredService (org.apereo.cas.services.RegisteredService)1 ReturnAllowedAttributeReleasePolicy (org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1