From 9f29829ee6c0fd9678fe1916c01d2f2b4d69b446 Mon Sep 17 00:00:00 2001 From: Max Kalika Date: Sat, 21 Jan 2017 22:39:05 -0800 Subject: [PATCH] Issue #147: Add tests for ConnectionManager.getHost(String host). --- .../jmxproxy/jmx/tests/ConnectionManagerTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/com/github/mk23/jmxproxy/jmx/tests/ConnectionManagerTest.java b/src/test/java/com/github/mk23/jmxproxy/jmx/tests/ConnectionManagerTest.java index 3679957..a68d84c 100644 --- a/src/test/java/com/github/mk23/jmxproxy/jmx/tests/ConnectionManagerTest.java +++ b/src/test/java/com/github/mk23/jmxproxy/jmx/tests/ConnectionManagerTest.java @@ -28,6 +28,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeNotNull; +import static org.junit.Assume.assumeTrue; public class ConnectionManagerTest { private final String passwdFile = System.getProperty("com.sun.management.jmxremote.password.file"); @@ -104,6 +105,20 @@ public void checkValidHostInvalidAuth() throws Exception { assumeNotNull(passwdFile); manager.getHost(validHost, invalidAuth); } + @Test + public void checkValidHostAnonymousAuthAllowed() throws Exception { + final ConnectionManager manager = new ConnectionManager(new AppConfig()); + + assumeTrue(passwdFile == null); + assertNotNull(manager.getHost(validHost)); + } + @Test(expected=WebApplicationException.class) + public void checkValidHostAnonymousAuthDisallowed() throws Exception { + final ConnectionManager manager = new ConnectionManager(new AppConfig()); + + assumeNotNull(passwdFile); + manager.getHost(validHost); + } /* Host tests */ @Test