001package org.apache.maven.wagon.providers.ssh.external; 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.apache.maven.wagon.WagonConstants; 023import org.apache.maven.wagon.WagonTestCase; 024import org.apache.maven.wagon.authentication.AuthenticationInfo; 025import org.apache.maven.wagon.providers.ssh.TestData; 026import org.apache.maven.wagon.repository.Repository; 027import org.apache.maven.wagon.resource.Resource; 028 029import java.io.File; 030 031/** 032 * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 033 * 034 */ 035public class ScpExternalWagonTest 036 extends WagonTestCase 037{ 038 protected int getExpectedContentLengthOnGet( int expectedSize ) 039 { 040 return WagonConstants.UNKNOWN_LENGTH; 041 } 042 043 protected boolean supportsGetIfNewer() 044 { 045 return false; 046 } 047 048 protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource ) 049 { 050 return 0; 051 } 052 053 protected String getProtocol() 054 { 055 return "scpexe"; 056 } 057 058 public String getTestRepositoryUrl() 059 { 060 return TestData.getTestRepositoryUrl(); 061 } 062 063 protected AuthenticationInfo getAuthInfo() 064 { 065 AuthenticationInfo authInfo = new AuthenticationInfo(); 066 067 String userName = TestData.getUserName(); 068 069 authInfo.setUserName( userName ); 070 071 File privateKey = TestData.getPrivateKey(); 072 073 if ( privateKey.exists() ) 074 { 075 authInfo.setPrivateKey( privateKey.getAbsolutePath() ); 076 077 authInfo.setPassphrase( "" ); 078 } 079 080 return authInfo; 081 } 082 083 public void testIsPuTTY() 084 throws Exception 085 { 086 ScpExternalWagon wagon = (ScpExternalWagon) getWagon(); 087 088 wagon.setSshExecutable( "c:\\program files\\PuTTY\\plink.exe" ); 089 assertTrue( wagon.isPuTTY() ); 090 wagon.setSshExecutable( "plink" ); 091 assertTrue( wagon.isPuTTY() ); 092 wagon.setSshExecutable( "PLINK" ); 093 assertTrue( wagon.isPuTTY() ); 094 wagon.setSshExecutable( "PlInK" ); 095 assertTrue( wagon.isPuTTY() ); 096 wagon.setSshExecutable( "ssh" ); 097 assertFalse( wagon.isPuTTY() ); 098 099 wagon.setScpExecutable( "c:\\program files\\PuTTY\\pscp.exe" ); 100 assertTrue( wagon.isPuTTYSCP() ); 101 wagon.setScpExecutable( "pscp" ); 102 assertTrue( wagon.isPuTTYSCP() ); 103 wagon.setScpExecutable( "PSCP" ); 104 assertTrue( wagon.isPuTTYSCP() ); 105 wagon.setScpExecutable( "PsCp" ); 106 assertTrue( wagon.isPuTTYSCP() ); 107 wagon.setScpExecutable( "scp" ); 108 assertFalse( wagon.isPuTTYSCP() ); 109 } 110}