Search in sources :

Example 1 with AttributeFormDataPopulator

use of org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator 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);
}
Also used : BindingResult(org.springframework.validation.BindingResult) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultAccessStrategyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper) RegisteredServiceEditBean(org.apereo.cas.mgmt.services.web.beans.RegisteredServiceEditBean) DefaultProxyPolicyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper) RegisteredServiceSimpleFormController(org.apereo.cas.mgmt.services.web.RegisteredServiceSimpleFormController) DefaultRegisteredServiceFactory(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory) DefaultUsernameAttributeProviderMapper(org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AttributeFormDataPopulator(org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator) Test(org.junit.Test)

Example 2 with AttributeFormDataPopulator

use of org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator 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));
}
Also used : BindingResult(org.springframework.validation.BindingResult) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) DefaultAccessStrategyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper) RegisteredServiceEditBean(org.apereo.cas.mgmt.services.web.beans.RegisteredServiceEditBean) DefaultProxyPolicyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper) RegisteredServiceSimpleFormController(org.apereo.cas.mgmt.services.web.RegisteredServiceSimpleFormController) DefaultRegisteredServiceFactory(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory) DefaultUsernameAttributeProviderMapper(org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) AttributeFormDataPopulator(org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator) Test(org.junit.Test)

Example 3 with AttributeFormDataPopulator

use of org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator 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);
}
Also used : HashMap(java.util.HashMap) DefaultAccessStrategyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper) DefaultProxyPolicyMapper(org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper) DefaultRegisteredServiceMapper(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceMapper) InMemoryServiceRegistry(org.apereo.cas.services.InMemoryServiceRegistry) RegisteredServiceSimpleFormController(org.apereo.cas.mgmt.services.web.RegisteredServiceSimpleFormController) List(java.util.List) DefaultRegisteredServiceFactory(org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory) DefaultServicesManager(org.apereo.cas.services.DefaultServicesManager) DefaultUsernameAttributeProviderMapper(org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper) StubPersonAttributeDao(org.apereo.services.persondir.support.StubPersonAttributeDao) AttributeFormDataPopulator(org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator) Before(org.junit.Before)

Aggregations

RegisteredServiceSimpleFormController (org.apereo.cas.mgmt.services.web.RegisteredServiceSimpleFormController)3 AttributeFormDataPopulator (org.apereo.cas.mgmt.services.web.factory.AttributeFormDataPopulator)3 DefaultAccessStrategyMapper (org.apereo.cas.mgmt.services.web.factory.DefaultAccessStrategyMapper)3 DefaultProxyPolicyMapper (org.apereo.cas.mgmt.services.web.factory.DefaultProxyPolicyMapper)3 DefaultRegisteredServiceFactory (org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceFactory)3 DefaultUsernameAttributeProviderMapper (org.apereo.cas.mgmt.services.web.factory.DefaultUsernameAttributeProviderMapper)3 RegisteredServiceEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceEditBean)2 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)2 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)2 RegisteredService (org.apereo.cas.services.RegisteredService)2 Test (org.junit.Test)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 BindingResult (org.springframework.validation.BindingResult)2 HashMap (java.util.HashMap)1 List (java.util.List)1 DefaultRegisteredServiceMapper (org.apereo.cas.mgmt.services.web.factory.DefaultRegisteredServiceMapper)1 DefaultServicesManager (org.apereo.cas.services.DefaultServicesManager)1 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)1 StubPersonAttributeDao (org.apereo.services.persondir.support.StubPersonAttributeDao)1