use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class SSLCertMonitorIT method testExpiringDateForCertificate.
@Test
@JUnitHttpServer(port = 10342, https = true)
public void testExpiringDateForCertificate() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 4);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isUnavailable());
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class SSLCertMonitorIT method testHostNameVerificationSucceeds.
@Test
@JUnitHttpServer(port = 10342, https = true, vhosts = "test.example.com")
public void testHostNameVerificationSucceeds() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 5);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
parameters.put("server-name", "${nodelabel}.example.com");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "test", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isAvailable());
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class SSLCertMonitorIT method testValidDateForCertificate.
@Test
@JUnitHttpServer(port = 10342, https = true)
public void testValidDateForCertificate() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 5);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isAvailable());
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class JUnitHttpServerTest method testBasicAuthSuccess.
@Test
@JUnitHttpServer(port = 9162, basicAuth = true, webapps = { @Webapp(context = "/testContext", path = "src/test/resources/test-webapp") })
public void testBasicAuthSuccess() throws Exception {
final HttpUriRequest method = new HttpGet("http://localhost:9162/testContext/monkey");
m_clientWrapper.addBasicCredentials("admin", "istrator");
final HttpResponse response = m_clientWrapper.execute(method);
final String responseString = EntityUtils.toString(response.getEntity());
LOG.debug("got response:\n{}", responseString);
assertEquals(200, response.getStatusLine().getStatusCode());
assertTrue(responseString.contains("You are reading this from a servlet!"));
}
use of org.opennms.core.test.http.annotations.JUnitHttpServer in project opennms by OpenNMS.
the class JUnitHttpServerTest method testServer.
@Test
@JUnitHttpServer(port = 9162)
public void testServer() throws HttpException, IOException {
HttpUriRequest method = new HttpGet("http://localhost:9162/test.html");
final CloseableHttpResponse response = m_clientWrapper.execute(method);
String responseString = EntityUtils.toString(response.getEntity());
LOG.debug("got response:\n{}", responseString);
assertEquals(200, response.getStatusLine().getStatusCode());
assertTrue(responseString.contains("Purple monkey dishwasher."));
}
Aggregations