1 | |
package org.apache.maven.wagon.providers.ssh; |
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.StreamingWagonTestCase; |
23 | |
import org.apache.maven.wagon.authentication.AuthenticationInfo; |
24 | |
import org.apache.maven.wagon.repository.Repository; |
25 | |
import org.apache.maven.wagon.resource.Resource; |
26 | |
|
27 | |
import java.io.File; |
28 | |
import java.util.Arrays; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public abstract class AbstractEmbeddedScpWagonTest |
35 | |
extends StreamingWagonTestCase |
36 | |
{ |
37 | |
|
38 | |
SshServerEmbedded sshServerEmbedded; |
39 | |
|
40 | |
@Override |
41 | |
protected void setUp() |
42 | |
throws Exception |
43 | |
{ |
44 | 0 | super.setUp(); |
45 | |
|
46 | 0 | String sshKeyResource = "ssh-keys/id_rsa"; |
47 | |
|
48 | 0 | sshServerEmbedded = new SshServerEmbedded( getProtocol(), Arrays.asList( sshKeyResource ), false ); |
49 | |
|
50 | 0 | sshServerEmbedded.start(); |
51 | 0 | System.out.println( "sshd on port " + sshServerEmbedded.getPort() ); |
52 | 0 | } |
53 | |
|
54 | |
@Override |
55 | |
protected void tearDownWagonTestingFixtures() |
56 | |
throws Exception |
57 | |
{ |
58 | |
|
59 | 0 | for ( TestPasswordAuthenticator.PasswordAuthenticatorRequest passwordAuthenticatorRequest : sshServerEmbedded.passwordAuthenticator.passwordAuthenticatorRequests ) |
60 | |
{ |
61 | 0 | assertEquals( TestData.getUserName(), passwordAuthenticatorRequest.username ); |
62 | 0 | assertEquals( TestData.getUserPassword(), passwordAuthenticatorRequest.password ); |
63 | |
} |
64 | 0 | sshServerEmbedded.stop(); |
65 | 0 | } |
66 | |
|
67 | |
protected abstract String getProtocol(); |
68 | |
|
69 | |
@Override |
70 | |
protected int getTestRepositoryPort() |
71 | |
{ |
72 | 0 | return sshServerEmbedded.getPort(); |
73 | |
} |
74 | |
|
75 | |
|
76 | |
public String getTestRepositoryUrl() |
77 | |
{ |
78 | 0 | return TestData.getTestRepositoryUrl( sshServerEmbedded.getPort() ); |
79 | |
} |
80 | |
|
81 | |
protected AuthenticationInfo getAuthInfo() |
82 | |
{ |
83 | 0 | AuthenticationInfo authInfo = super.getAuthInfo(); |
84 | |
|
85 | 0 | authInfo.setUserName( TestData.getUserName() ); |
86 | 0 | authInfo.setPassword( TestData.getUserPassword() ); |
87 | |
|
88 | 0 | return authInfo; |
89 | |
} |
90 | |
|
91 | |
protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource ) |
92 | |
{ |
93 | 0 | return new File( repository.getBasedir(), resource.getName() ).lastModified(); |
94 | |
} |
95 | |
|
96 | |
|
97 | |
@Override |
98 | |
protected abstract boolean supportsGetIfNewer(); |
99 | |
|
100 | |
} |