ConfigController extends AbstractConsoleController { @RequestMapping(value = "/config/change_config", method = RequestMethod.POST) public RetMessage changeConfig(HttpServletRequest request, @RequestBody ConfigModel config) { logger.info("[changeConfig] Request IP: {}, Config Change To: {}", request.getRemoteAddr(), config); String sourceIp = request.getHeader("X-FORWARDED-FOR"); if(sourceIp == null) { sourceIp = request.getRemoteAddr(); } return changeConfig(config.getKey(), config.getVal(), sourceIp); }  @RequestMapping(value = "/config/change_config", method = RequestMethod.POST) RetMessage changeConfig(HttpServletRequest request, @RequestBody ConfigModel config); @RequestMapping(value = "/config/alert_system", method = RequestMethod.GET) RetMessage isAlertSystemOn(); @RequestMapping(value = "/config/sentinel_auto_process", method = RequestMethod.GET) RetMessage isSentinelAutoProcessOn();  }
@Test public void testChangeConfig1() throws Exception { ConfigModel model = new ConfigModel(); model.setKey(DefaultConsoleDbConfig.KEY_ALERT_SYSTEM_ON); model.setVal(String.valueOf(false)); RetMessage ret = controller.changeConfig(request, model); Assert.assertEquals(RetMessage.SUCCESS_STATE, ret.getState()); }
@Test public void testChangeConfig2() throws Exception { ConfigModel model = new ConfigModel(); model.setKey("Key Unknown"); model.setVal(String.valueOf(false)); RetMessage ret = controller.changeConfig(request, model); Assert.assertEquals(RetMessage.FAIL_STATE, ret.getState()); Assert.assertEquals("Unknown config key: Key Unknown", ret.getMessage()); }