You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/11/25 21:20:25 UTC

svn commit: r884248 - in /maven/core-integration-testing/trunk/core-it-suite/src/test: java/org/apache/maven/it/ resources/mng-4470/ resources/mng-4470/release/ resources/mng-4470/snapshot/

Author: bentmann
Date: Wed Nov 25 20:20:24 2009
New Revision: 884248

URL: http://svn.apache.org/viewvc?rev=884248&view=rev
Log:
[MNG-4470] [regression] Proxies are ignored during artifact deployment

o Added IT

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml   (with props)
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=884248&r1=884247&r2=884248&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java Wed Nov 25 20:20:24 2009
@@ -85,6 +85,7 @@
         // suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
 
+        suite.addTestSuite( MavenITmng4470AuthenticatedDeploymentToProxyTest.class );
         suite.addTestSuite( MavenITmng4469AuthenticatedDeploymentToCustomRepoTest.class );
         suite.addTestSuite( MavenITmng4465PluginPrefixFromLocalCacheOfDownRepoTest.class );
         suite.addTestSuite( MavenITmng4461ArtifactUploadMonitorTest.class );

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java?rev=884248&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java Wed Nov 25 20:20:24 2009
@@ -0,0 +1,193 @@
+package org.apache.maven.it;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.handler.HandlerList;
+import org.mortbay.jetty.security.B64Code;
+import org.mortbay.jetty.security.Constraint;
+import org.mortbay.jetty.security.ConstraintMapping;
+import org.mortbay.jetty.security.HashUserRealm;
+import org.mortbay.jetty.security.SecurityHandler;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4470">MNG-4470</a>.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class MavenITmng4470AuthenticatedDeploymentToProxyTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    private Server server;
+
+    private int port;
+
+    private boolean deployed;
+
+    public MavenITmng4470AuthenticatedDeploymentToProxyTest()
+    {
+        super( "[2.0.3,3.0-alpha-1),[3.0-alpha-6,)" );
+    }
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        Handler proxyHandler = new AbstractHandler()
+        {
+            public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+                throws IOException, ServletException
+            {
+                System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
+
+                String auth = request.getHeader( "Proxy-Authorization" );
+                if ( auth != null )
+                {
+                    auth = auth.substring( auth.indexOf( ' ' ) + 1 ).trim();
+                    auth = B64Code.decode( auth );
+                }
+                System.out.println( "Proxy-Authorization: " + auth );
+
+                if ( !"proxyuser:proxypass".equals( auth ) )
+                {
+                    response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
+                    response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" );
+                    ( (Request) request ).setHandled( true );
+                }
+            }
+        };
+
+        Handler repoHandler = new AbstractHandler()
+        {
+            public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
+                throws IOException, ServletException
+            {
+                System.out.println( "Handling " + request.getMethod() + " " + request.getRequestURL() );
+
+                if ( "PUT".equalsIgnoreCase( request.getMethod() ) )
+                {
+                    response.setStatus( HttpServletResponse.SC_OK );
+                    deployed = true;
+                }
+                else
+                {
+                    response.setStatus( HttpServletResponse.SC_NOT_FOUND );
+                }
+
+                ( (Request) request ).setHandled( true );
+            }
+        };
+
+        Constraint constraint = new Constraint();
+        constraint.setName( Constraint.__BASIC_AUTH );
+        constraint.setRoles( new String[] { "deployer" } );
+        constraint.setAuthenticate( true );
+
+        ConstraintMapping constraintMapping = new ConstraintMapping();
+        constraintMapping.setConstraint( constraint );
+        constraintMapping.setPathSpec( "/*" );
+
+        HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
+        userRealm.put( "testuser", "testtest" );
+        userRealm.addUserToRole( "testuser", "deployer" );
+
+        SecurityHandler securityHandler = new SecurityHandler();
+        securityHandler.setUserRealm( userRealm );
+        securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
+
+        HandlerList handlerList = new HandlerList();
+        handlerList.addHandler( proxyHandler );
+        handlerList.addHandler( securityHandler );
+        handlerList.addHandler( repoHandler );
+
+        server = new Server( 0 );
+        server.setHandler( handlerList );
+        server.start();
+
+        port = server.getConnectors()[0].getLocalPort();
+
+        deployed = false;
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        if ( server != null )
+        {
+            server.stop();
+            server = null;
+        }
+
+        super.tearDown();
+    }
+
+    /**
+     * Test that deployment (of a release) to a proxy that requires authentication works.
+     */
+    public void testitRelease()
+        throws Exception
+    {
+        testit( "release" );
+    }
+
+    /**
+     * Test that deployment (of a snapshot) to a proxy that requires authentication works.
+     */
+    public void testitSnapshot()
+        throws Exception
+    {
+        testit( "snapshot" );
+    }
+
+    private void testit( String project )
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4470/" + project );
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", 
+            Collections.singletonMap( "@port@", Integer.toString( port ) ) );
+        verifier.getCliOptions().add( "--settings" );
+        verifier.getCliOptions().add( "settings.xml" );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        assertTrue( deployed );
+    }
+
+}

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4470AuthenticatedDeploymentToProxyTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml?rev=884248&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml Wed Nov 25 20:20:24 2009
@@ -0,0 +1,65 @@
+<?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.mng4470</groupId>
+  <artifactId>release</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-4470</name> 
+  <description>
+    Test that deployment (of a release) to a proxy that requires authentication works.
+  </description>
+
+  <distributionManagement>
+    <repository>
+      <id>maven-core-it</id>
+      <url>http://bad.host/repo</url>
+    </repository>
+  </distributionManagement>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-artifact</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <configuration>
+          <mainFile>pom.xml</mainFile>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>set</goal>
+              <goal>install</goal>
+              <goal>deploy</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml?rev=884248&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml Wed Nov 25 20:20:24 2009
@@ -0,0 +1,41 @@
+<?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>maven-core-it</id>
+      <active>true</active>
+      <protocol>http</protocol>
+      <host>localhost</host>
+      <port>@port@</port>
+      <username>proxyuser</username>
+      <password>proxypass</password>
+    </proxy>
+  </proxies>
+  <servers>
+    <server>
+      <id>maven-core-it</id>
+      <username>testuser</username>
+      <password>testtest</password>
+    </server>
+  </servers>
+</settings>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/release/settings-template.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml?rev=884248&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml Wed Nov 25 20:20:24 2009
@@ -0,0 +1,65 @@
+<?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.mng4470</groupId>
+  <artifactId>snapshot</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>Maven Integration Test :: MNG-4470</name> 
+  <description>
+    Test that deployment (of a snapshot) to a proxy that requires authentication works.
+  </description>
+
+  <distributionManagement>
+    <snapshotRepository>
+      <id>maven-core-it</id>
+      <url>http://bad.host/repo</url>
+    </snapshotRepository>
+  </distributionManagement>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-artifact</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <configuration>
+          <mainFile>pom.xml</mainFile>
+        </configuration>
+        <executions>
+          <execution>
+            <id>test</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>set</goal>
+              <goal>install</goal>
+              <goal>deploy</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml?rev=884248&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml Wed Nov 25 20:20:24 2009
@@ -0,0 +1,41 @@
+<?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>maven-core-it</id>
+      <active>true</active>
+      <protocol>http</protocol>
+      <host>localhost</host>
+      <port>@port@</port>
+      <username>proxyuser</username>
+      <password>proxypass</password>
+    </proxy>
+  </proxies>
+  <servers>
+    <server>
+      <id>maven-core-it</id>
+      <username>testuser</username>
+      <password>testtest</password>
+    </server>
+  </servers>
+</settings>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4470/snapshot/settings-template.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision