Supplement test case and clean to code
@@ -48,11 +48,13 @@ public class SlaveComputerTest {
@Test
public void testGetAbsoluteRemotePath() throws Exception {
+ //default auth
Node nodeA = j.createOnlineSlave();
String path = ((DumbSlave) nodeA).getComputer().getAbsoluteRemotePath();
Assert.assertNotNull(path);
Assert.assertEquals(getRemoteFS(nodeA, null), path);
+ //not auth
String userAlice = "alice";
MockAuthorizationStrategy authStrategy = new MockAuthorizationStrategy();
authStrategy.grant(Computer.CONFIGURE, Jenkins.READ).everywhere().to(userAlice);
@@ -60,11 +62,19 @@ public class SlaveComputerTest {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
j.jenkins.setAuthorizationStrategy(authStrategy);
try(ACLContext context = ACL.as(User.getById(userAlice, true))) {
- nodeA = j.createOnlineSlave();
path = ((DumbSlave) nodeA).getComputer().getAbsoluteRemotePath();
Assert.assertNull(path);
Assert.assertNull(getRemoteFS(nodeA, userAlice));
}
+
+ //with auth
+ String userBob = "bob";
+ authStrategy.grant(Computer.CONNECT, Jenkins.READ).everywhere().to(userBob);
+ try(ACLContext context = ACL.as(User.getById(userBob, true))) {
+ path = ((DumbSlave) nodeA).getComputer().getAbsoluteRemotePath();
+ Assert.assertNotNull(path);
+ Assert.assertNotNull(getRemoteFS(nodeA, userBob));
+ }
}
/**
