[MNG-4877] Regression: Deploy to SCP with privateKey fails - privateKey and passphrase gets lost

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@1029207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-10-30 21:40:37 +00:00
parent 1226ce1ef7
commit dfae567d59
5 changed files with 208 additions and 11 deletions

View File

@ -83,6 +83,7 @@ public class IntegrationTestSuite
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng4877DeployUsingPrivateKeyTest.class );
suite.addTestSuite( MavenITmng4874UpdateLatestPluginVersionTest.class );
suite.addTestSuite( MavenITmng4872ReactorResolutionAttachedWithExclusionsTest.class );
suite.addTestSuite( MavenITmng4842ParentResolutionOfDependencyPomTest.class );

View File

@ -0,0 +1,66 @@
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 org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import java.io.File;
import java.util.Properties;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4877">MNG-4877</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4877DeployUsingPrivateKeyTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng4877DeployUsingPrivateKeyTest()
{
super( "[2.0.3,3.0-alpha-1),[3.0.1,)" );
}
/**
* Verify that configured private key and passphrase are used for (SSH) deployment.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4877" );
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.getCliOptions().add( "-s" );
verifier.getCliOptions().add( "settings.xml" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "target/wagon.properties" );
assertEquals( "testuser", props.get( "username" ) );
assertEquals( "testpass", props.get( "password" ) );
assertEquals( "testkey", props.get( "privateKey" ) );
assertEquals( "testphrase", props.get( "passphrase" ) );
}
}

View File

@ -0,0 +1,72 @@
<?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.mng4877</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4877</name>
<description>
Verify that configured private key and passphrase are used for (SSH) deployment.
</description>
<distributionManagement>
<repository>
<id>maven-core-it-mng4877</id>
<url>coreit://localhost/nul</url>
</repository>
</distributionManagement>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.its</groupId>
<artifactId>core-it-wagon</artifactId>
<version>2.1-SNAPSHOT</version>
</extension>
</extensions>
<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>

View File

@ -0,0 +1,38 @@
<?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.
-->
<!--
These settings are meant for ITs that don't download artifacts from remote servers, i.e. ITs that either use their
own test repos or can employ the local repository (after bootstrapping). This configuration uses a file: URL to
"central" to avoid needless network access for files knowingly not present externally.
-->
<settings>
<servers>
<server>
<id>maven-core-it-mng4877</id>
<username>testuser</username>
<password>testpass</password>
<privateKey>testkey</privateKey>
<passphrase>testphrase</passphrase>
</server>
</servers>
</settings>

View File

@ -35,6 +35,7 @@ import org.apache.maven.wagon.OutputData;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.resource.Resource;
@ -120,6 +121,12 @@ public class CoreItWagon
public void fillInputData( InputData inputData )
throws TransferFailedException, ResourceDoesNotExistException
{
String resName = inputData.getResource().getName();
if ( resName.endsWith( ".xml" ) ||resName.endsWith( ".md5" ) || resName.endsWith( ".sha1" ) )
{
throw new ResourceDoesNotExistException( resName );
}
try
{
inputData.setInputStream( new ByteArrayInputStream( "<metadata />".getBytes( "UTF-8" ) ) );
@ -134,27 +141,31 @@ public class CoreItWagon
throws TransferFailedException
{
Properties props = new Properties();
if ( getRepository().getPermissions() != null )
{
String dirPerms = getRepository().getPermissions().getDirectoryMode();
if ( dirPerms != null )
{
props.setProperty( "directory.mode", dirPerms );
}
put( props, "directory.mode", dirPerms );
String filePerms = getRepository().getPermissions().getFileMode();
if ( filePerms != null )
{
props.setProperty( "file.mode", filePerms );
}
put( props, "file.mode", filePerms );
}
AuthenticationInfo auth = getAuthenticationInfo();
if ( auth != null )
{
put( props, "username", auth.getUserName() );
put( props, "password", auth.getPassword() );
put( props, "privateKey", auth.getPrivateKey() );
put( props, "passphrase", auth.getPassphrase() );
}
try
{
new File( "target" ).mkdirs();
File file = new File( "target/wagon.properties" ).getAbsoluteFile();
file.getParentFile().mkdirs();
OutputStream os = new FileOutputStream( "target/wagon.properties" );
OutputStream os = new FileOutputStream( file );
try
{
props.store( os, "MAVEN-CORE-IT-WAGON" );
@ -178,4 +189,13 @@ public class CoreItWagon
// TODO Auto-generated method stub
}
private void put( Properties props, String key, String value )
{
if ( value != null )
{
props.setProperty( key, value );
}
}
}