SystemMonitorController { protected boolean checkAccess(HttpServletRequest request) { return OpenmrsUtil.nullSafeEquals(request.getRemoteAddr(), request.getLocalAddr()); }  @RequestMapping(value = "/sysmon.form", method = RequestMethod.GET) void get(HttpServletRequest request, HttpServletResponse response);  }
@Test public void checkAccess_shouldGrantAccessToLocalRequests() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setLocalAddr("1.2.3.4"); request.setRemoteAddr("1.2.3.4"); Assert.assertThat(controller.checkAccess(request), is(true)); request = new MockHttpServletRequest(); request.setLocalAddr("5.6.7.8"); request.setRemoteAddr("1.2.3.4"); Assert.assertThat(controller.checkAccess(request), is(false)); request = new MockHttpServletRequest(); request.setLocalAddr(null); request.setRemoteAddr("1.2.3.4"); Assert.assertThat(controller.checkAccess(request), is(false)); }