use of org.motechproject.security.model.SecurityConfigDto in project motech by motech.
the class MotechURLSecurityServiceBundleIT method testUpdateSecurity.
@Test
public void testUpdateSecurity() {
motechUserService.register("admin", "admin", "admin@mail.com", "", asList(SECURITY_MANAGE_ADMIN), Locale.ENGLISH);
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken("admin", "admin");
Authentication auth = authenticationManager.authenticate(authRequest);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(auth);
List<SecurityRuleDto> rules = new ArrayList<>();
addRules(rules);
SecurityConfigDto configuration = new SecurityConfigDto();
configuration.setSecurityRules(rules);
securityService.updateSecurityConfiguration(configuration);
// Shouldn't return rule marked as deleted.
assertEquals(3, securityService.findAllSecurityRules().size());
}
use of org.motechproject.security.model.SecurityConfigDto in project motech by motech.
the class SecurityRulesController method getSecurityRules.
/**
* Returns security config
*
* @return security config
*/
@RequestMapping(value = "/web-api/securityRules", method = RequestMethod.GET)
@ResponseBody
public SecurityConfigDto getSecurityRules() {
SecurityConfigDto security = new SecurityConfigDto();
List<SecurityRuleDto> rules = urlSecurityService.findAllSecurityRules();
security.setSecurityRules(rules);
return security;
}
Aggregations