1 package org.apache.maven.wagon.providers.ssh.external;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.wagon.WagonConstants;
23 import org.apache.maven.wagon.WagonTestCase;
24 import org.apache.maven.wagon.authentication.AuthenticationInfo;
25 import org.apache.maven.wagon.providers.ssh.TestData;
26 import org.apache.maven.wagon.repository.Repository;
27 import org.apache.maven.wagon.resource.Resource;
28
29 import java.io.File;
30
31
32
33
34
35 public class ScpExternalWagonTest
36 extends WagonTestCase
37 {
38 protected int getExpectedContentLengthOnGet( int expectedSize )
39 {
40 return WagonConstants.UNKNOWN_LENGTH;
41 }
42
43 protected boolean supportsGetIfNewer()
44 {
45 return false;
46 }
47
48 protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
49 {
50 return 0;
51 }
52
53 protected String getProtocol()
54 {
55 return "scpexe";
56 }
57
58 public String getTestRepositoryUrl()
59 {
60 return TestData.getTestRepositoryUrl();
61 }
62
63 protected AuthenticationInfo getAuthInfo()
64 {
65 AuthenticationInfo authInfo = new AuthenticationInfo();
66
67 String userName = TestData.getUserName();
68
69 authInfo.setUserName( userName );
70
71 File privateKey = TestData.getPrivateKey();
72
73 if ( privateKey.exists() )
74 {
75 authInfo.setPrivateKey( privateKey.getAbsolutePath() );
76
77 authInfo.setPassphrase( "" );
78 }
79
80 return authInfo;
81 }
82
83 public void testIsPuTTY() throws Exception
84 {
85 ScpExternalWagon wagon = (ScpExternalWagon) getWagon();
86
87 wagon.setSshExecutable( "c:\\program files\\PuTTY\\plink.exe" );
88 assertTrue( wagon.isPuTTY() );
89 wagon.setSshExecutable( "plink" );
90 assertTrue( wagon.isPuTTY() );
91 wagon.setSshExecutable( "PLINK" );
92 assertTrue( wagon.isPuTTY() );
93 wagon.setSshExecutable( "PlInK" );
94 assertTrue( wagon.isPuTTY() );
95 wagon.setSshExecutable( "ssh" );
96 assertFalse( wagon.isPuTTY() );
97
98 wagon.setScpExecutable( "c:\\program files\\PuTTY\\pscp.exe" );
99 assertTrue( wagon.isPuTTYSCP() );
100 wagon.setScpExecutable( "pscp" );
101 assertTrue( wagon.isPuTTYSCP() );
102 wagon.setScpExecutable( "PSCP" );
103 assertTrue( wagon.isPuTTYSCP() );
104 wagon.setScpExecutable( "PsCp" );
105 assertTrue( wagon.isPuTTYSCP() );
106 wagon.setScpExecutable( "scp" );
107 assertFalse( wagon.isPuTTYSCP() );
108 }
109 }