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:
Benjamin Bentmann 2009-08-12 13:36:16 +00:00
parent 724131c8be
commit 7ccdc16429
9 changed files with 228 additions and 47 deletions

View File

@ -23,43 +23,112 @@ import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor; import org.apache.maven.it.util.ResourceExtractor;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Properties; 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 public class MavenITmng0553SettingsAuthzEncryptionTest
extends AbstractMavenIntegrationTestCase extends AbstractMavenIntegrationTestCase
{ {
private File testDir;
private Server server;
private int port;
public MavenITmng0553SettingsAuthzEncryptionTest() public MavenITmng0553SettingsAuthzEncryptionTest()
{ {
// TODO: reintroduce for 3.0 // TODO: reintroduce for 3.0
super( "(2.1.0-M1,3.0-alpha-1)" ); // 2.1.0-M2+ 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. * Test that the encrypted auth infos given in the settings.xml are decrypted.
*/ */
public void testitBasic() public void testitBasic()
throws Exception 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.setAutoclean( false );
verifier.deleteDirectory( "target" ); verifier.deleteArtifacts( "org.apache.maven.its.mng0553" );
List cliOptions = new ArrayList(); verifier.assertArtifactNotPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
cliOptions.add( "--settings" ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
cliOptions.add( "settings.xml" );
verifier.getSystemProperties().setProperty( "settings.security", "settings-security.xml" ); verifier.getSystemProperties().setProperty( "settings.security", "settings-security.xml" );
verifier.setCliOptions( cliOptions ); verifier.getCliOptions().add( "--settings" );
verifier.getCliOptions().add( "settings.xml" );
verifier.executeGoal( "validate" ); verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog(); verifier.verifyErrorFreeLog();
verifier.resetStreams(); verifier.resetStreams();
Properties props = verifier.loadProperties( "target/auth.properties" ); verifier.assertArtifactPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
assertEquals( "testuser", props.getProperty( "test.username" ) );
assertEquals( "testtest", props.getProperty( "test.password" ) );
} }
/** /**
@ -69,32 +138,30 @@ public class MavenITmng0553SettingsAuthzEncryptionTest
public void testitRelocation() public void testitRelocation()
throws Exception 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(); 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 ); 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 // 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( "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.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 // 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.executeGoal( "validate", Collections.singletonMap( "MAVEN_OPTS", "-Duser.language=tr" ) );
verifier.verifyErrorFreeLog(); verifier.verifyErrorFreeLog();
verifier.resetStreams(); verifier.resetStreams();
Properties props = verifier.loadProperties( "target/auth.properties" ); verifier.assertArtifactPresent( "org.apache.maven.its.mng0553", "a", "0.1-SNAPSHOT", "jar" );
assertEquals( "testuser", props.getProperty( "test.username" ) );
assertEquals( "testtest", props.getProperty( "test.password" ) );
} }
} }

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -28,30 +28,34 @@ under the License.
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>test</name> <name>Maven Integration Test :: MNG-533</name>
<description> <description>
Test that the auth infos given in the settings.xml are pushed into the wagon manager and are available Test that the auth infos given in the settings.xml are properly decrypted.
to other components/plugins.
</description> </description>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng0553</groupId>
<artifactId>a</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.its.plugins</groupId> <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> <version>2.1-SNAPSHOT</version>
<configuration> <configuration>
<propertiesFile>target/auth.properties</propertiesFile> <compileClassPath>target/classpath.txt</compileClassPath>
<serverIds>
<serverId>test</serverId>
</serverIds>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<id>test</id> <id>test</id>
<phase>validate</phase> <phase>validate</phase>
<goals> <goals>
<goal>dump-auth</goal> <goal>compile</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>

View File

@ -27,4 +27,24 @@ under the License.
<password>{BteqUEnqHecHM7MZfnj9FwLcYbdInWxou1C929Txa0A=}</password> <password>{BteqUEnqHecHM7MZfnj9FwLcYbdInWxou1C929Txa0A=}</password>
</server> </server>
</servers> </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> </settings>

View File

@ -28,30 +28,34 @@ under the License.
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>test</name> <name>Maven Integration Test :: MNG-553</name>
<description> <description>
Test that the auth infos given in the settings.xml are pushed into the wagon manager and are available Test that the auth infos given in the settings.xml are properly decrypted.
to other components/plugins.
</description> </description>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng0553</groupId>
<artifactId>a</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.its.plugins</groupId> <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> <version>2.1-SNAPSHOT</version>
<configuration> <configuration>
<propertiesFile>target/auth.properties</propertiesFile> <compileClassPath>target/classpath.txt</compileClassPath>
<serverIds>
<serverId>test</serverId>
</serverIds>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<id>test</id> <id>test</id>
<phase>validate</phase> <phase>validate</phase>
<goals> <goals>
<goal>dump-auth</goal> <goal>compile</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>

View File

@ -27,4 +27,24 @@ under the License.
<password>{BteqUEnqHecHM7MZfnj9FwLcYbdInWxou1C929Txa0A=}</password> <password>{BteqUEnqHecHM7MZfnj9FwLcYbdInWxou1C929Txa0A=}</password>
</server> </server>
</servers> </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> </settings>