use of org.apereo.cas.services.InMemoryServiceRegistry in project cas by apereo.
the class Saml10SuccessResponseViewTests method setUp.
@Before
public void setUp() {
final List<RegisteredService> list = new ArrayList<>();
list.add(RegisteredServiceTestUtils.getRegisteredService("https://.+"));
final InMemoryServiceRegistry dao = new InMemoryServiceRegistry();
dao.setRegisteredServices(list);
final ServicesManager mgmr = new DefaultServicesManager(dao, mock(ApplicationEventPublisher.class));
mgmr.load();
this.response = new Saml10SuccessResponseView(new DefaultCasProtocolAttributeEncoder(mgmr, CipherExecutor.noOpOfStringToString()), mgmr, "attribute", new Saml10ObjectBuilder(configBean), new DefaultArgumentExtractor(new SamlServiceFactory()), StandardCharsets.UTF_8.name(), 1000, 30, "testIssuer", "whatever", new DefaultAuthenticationAttributeReleasePolicy());
}
use of org.apereo.cas.services.InMemoryServiceRegistry in project cas by apereo.
the class DefaultRegisteredServiceReplicationStrategyTests method verifyUpdateWithNoMatch.
@Test
public void verifyUpdateWithNoMatch() {
val id = new PublisherIdentifier();
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val serviceRegistry = new InMemoryServiceRegistry(appCtx);
val stream = casProperties.getServiceRegistry().getStream();
val mgr = mock(DistributedCacheManager.class);
val service = newService("Test1");
service.setId(500);
val cachedService = newService("Test2");
val object = DistributedCacheObject.<RegisteredService>builder().value(cachedService).publisherIdentifier(id).build();
when(mgr.getAll()).thenReturn(CollectionUtils.wrapList(object));
val strategy = new DefaultRegisteredServiceReplicationStrategy(mgr, stream, id);
val results = strategy.updateLoadedRegisteredServicesFromCache(CollectionUtils.wrapList(service), serviceRegistry);
assertFalse(results.isEmpty());
assertEquals(2, results.size());
}
use of org.apereo.cas.services.InMemoryServiceRegistry in project cas by apereo.
the class DefaultRegisteredServiceReplicationStrategyTests method verifyGetInCacheAndUpdate.
@Test
public void verifyGetInCacheAndUpdate() {
val id = new PublisherIdentifier();
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val serviceRegistry = new InMemoryServiceRegistry(appCtx);
val stream = casProperties.getServiceRegistry().getStream();
val mgr = mock(DistributedCacheManager.class);
val strategy = new DefaultRegisteredServiceReplicationStrategy(mgr, stream, id);
val service = newService("Test");
val service2 = newService("Test1");
val object = DistributedCacheObject.<RegisteredService>builder().value(service2).publisherIdentifier(id).build();
when(mgr.find(any())).thenReturn(Optional.of(object));
var svc = strategy.getRegisteredServiceFromCacheIfAny(service, 1000, serviceRegistry);
assertNotNull(svc);
assertEquals(serviceRegistry.size(), 1);
svc = serviceRegistry.findServiceById(1000);
assertEquals("Test1", svc.getName());
}
use of org.apereo.cas.services.InMemoryServiceRegistry in project cas by apereo.
the class DefaultRegisteredServiceReplicationStrategyTests method verifySetInCache.
@Test
public void verifySetInCache() {
val id = new PublisherIdentifier();
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val serviceRegistry = new InMemoryServiceRegistry(appCtx);
val stream = casProperties.getServiceRegistry().getStream();
val mgr = mock(DistributedCacheManager.class);
val strategy = new DefaultRegisteredServiceReplicationStrategy(mgr, stream, id);
when(mgr.find(any())).thenReturn(Optional.empty());
var svc = strategy.getRegisteredServiceFromCacheIfAny(newService("Test"), 1000, serviceRegistry);
assertNotNull(svc);
svc = strategy.getRegisteredServiceFromCacheIfAny(newService("Test"), "https://example.org", serviceRegistry);
assertNotNull(svc);
strategy.destroy();
}
use of org.apereo.cas.services.InMemoryServiceRegistry in project cas by apereo.
the class DefaultRegisteredServiceReplicationStrategyTests method verifyGetInCacheAndMatch.
@Test
public void verifyGetInCacheAndMatch() {
val id = new PublisherIdentifier();
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val serviceRegistry = new InMemoryServiceRegistry(appCtx);
val stream = casProperties.getServiceRegistry().getStream();
val mgr = mock(DistributedCacheManager.class);
val strategy = new DefaultRegisteredServiceReplicationStrategy(mgr, stream, id);
val service = newService("Test");
val service2 = newService("Test");
val object = DistributedCacheObject.<RegisteredService>builder().value(service2).publisherIdentifier(id).build();
when(mgr.find(any())).thenReturn(Optional.of(object));
var svc = strategy.getRegisteredServiceFromCacheIfAny(service, 1000, serviceRegistry);
assertNotNull(svc);
assertEquals(serviceRegistry.size(), 0);
}
Aggregations