use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class SamlRegisteredServiceTests method verifySavingInCommonSamlService.
@Test
public void verifySavingInCommonSamlService() throws Exception {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val service = new SamlRegisteredService();
service.setName(SAML_SERVICE);
service.setServiceId("http://mmoayyed.unicon.net");
service.setMetadataLocation(METADATA_LOCATION);
val policy = new InCommonRSAttributeReleasePolicy();
val chain = new ChainingAttributeReleasePolicy();
chain.setPolicies(Arrays.asList(policy, new DenyAllAttributeReleasePolicy()));
service.setAttributeReleasePolicy(chain);
val dao = new JsonServiceRegistry(new FileSystemResource(FileUtils.getTempDirectoryPath() + File.separator + "json-service-registry"), WatcherService.noOp(), appCtx, new NoOpRegisteredServiceReplicationStrategy(), new DefaultRegisteredServiceResourceNamingStrategy(), new ArrayList<>());
dao.save(service);
dao.load();
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class SamlRegisteredServiceAttributeReleasePolicyTests method verifyBadServiceProvider.
@Test
public void verifyBadServiceProvider() {
val resolver = mock(SamlRegisteredServiceCachingMetadataResolver.class);
when(resolver.resolve(any(), any())).thenReturn(mock(MetadataResolver.class));
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, new CasConfigurationProperties(), "CasConfigurationProperties");
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, resolver, SamlRegisteredServiceCachingMetadataResolver.DEFAULT_BEAN_NAME);
ApplicationContextProvider.holdApplicationContext(applicationContext);
val registeredService = SamlIdPTestUtils.getSamlRegisteredService();
registeredService.setServiceId("https://sp.cas.org");
val policy = new EduPersonTargetedIdAttributeReleasePolicy();
val releasePolicyContext = RegisteredServiceAttributeReleasePolicyContext.builder().registeredService(registeredService).service(CoreAuthenticationTestUtils.getService("https://sp.cas.org")).principal(CoreAuthenticationTestUtils.getPrincipal("casuser")).build();
val attributes = policy.getAttributes(releasePolicyContext);
assertTrue(attributes.isEmpty());
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class YubiKeyAccountSaveRegistrationActionTests method setup.
@BeforeEach
public void setup() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, new YubiKeyMultifactorAuthenticationProvider());
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class ApplicationContextProviderTests method verifyOperation.
@Test
public void verifyOperation() {
val appCtx = new StaticApplicationContext();
appCtx.refresh();
val container = BeanContainer.of("Hello", "World");
appCtx.registerBean("beanContainer", BeanContainer.class);
appCtx.getBeanFactory().initializeBean(container, "beanContainer");
appCtx.getBeanFactory().autowireBean(container);
appCtx.getBeanFactory().registerSingleton("beanContainer", container);
ApplicationContextProvider.holdApplicationContext(appCtx);
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
val holding = new HoldingBeanContainer();
ApplicationContextProvider.processBeanInjections(holding);
assertNotNull(holding.getContainer());
assertEquals(2, holding.getContainer().size());
}
});
}
use of org.springframework.context.support.StaticApplicationContext in project cas by apereo.
the class DelegatingControllerTests method verifyFails.
@Test
public void verifyFails() throws Exception {
val request = new MockHttpServletRequest();
request.setMethod("POST");
val response = new MockHttpServletResponse();
val ctrl = new DelegatingController();
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ctrl.setApplicationContext(applicationContext);
val mv = ctrl.handleRequest(request, response);
assertNotNull(mv);
assertEquals(ctrl.getFailureView(), mv.getViewName());
}
Aggregations