|
22 | 22 | import java.io.ByteArrayOutputStream;
|
23 | 23 | import java.io.InputStream;
|
24 | 24 | import java.io.PrintStream;
|
| 25 | +import java.net.Inet4Address; |
| 26 | +import java.net.InetAddress; |
| 27 | +import java.net.UnknownHostException; |
25 | 28 | import java.nio.charset.StandardCharsets;
|
26 | 29 | import java.nio.file.Files;
|
27 | 30 | import java.nio.file.Path;
|
|
46 | 49 | import org.jboss.as.controller.client.helpers.Operations;
|
47 | 50 | import org.jboss.as.controller.client.impl.AdditionalBootCliScriptInvoker;
|
48 | 51 | import org.jboss.as.controller.operations.common.Util;
|
| 52 | +import org.jboss.as.network.NetworkUtils; |
49 | 53 | import org.jboss.as.test.integration.management.util.CLIWrapper;
|
50 | 54 | import org.jboss.as.test.shared.AssumeTestGroupUtil;
|
| 55 | +import org.jboss.as.test.shared.TestSuiteEnvironment; |
51 | 56 | import org.jboss.as.test.shared.TimeoutUtil;
|
52 | 57 | import org.jboss.dmr.ModelNode;
|
53 | 58 | import org.jboss.logging.Logger;
|
@@ -93,6 +98,7 @@ public class YamlExtensionTestCase {
|
93 | 98 | private static Path testSocketOverrideYaml;
|
94 | 99 | private static Path testPortOffsetOverrideYaml;
|
95 | 100 | private static Path testRemoveSocketYaml;
|
| 101 | + private static Path testInterfaceOverrideYaml; |
96 | 102 | private static Path testAddingExtensionPathDeploymentOverlayIgnored;
|
97 | 103 | private static Path testAddingEmptyExtensionFailYaml;
|
98 | 104 | private static Path testDeploymentYaml;
|
@@ -151,6 +157,7 @@ public static void setup() throws Exception {
|
151 | 157 | testSocketOverrideYaml = getResourceFilePath("test-socket-override.yml");
|
152 | 158 | testPortOffsetOverrideYaml = getResourceFilePath("test-port-offset-override.yml");
|
153 | 159 | testRemoveSocketYaml = getResourceFilePath("test-remove-socket.yml");
|
| 160 | + testInterfaceOverrideYaml = getResourceFilePath("test-interface-override.yml"); |
154 | 161 | testAddingExtensionPathDeploymentOverlayIgnored = getResourceFilePath("test-adding-extension-path-deployment-overlay-ignored.yml");
|
155 | 162 | testAddingEmptyExtensionFailYaml = getResourceFilePath("test-adding-empty-extension.yml");
|
156 | 163 | testDeploymentYaml = getResourceFilePath("test-deployment.yml");
|
@@ -644,6 +651,21 @@ public void testPostStartCLIChangesToModelDoNotSurviveRestart() throws Exception
|
644 | 651 | Assert.assertEquals("Yaml changes to configuration were persisted to xml. This should never happen.", defaultXml, readConfigAsXml());
|
645 | 652 | }
|
646 | 653 |
|
| 654 | + @Test |
| 655 | + public void testInterfaceOverride() throws UnknownHostException { |
| 656 | + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| 657 | + container.startYamlExtension(new PrintStream(byteArrayOutputStream), new Path[]{testInterfaceOverrideYaml}); |
| 658 | + String logged = byteArrayOutputStream.toString(); |
| 659 | + |
| 660 | + InetAddress serverAddress = InetAddress.getByName(TestSuiteEnvironment.getServerAddress()); |
| 661 | + String expectedAddress = serverAddress instanceof Inet4Address ? "0.0.0.0" : "[0:0:0:0:0:0:0:0]"; |
| 662 | + String expectedConsoleOutput = "http://"+ expectedAddress + ":9990/management"; |
| 663 | + assertThat("The server didn't log it is listening on address 0.0.0.0.", logged, CoreMatchers.containsString(expectedConsoleOutput)); |
| 664 | + String unexpectedAddress = NetworkUtils.formatIPAddressForURI(serverAddress); |
| 665 | + String unexpectedConsoleOutput = "http://" + unexpectedAddress + ":9990/management"; |
| 666 | + assertThat("The server logged it is listening on address 127.0.0.1.", logged, CoreMatchers.not(CoreMatchers.containsString(unexpectedConsoleOutput))); |
| 667 | + } |
| 668 | + |
647 | 669 | private void waitForRunningMode(String runningMode) throws Exception {
|
648 | 670 | // Following a reload to normal mode, we might read the running mode too early and hit the admin-only server
|
649 | 671 | // Cycle around a bit to make sure we get the server reloaded into normal mode
|
|
0 commit comments