[MNG-6401] IT for proxy port interpolation (#275)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6401ProxyPortInterpolationTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6401ProxyPortInterpolationTest.java
new file mode 100644
index 0000000..42c2cc6
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6401ProxyPortInterpolationTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.shared.verifier.Verifier;
+import org.apache.maven.shared.verifier.util.ResourceExtractor;
+import org.junit.jupiter.api.Test;
+
+class MavenITmng6401ProxyPortInterpolationTest extends AbstractMavenIntegrationTestCase {
+
+    private Proxy proxy;
+
+    private int port;
+
+    protected MavenITmng6401ProxyPortInterpolationTest() {
+        super("(4.0.0-alpha-7,)");
+    }
+
+    @Test
+    public void testitEnvVars() throws Exception {
+        File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-6401-proxy-port-interpolation");
+
+        Verifier verifier = newVerifier(testDir.getAbsolutePath());
+        verifier.setAutoclean(false);
+        verifier.deleteDirectory("target");
+        verifier.addCliArgument("--settings");
+        verifier.addCliArgument("settings.xml");
+        verifier.setEnvironmentVariable("MAVEN_PROXY_ACTIVE_BOOLEAN", "true");
+        verifier.setEnvironmentVariable("MAVEN_PROXY_HOST_STRING", "myproxy.host.net");
+        verifier.setEnvironmentVariable("MAVEN_PROXY_PORT_INT", "18080");
+        verifier.addCliArgument("validate");
+        verifier.execute();
+        verifier.verifyErrorFreeLog();
+
+        Properties props = verifier.loadProperties("target/settings.properties");
+        assertEquals("true", props.getProperty("settings.proxies.0.active"));
+        assertEquals("myproxy.host.net", props.getProperty("settings.proxies.0.host"));
+        assertEquals("18080", props.getProperty("settings.proxies.0.port"));
+    }
+}
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index 50a6929..2b8c5e9 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -120,6 +120,7 @@
          * the tests are to finishing. Newer tests are also more likely to fail, so this is
          * a fail fast technique as well.
          */
+        suite.addTestSuite(MavenITmng6401ProxyPortInterpolationTest.class);
         suite.addTestSuite(MavenITmng7228LeakyModelTest.class);
         suite.addTestSuite(MavenITmng7819FileLockingWithSnapshotsTest.class);
         suite.addTestSuite(MavenITmng5600DependencyManagementImportExclusionsTest.class);
diff --git a/core-it-suite/src/test/resources/mng-6401-proxy-port-interpolation/pom.xml b/core-it-suite/src/test/resources/mng-6401-proxy-port-interpolation/pom.xml
new file mode 100644
index 0000000..1e89933
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6401-proxy-port-interpolation/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng6401</groupId>
+  <artifactId>test</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-6401</name>
+  <description>Verify that the proxy/port in settings.xml can be interpolated using environment variables and system properties.</description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-expression</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>eval</goal>
+            </goals>
+            <phase>validate</phase>
+            <configuration>
+              <expressions>
+                <expression>settings/proxies/0/active</expression>
+                <expression>settings/proxies/0/host</expression>
+                <expression>settings/proxies/0/port</expression>
+              </expressions>
+              <outputFile>target/settings.properties</outputFile>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6401-proxy-port-interpolation/settings.xml b/core-it-suite/src/test/resources/mng-6401-proxy-port-interpolation/settings.xml
new file mode 100644
index 0000000..2b2d666
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6401-proxy-port-interpolation/settings.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings>
+  <proxies>
+    <proxy>
+      <id>my_proxy</id>
+      <active>${env.MAVEN_PROXY_ACTIVE_BOOLEAN}</active>
+      <protocol>http</protocol>
+      <host>${env.MAVEN_PROXY_HOST_STRING}</host>
+      <port>${env.MAVEN_PROXY_PORT_INT}</port>
+      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
+    </proxy>
+  </proxies>
+</settings>