use of org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method verifyEditMockRegisteredService.
@Test
public void verifyEditMockRegisteredService() throws Exception {
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new MockRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.singletonList(new AttributeFormDataPopulator(this.repository)));
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
final MockRegisteredService r = new MockRegisteredService();
r.setId(1000);
r.setName("Test Service");
r.setServiceId(TEST_ID);
r.setDescription(DESCRIPTION);
this.manager.save(r);
r.setServiceId("serviceId1");
final RegisteredServiceEditBean.ServiceData data = registeredServiceFactory.createServiceData(r);
this.controller.saveService(new MockHttpServletRequest(), new MockHttpServletResponse(), data, mock(BindingResult.class));
assertFalse(this.manager.getAllServices().isEmpty());
final RegisteredService r2 = this.manager.findServiceBy(1000);
assertEquals("serviceId1", r2.getServiceId());
assertTrue(r2 instanceof MockRegisteredService);
}
use of org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method verifyAddMockRegisteredService.
@Test
public void verifyAddMockRegisteredService() throws Exception {
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new MockRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.singletonList(new AttributeFormDataPopulator(this.repository)));
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
final MockRegisteredService svc = new MockRegisteredService();
svc.setDescription(DESCRIPTION);
svc.setServiceId("^serviceId");
svc.setName(NAME);
svc.setId(1000);
svc.setEvaluationOrder(1000);
final RegisteredServiceEditBean.ServiceData data = registeredServiceFactory.createServiceData(svc);
this.controller.saveService(new MockHttpServletRequest(), new MockHttpServletResponse(), data, mock(BindingResult.class));
final Collection<RegisteredService> services = this.manager.getAllServices();
assertEquals(1, services.size());
this.manager.getAllServices().forEach(rs -> assertTrue(rs instanceof MockRegisteredService));
}
use of org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper in project cas by apereo.
the class ManageRegisteredServicesMultiActionControllerTests method verifyCustomComponents.
@Test
public void verifyCustomComponents() throws Exception {
// override the RegisteredServiceMapper
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new CustomRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.emptyList());
this.controller = new ManageRegisteredServicesMultiActionController(this.servicesManager, this.registeredServiceFactory, new WebApplicationServiceFactory(), "https://cas.example.org");
final RegexRegisteredService r = new RegexRegisteredService();
r.setId(1200);
r.setName(NAME);
r.setDescription(UNIQUE_DESCRIPTION);
r.setServiceId("test");
r.setEvaluationOrder(2);
this.servicesManager.save(r);
final MockHttpServletResponse response = new MockHttpServletResponse();
final ModelAndView mv = this.controller.manage(response);
assertTrue(mv.getModel().containsKey("defaultServiceUrl"));
assertTrue(mv.getModel().containsKey("status"));
this.controller.getServices(response);
final String content = response.getContentAsString();
assertTrue(content.contains(SERVICES));
assertTrue(content.contains(UNIQUE_DESCRIPTION));
assertTrue(content.contains("customComponent1"));
assertTrue(content.contains("key2"));
}
use of org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper in project cas by apereo.
the class RegisteredServiceSimpleFormControllerTests method setUp.
@Before
public void setUp() throws Exception {
final Map<String, List<Object>> attributes = new HashMap<>();
attributes.put(TEST_ID, Arrays.asList(new Object[] { TEST_ID }));
this.repository = new StubPersonAttributeDao();
this.repository.setBackingMap(attributes);
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new DefaultRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.singletonList(new AttributeFormDataPopulator(this.repository)));
this.manager = new DefaultServicesManager(new InMemoryServiceRegistry());
this.controller = new RegisteredServiceSimpleFormController(this.manager, this.registeredServiceFactory);
}
use of org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper in project cas by apereo.
the class ManageRegisteredServicesMultiActionControllerTests method setUp.
@Before
public void setUp() throws Exception {
this.servicesManager = new DefaultServicesManager(new InMemoryServiceRegistry());
this.registeredServiceFactory = new DefaultRegisteredServiceFactory(new DefaultAccessStrategyMapper(), policyMapper, new DefaultProxyPolicyMapper(), new DefaultRegisteredServiceMapper(), new DefaultUsernameAttributeProviderMapper(), Collections.emptyList());
this.controller = new ManageRegisteredServicesMultiActionController(this.servicesManager, this.registeredServiceFactory, new WebApplicationServiceFactory(), "https://cas.example.org");
}
Aggregations