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