@Test public void testManagementHostInitializationWithEncryptionNoErrors() throws Throwable { File keyFile = Paths.get(folder.newFolder().getPath(), "encryption.key").toFile(); System.setProperty(EncryptionUtils.ENCRYPTION_KEY, keyFile.getPath()); System.setProperty(EncryptionUtils.INIT_KEY_IF_MISSING, "true"); EncryptionUtils.initEncryptionService(); try (TestManagementHost host = new TestManagementHost(false)) { // we're just verifying that no exceptions are thrown assertNull(host.getSecureListener()); } }
@Test public void testManagementHostInitializationWithNodeGroup() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8292", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8292", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8292")) { host.start(); host.startManagementServices(); AtomicInteger statusCode = new AtomicInteger(0); Operation op = Operation .createGet(UriUtils.buildUri(host, MockDockerAdapterService.SELF_LINK)) .setReferer(host.getUri()) .setCompletion((o, e) -> { if (e == null) { statusCode.set(o.getStatusCode()); host.getTestContext().completeIteration(); } else { host.getTestContext().failIteration(e); } }); host.sendRequest(op); host.getTestContext().await(); assertEquals("The MockHostInteractionService didn't start.", 204, statusCode.get()); } }
@Test public void testManagementHostInitialization() throws Throwable { try (TestManagementHost host = new TestManagementHost(true)) { host.start(); host.startManagementServices(); AtomicInteger statusCode = new AtomicInteger(0); Operation op = Operation .createGet(UriUtils.buildUri(host, MockDockerAdapterService.SELF_LINK)) .setReferer(host.getUri()) .setCompletion((o, e) -> { if (e == null) { statusCode.set(o.getStatusCode()); host.getTestContext().completeIteration(); } else { host.getTestContext().failIteration(e); } }); host.sendRequest(op); host.getTestContext().await(); assertEquals("The MockHostInteractionService didn't start.", 204, statusCode.get()); assertTrue(host.isProcessOwner()); } }
@Test public void testManagementHostUpdateConfigurationOnRestart() throws Throwable { ConfigurationServiceTest.overrideConfigurationPropertiesFile("/configuration-0.properties"); try (TestManagementHost host = new TestManagementHost(true)) { host.start(); host.registerForServiceAvailability(host.getTestContext().getCompletion(), try (TestManagementHost host = new TestManagementHost(true)) { host.start(); host.registerForServiceAvailability(host.getTestContext().getCompletion(),
@Test public void testResourcePoolDelete() throws Throwable { try (TestManagementHost host = new TestManagementHost(true)) { host.start(); host.startFabricServices();
@Test public void testCredentialsDelete() throws Throwable { try (TestManagementHost host = new TestManagementHost(true)) { host.start(); host.startFabricServices();
@Test(expected = IllegalArgumentException.class) public void testManagementHostInitializationErrorSameSecurePort() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "port" + ARGUMENT_ASSIGNMENT + "-1", ARGUMENT_PREFIX + "securePort" + ARGUMENT_ASSIGNMENT + "8283", ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "https://127.0.0.1:8283", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "https://127.0.0.1:8283", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "https://127.0.0.1:8283")) { // we're just verifying that exception is thrown } }
@Test(expected = IllegalArgumentException.class) public void testManagementHostInitializationErrorSamePort() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282")) { // we're just verifying that exception is thrown } }
@Test(expected = IllegalArgumentException.class) public void testManagementHostInitializationErrorBigNodeGroupPort() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:90000", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282")) { // we're just verifying that exception is thrown } }
@Test public void testManagementHostInitializationNoErrorsWithNodeGroup() throws Throwable { try (TestManagementHost host = new TestManagementHost(false, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8292", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8292", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8292")) { // we're just verifying that no exceptions are thrown } }
@Test(expected = IllegalArgumentException.class) public void testManagementHostInitializationErrorNoNodeGroupPort() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282")) { // we're just verifying that exception is thrown } }
@Test(expected = IllegalArgumentException.class) public void testManagementHostInitializationErrorNoNodeGroupHost() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "http//:8283", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282")) { // we're just verifying that exception is thrown } }
@Test(expected = IllegalArgumentException.class) public void testManagementHostInitializationErrorNoNodeGroupScheme() throws Throwable { try (TestManagementHost host = new TestManagementHost(true, ARGUMENT_PREFIX + "publicUri" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282", ARGUMENT_PREFIX + "nodeGroupPublicUri" + ARGUMENT_ASSIGNMENT + "//127.0.0.1:8283", ARGUMENT_PREFIX + "peerList" + ARGUMENT_ASSIGNMENT + "http://127.0.0.1:8282")) { // we're just verifying that exception is thrown } }
@Test public void testManagementHostInitializationNoErrors() throws Throwable { try (TestManagementHost host = new TestManagementHost(false)) { // we're just verifying that no exceptions are thrown assertNull(host.getSecureListener()); } }
@Test public void testManagementHostInitializationWithSslNoErrors() throws Throwable { try (TestManagementHost host = new TestManagementHost(false, ARGUMENT_PREFIX + "port" + ARGUMENT_ASSIGNMENT + "-1", ARGUMENT_PREFIX + "securePort" + ARGUMENT_ASSIGNMENT + "8283")) { // we're just verifying that no exceptions are thrown assertNotNull(host.getSecureListener()); } }