Search in sources :

Example 6 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class SamlRegisteredServiceTests method verifySavingSamlService.

@Test
public void verifySavingSamlService() throws Exception {
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val registeredService = new SamlRegisteredService();
    registeredService.setName(SAML_SERVICE);
    registeredService.setServiceId("http://mmoayyed.unicon.net");
    registeredService.setMetadataLocation(METADATA_LOCATION);
    val dao = new JsonServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    dao.save(registeredService);
    dao.load();
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) Test(org.junit.jupiter.api.Test)

Example 7 with JsonServiceRegistry

use of org.apereo.cas.services.JsonServiceRegistry in project cas by apereo.

the class GrouperRegisteredServiceAccessStrategyTests method checkAccessStrategyJson.

@Test
public void checkAccessStrategyJson() throws Exception {
    val attributes = new HashMap<String, Set<String>>();
    val v1 = new HashSet<String>();
    v1.add("admin");
    attributes.put("memberOf", v1);
    val service = RegisteredServiceTestUtils.getRegisteredService("test");
    val grouper = new GrouperRegisteredServiceAccessStrategy();
    grouper.setConfigProperties(CollectionUtils.wrap("hello", "world"));
    grouper.setRequiredAttributes(attributes);
    service.setAccessStrategy(grouper);
    val appCtx = new StaticApplicationContext();
    appCtx.refresh();
    val dao = new JsonServiceRegistry(RESOURCE, WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
    val saved = dao.save(service);
    assertEquals(service, saved);
    assertFalse(dao.load().isEmpty());
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) HashMap(java.util.HashMap) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) JsonServiceRegistry(org.apereo.cas.services.JsonServiceRegistry) NoOpRegisteredServiceReplicationStrategy(org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

JsonServiceRegistry (org.apereo.cas.services.JsonServiceRegistry)7 NoOpRegisteredServiceReplicationStrategy (org.apereo.cas.services.replication.NoOpRegisteredServiceReplicationStrategy)6 lombok.val (lombok.val)4 DefaultRegisteredServiceResourceNamingStrategy (org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)3 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ChainingAttributeReleasePolicy (org.apereo.cas.services.ChainingAttributeReleasePolicy)2 DenyAllAttributeReleasePolicy (org.apereo.cas.services.DenyAllAttributeReleasePolicy)2 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)2 Set (java.util.Set)1 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)1 InCommonRSAttributeReleasePolicy (org.apereo.cas.support.saml.services.InCommonRSAttributeReleasePolicy)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1