001package org.apache.maven.wagon.providers.ssh;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.codehaus.plexus.util.FileUtils;
023
024import java.io.File;
025import java.io.IOException;
026
027/**
028 * @author <a href="michal@codehaus.org">Michal Maczka</a>
029 *
030 */
031public class TestData
032{
033    public static String getTempDirectory()
034    {
035        return System.getProperty( "java.io.tmpdir", "target" );
036    }
037
038    public static String getTestRepositoryUrl( int port )
039    {
040        return "scp://" + getHostname() + ":" + port + getRepoPath();
041    }
042
043    public static String getRepoPath()
044    {
045        return getTempDirectory() + "/wagon-ssh-test/" + getUserName();
046    }
047
048    public static String getUserName()
049    {
050        return System.getProperty( "test.user", System.getProperty( "user.name" ) );
051    }
052
053    public static String getUserPassword()
054    {
055        return "comeonFrance!:-)";
056    }
057
058    public static File getPrivateKey()
059    {
060        return new File( System.getProperty( "sshKeysPath", "src/test/ssh-keys" ), "id_rsa" );
061    }
062
063    public static String getHostname()
064    {
065        return System.getProperty( "test.host", "localhost" );
066    }
067
068    public static String getHostKey()
069    {
070        try
071        {
072            return FileUtils.fileRead(
073                new File( System.getProperty( "sshKeysPath" ), "id_rsa.pub" ).getPath() ).substring(
074                "ssh-rsa".length() ).trim();
075        }
076        catch ( IOException e )
077        {
078            return null;
079        }
080    }
081}