mirror of https://github.com/apache/maven.git
o Decoupled IT from core API details like wagon manager and tested effective repo access instead
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@803503 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
724131c8be
commit
7ccdc16429
|
@ -23,43 +23,112 @@ import org.apache.maven.it.Verifier;
|
|||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.DefaultHandler;
|
||||
import org.mortbay.jetty.handler.HandlerList;
|
||||
import org.mortbay.jetty.handler.ResourceHandler;
|
||||
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-553">MNG-553</a>.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class MavenITmng0553SettingsAuthzEncryptionTest
|
||||
extends AbstractMavenIntegrationTestCase
|
||||
{
|
||||
|
||||
private File testDir;
|
||||
|
||||
private Server server;
|
||||
|
||||
private int port;
|
||||
|
||||
public MavenITmng0553SettingsAuthzEncryptionTest()
|
||||
{
|
||||
// TODO: reintroduce for 3.0
|
||||
super( "(2.1.0-M1,3.0-alpha-1)" ); // 2.1.0-M2+
|
||||
}
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0553" );
|
||||
|
||||
Constraint constraint = new Constraint();
|
||||
constraint.setName( Constraint.__BASIC_AUTH );
|
||||
constraint.setRoles( new String[] { "user" } );
|
||||
constraint.setAuthenticate( true );
|
||||
|
||||
ConstraintMapping constraintMapping = new ConstraintMapping();
|
||||
constraintMapping.setConstraint( constraint );
|
||||
constraintMapping.setPathSpec( "/*" );
|
||||
|
||||
HashUserRealm userRealm = new HashUserRealm( "TestRealm" );
|
||||
userRealm.put( "testuser", "testtest" );
|
||||
userRealm.addUserToRole( "testuser", "user" );
|
||||
|
||||
SecurityHandler securityHandler = new SecurityHandler();
|
||||
securityHandler.setUserRealm( userRealm );
|
||||
securityHandler.setConstraintMappings( new ConstraintMapping[] { constraintMapping } );
|
||||
|
||||
ResourceHandler repoHandler = new ResourceHandler();
|
||||
repoHandler.setResourceBase( new File( testDir, "repo" ).getAbsolutePath() );
|
||||
|
||||
HandlerList handlerList = new HandlerList();
|
||||
handlerList.addHandler( securityHandler );
|
||||
handlerList.addHandler( repoHandler );
|
||||
handlerList.addHandler( new DefaultHandler() );
|
||||
|
||||
server = new Server( 0 );
|
||||
server.setHandler( handlerList );
|
||||
server.start();
|
||||
|
||||
port = server.getConnectors()[0].getLocalPort();
|
||||
}
|
||||
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
if ( server != null )
|
||||
{
|
||||
server.stop();
|
||||
server = null;
|
||||
}
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the encrypted auth infos given in the settings.xml are decrypted.
|
||||
*/
|
||||
public void testitBasic()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0553/test-1" );
|
||||
Properties filterProps = new Properties();
|
||||
filterProps.setProperty( "@port@", Integer.toString( port ) );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
Verifier verifier = new Verifier( new File( testDir, "test-1" ).getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "--settings" );
|
||||
cliOptions.add( "settings.xml" );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng0553" );
|
||||
verifier.assertArtifactNotPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
|
||||
verifier.getSystemProperties().setProperty( "settings.security", "settings-security.xml" );
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.getCliOptions().add( "--settings" );
|
||||
verifier.getCliOptions().add( "settings.xml" );
|
||||
verifier.executeGoal( "validate" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/auth.properties" );
|
||||
assertEquals( "testuser", props.getProperty( "test.username" ) );
|
||||
assertEquals( "testtest", props.getProperty( "test.password" ) );
|
||||
verifier.assertArtifactPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,32 +138,30 @@ public class MavenITmng0553SettingsAuthzEncryptionTest
|
|||
public void testitRelocation()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-0553/test-2" );
|
||||
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteDirectory( "target" );
|
||||
|
||||
// NOTE: The upper-case scheme name is essential part of the test
|
||||
String secUrl = "FILE://" + new File( testDir, "relocated-settings-security.xml" ).toURI().getRawPath();
|
||||
Properties filterProps = new Properties();
|
||||
filterProps.setProperty( "@port@", Integer.toString( port ) );
|
||||
// NOTE: The upper-case scheme name is essential part of the test
|
||||
String secUrl = "FILE://" + new File( testDir, "test-2/relocated-settings-security.xml" ).toURI().getRawPath();
|
||||
filterProps.setProperty( "@relocation@", secUrl );
|
||||
|
||||
Verifier verifier = new Verifier( new File( testDir, "test-2" ).getAbsolutePath() );
|
||||
verifier.setAutoclean( false );
|
||||
verifier.deleteArtifacts( "org.apache.maven.its.mng0553" );
|
||||
verifier.assertArtifactNotPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
|
||||
|
||||
// NOTE: The tilde ~ in the file name is essential part of the test
|
||||
verifier.filterFile( "security-template.xml", "settings~security.xml", "UTF-8", filterProps );
|
||||
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
|
||||
|
||||
List cliOptions = new ArrayList();
|
||||
cliOptions.add( "--settings" );
|
||||
cliOptions.add( "settings.xml" );
|
||||
verifier.getSystemProperties().setProperty( "settings.security", "settings~security.xml" );
|
||||
verifier.setCliOptions( cliOptions );
|
||||
verifier.getCliOptions().add( "--settings" );
|
||||
verifier.getCliOptions().add( "settings.xml" );
|
||||
// NOTE: The selection of the Turkish language for the JVM locale is essential part of the test
|
||||
verifier.executeGoal( "validate", Collections.singletonMap( "MAVEN_OPTS", "-Duser.language=tr" ) );
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
|
||||
Properties props = verifier.loadProperties( "target/auth.properties" );
|
||||
assertEquals( "testuser", props.getProperty( "test.username" ) );
|
||||
assertEquals( "testtest", props.getProperty( "test.password" ) );
|
||||
verifier.assertArtifactPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -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.
|
||||
-->
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng0553</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-553</name>
|
||||
<description>
|
||||
Test support for encrypted passwords in settings.
|
||||
</description>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven-core-it</id>
|
||||
<url>file:///${basedir}/repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.apache.maven.its.mng0553</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<snapshot>
|
||||
<timestamp>20090812.131911</timestamp>
|
||||
<buildNumber>1</buildNumber>
|
||||
</snapshot>
|
||||
<lastUpdated>20090812131911</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.apache.maven.its.mng0553</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
</versions>
|
||||
<lastUpdated>20090812131911</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -28,31 +28,35 @@ under the License.
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>test</name>
|
||||
<name>Maven Integration Test :: MNG-533</name>
|
||||
<description>
|
||||
Test that the auth infos given in the settings.xml are pushed into the wagon manager and are available
|
||||
to other components/plugins.
|
||||
Test that the auth infos given in the settings.xml are properly decrypted.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.mng0553</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-uses-wagon</artifactId>
|
||||
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<propertiesFile>target/auth.properties</propertiesFile>
|
||||
<serverIds>
|
||||
<serverId>test</serverId>
|
||||
</serverIds>
|
||||
<compileClassPath>target/classpath.txt</compileClassPath>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>dump-auth</goal>
|
||||
</goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
|
|
@ -27,4 +27,24 @@ under the License.
|
|||
<password>{BteqUEnqHecHM7MZfnj9FwLcYbdInWxou1C929Txa0A=}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>maven-core-it-repo</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>test</id>
|
||||
<url>http://localhost:@port@/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>maven-core-it-repo</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
|
@ -28,31 +28,35 @@ under the License.
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>test</name>
|
||||
<name>Maven Integration Test :: MNG-553</name>
|
||||
<description>
|
||||
Test that the auth infos given in the settings.xml are pushed into the wagon manager and are available
|
||||
to other components/plugins.
|
||||
Test that the auth infos given in the settings.xml are properly decrypted.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.its.mng0553</groupId>
|
||||
<artifactId>a</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin-uses-wagon</artifactId>
|
||||
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<propertiesFile>target/auth.properties</propertiesFile>
|
||||
<serverIds>
|
||||
<serverId>test</serverId>
|
||||
</serverIds>
|
||||
<compileClassPath>target/classpath.txt</compileClassPath>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>dump-auth</goal>
|
||||
</goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
|
|
@ -27,4 +27,24 @@ under the License.
|
|||
<password>{BteqUEnqHecHM7MZfnj9FwLcYbdInWxou1C929Txa0A=}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>maven-core-it-repo</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>test</id>
|
||||
<url>http://localhost:@port@/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>maven-core-it-repo</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
Loading…
Reference in New Issue