use of org.opennms.netmgt.poller.MonitoredService in project opennms by OpenNMS.
the class RadiusAuthMonitorTest method testTTLSResponse.
@Test
@Ignore("have to have a EAP-TTLS radius server set up")
public void testTTLSResponse() throws Exception {
mockSrv.start(true, false);
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new RadiusAuthMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, InetAddressUtils.addr("127.0.0.1"), "RADIUS");
m.put("user", "testing");
m.put("password", "12");
m.put("retry", "1");
m.put("secret", "testing123");
m.put("authtype", "eap-ttls");
m.put("inner-user", "anonymous");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
System.out.println("Reason" + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
use of org.opennms.netmgt.poller.MonitoredService in project opennms by OpenNMS.
the class RadiusAuthMonitorTest method testBadResponses.
@Test
public void testBadResponses() throws Exception {
mockSrv.start(true, false);
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new RadiusAuthMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, InetAddressUtils.addr("127.0.0.1"), "RADIUS");
m.put("user", "testing");
m.put("password", "12");
m.put("retry", "1");
m.put("secret", "testing123");
m.put("authtype", "chap");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode());
MockLogAppender.assertLogMatched(Level.DEBUG, "response returned, but request was not accepted");
}
use of org.opennms.netmgt.poller.MonitoredService in project opennms by OpenNMS.
the class RadiusAuthMonitorTest method testTimeOut.
@Test
public void testTimeOut() throws Exception {
// do not start raddius server
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new RadiusAuthMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, InetAddressUtils.addr("127.0.0.1"), "RADIUS");
m.put("user", "testing");
m.put("password", "12");
m.put("retry", "1");
m.put("secret", "testing123");
m.put("authtype", "chap");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode());
MockLogAppender.assertLogMatched(Level.DEBUG, "Error while attempting to connect to the RADIUS service on localhost");
}
use of org.opennms.netmgt.poller.MonitoredService in project opennms by OpenNMS.
the class SeleniumMonitorTest method testPollStatusNotNull.
// Requires Firefox to be installed to run
@Test
@JUnitHttpServer(port = 10342, webapps = @Webapp(context = "/opennms", path = "src/test/resources/testWar"))
public void testPollStatusNotNull() throws UnknownHostException {
MonitoredService monSvc = new MockMonitoredService(1, "papajohns", InetAddressUtils.addr("213.187.33.164"), "PapaJohnsSite");
Map<String, Object> params = new HashMap<String, Object>();
params.put("selenium-test", "SeleniumGroovyTest.groovy");
params.put("base-url", "localhost");
params.put("port", "10342");
SeleniumMonitor ajaxPSM = new SeleniumMonitor();
PollStatus pollStatus = ajaxPSM.poll(monSvc, params);
assertNotNull("PollStatus must not be null", pollStatus);
System.err.println("PollStatus message: " + pollStatus.getReason());
assertEquals(PollStatus.available(), pollStatus);
}
use of org.opennms.netmgt.poller.MonitoredService in project opennms by OpenNMS.
the class HttpMonitorIT method callTestResponseRange.
public void callTestResponseRange(boolean preferIPv6) throws UnknownHostException {
if (m_runTests == false)
return;
Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
ServiceMonitor monitor = new HttpMonitor();
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost", preferIPv6), "HTTP");
final int port = JUnitHttpServerExecutionListener.getPort();
if (port > 0) {
m.put("port", String.valueOf(port));
} else {
throw new IllegalStateException("Unable to determine what port the HTTP server started on!");
}
m.put("retry", "1");
m.put("timeout", "500");
m.put("response", "100-199");
PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode());
assertNotNull(status.getReason());
m.put("response", "100,200,302,400-500");
monitor = new HttpMonitor();
status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
assertNull(status.getReason());
m.put("response", "*");
monitor = new HttpMonitor();
status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
assertNull(status.getReason());
}
Aggregations