Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-10890]
added a test.
  • Loading branch information
kohsuke committed Jan 4, 2012
1 parent 1311c83 commit 167fbc0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.417</version>
<version>1.448-SNAPSHOT</version>
</parent>

<groupId>org.jenkins-ci.modules</groupId>
Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
<version>1.419</version>
<version>1.448-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
21 changes: 18 additions & 3 deletions src/test/java/org/jenkinsci/main/modules/cli/auth/ssh/TheTest.java
Expand Up @@ -3,6 +3,7 @@
import hudson.cli.CLI;
import hudson.cli.CLICommand;
import hudson.model.User;
import hudson.remoting.Callable;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestExtension;

Expand Down Expand Up @@ -33,9 +34,17 @@ public void test1() throws Exception {
assertEquals(PUBLIC_KEY, foo.getProperty(UserPropertyImpl.class).authorizedKeys);

CLI cli = new CLI(getURL());
cli.authenticate(Collections.singleton(CLI.loadKey(PRIVATE_KEY)));
assertEquals(0,cli.execute("test"));
cli.close();
try {
cli.authenticate(Collections.singleton(CLI.loadKey(PRIVATE_KEY)));
assertEquals(0, cli.execute("test"));

// closures executed with this channel should automatically carry the credential
// now that it's authenticated
cli.upgrade();
assertEquals("foo", cli.getChannel().call(new GetCurrentUser()));
} finally {
cli.close();
}
}

private static final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr+ZaQ/SI8xIr5BtMCh7gizoH/cVzEi8tCxwvHOu5eELzxl1FBwUH5/pRzMI31w1+WlYXBCYQSvcWgpLlAZn7VaJYCxUE9K9gMxLPmk81fUec8sFr5hSj6cPL3hWdk4CgdJ0M2Q/GNJExvbDsiFMFb/p9jnrKhHQ47mhT4HpMLTE4fG5+AB3liJZhaUo9lbHfmhpmpps9o1tE1z7YcIO4ckvCklxF+04mVRjKur3lcezh2i4TXjMGmkDgU7pTrwf9OM9rDo5dSpsAK/dGWlBT01jhv69wOfUitcYENAK07Tgyoti3pEYD3b2ugxQ0fe0LqoxFa//O540PjMhxEbmuQQ== xxx@yyy";
Expand Down Expand Up @@ -68,4 +77,10 @@ public void test1() throws Exception {
"Qob9zCG3CPQmu7I3dWp1rDUu2ZickE7rISRfo2N9TXWlkJ7ZjhSmQ2gnYgPQ6YGU\n" +
"LUNVNqTdfk2S8M+BM94pRqVgLSHHvwnqmMdoe7Ul3h2fk9CtNIw=\n" +
"-----END RSA PRIVATE KEY-----";

private static class GetCurrentUser implements Callable<String, Exception> {
public String call() throws Exception {
return User.current().getId();
}
}
}

0 comments on commit 167fbc0

Please sign in to comment.