[MNG-3953] [regression] Deployment to secured repository fails

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@731066 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-01-03 19:08:13 +00:00
parent 73d51681e2
commit 26f9c772f8
8 changed files with 356 additions and 0 deletions

View File

@ -90,6 +90,7 @@ public static Test suite()
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng3953AuthenticatedDeploymentTest.class );
suite.addTestSuite( MavenITmng3948ParentResolutionFromProfileReposTest.class );
suite.addTestSuite( MavenITmng3947PluginDefaultExecutionConfigTest.class );
suite.addTestSuite( MavenITmng3944BasedirInterpolationTest.class );

View File

@ -0,0 +1,165 @@
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 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.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-3953">MNG-3953</a>.
*
* @author Benjamin Bentmann
* @version $Id$
*/
public class MavenITmng3953AuthenticatedDeploymentTest
extends AbstractMavenIntegrationTestCase
{
private Server server;
private int port;
private boolean deployed;
public MavenITmng3953AuthenticatedDeploymentTest()
{
super( "(2.0.1,)" );
}
public void setUp()
throws Exception
{
super.setUp();
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 );
MavenITmng3953AuthenticatedDeploymentTest.this.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( 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();
}
super.tearDown();
}
/**
* Test that deployment (of a release) to a repository that requires authentification works.
*/
public void testitRelease()
throws Exception
{
testitMNG3953( "release" );
}
/**
* Test that deployment (of a snapshot) to a repository that requires authentification works.
*/
public void testitSnapshot()
throws Exception
{
testitMNG3953( "snapshot" );
}
private void testitMNG3953( String project )
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3953/" + project );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.getCliOptions().add( "--settings" );
verifier.getCliOptions().add( new File( testDir, "settings.xml" ).getAbsolutePath() );
verifier.getCliOptions().add( "-DdeploymentPort=" + port );
verifier.executeGoal( "validate" );
verifier.displayStreamBuffers();
verifier.verifyErrorFreeLog();
verifier.resetStreams();
assertTrue( deployed );
}
}

View File

@ -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.mng3953</groupId>
<artifactId>release</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-3953</name>
<description>
Test that deployment (of a release) to a repository that requires authentification works.
</description>
<distributionManagement>
<repository>
<id>maven-core-it-mng-3953</id>
<url>http://localhost:${deploymentPort}/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>main.jar</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>

View File

@ -0,0 +1,30 @@
<?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>
<servers>
<server>
<id>maven-core-it-mng-3953</id>
<username>testuser</username>
<password>testtest</password>
</server>
</servers>
</settings>

View File

@ -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.mng3953</groupId>
<artifactId>snapshot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-3953</name>
<description>
Test that deployment (of a snapshot) to a repository that requires authentification works.
</description>
<distributionManagement>
<repository>
<id>maven-core-it-mng-3953</id>
<url>http://localhost:${deploymentPort}/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>main.jar</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>

View File

@ -0,0 +1,30 @@
<?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>
<servers>
<server>
<id>maven-core-it-mng-3953</id>
<username>testuser</username>
<password>testtest</password>
</server>
</servers>
</settings>