Skip to content

Commit 8ccd614

Browse files
authored
Merge pull request #96 from daniel-beck/fix-read-only-test
Fix read-only test that requires 2.238+
2 parents 0f3711d + 5fd4a74 commit 8ccd614

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎src/test/java/org/jenkinsci/plugins/matrixauth/ReadOnlyTest.java‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,26 @@ public void testFolderConfiguration() throws IOException, SAXException {
104104
}
105105

106106
@Test
107-
@Ignore // TODO this form is only accessible to Agent/ExtendedRead users from https://github.com/jenkinsci/jenkins/pull/4531
108-
public void testAgentConfiguration() throws Exception {
109-
Assume.assumeTrue(Jenkins.getVersion().isNewerThanOrEqualTo(new VersionNumber("2.234"))); // TODO fix version
107+
public void testAgentConfigurationGlobally() throws Exception {
108+
Assume.assumeTrue(Jenkins.getVersion().isNewerThanOrEqualTo(new VersionNumber("2.238")));
110109
final Slave agent = j.createSlave();
111110
agent.setNodeProperties(Collections.singletonList(new AuthorizationMatrixNodeProperty()));
112-
assertPresentAndReadOnly( "computer/" + agent.getNodeName() + "/configure");
111+
assertPresentAndReadOnly("computer/" + agent.getNodeName() + "/configure");
113112

114-
// Grant permission globally -- works with https://github.com/jenkinsci/jenkins/pull/4531 before https://github.com/jenkinsci/jenkins/pull/4531#pullrequestreview-408283044
115-
((ProjectMatrixAuthorizationStrategy)Jenkins.get().getAuthorizationStrategy()).add(Computer.CONFIGURE, "anonymous");
113+
((ProjectMatrixAuthorizationStrategy) Jenkins.get().getAuthorizationStrategy()).add(Computer.CONFIGURE, Jenkins.ANONYMOUS.getName());
114+
assertPresentAndEditable("computer/" + agent.getNodeName() + "/configure");
115+
}
116+
117+
@Test
118+
public void testAgentConfigurationPerAgent() throws Exception {
119+
Assume.assumeTrue(Jenkins.getVersion().isNewerThanOrEqualTo(new VersionNumber("2.238")));
120+
final Slave agent = j.createSlave();
121+
agent.setNodeProperties(Collections.singletonList(new AuthorizationMatrixNodeProperty()));
122+
assertPresentAndReadOnly("computer/" + agent.getNodeName() + "/configure");
116123

117-
// Grant per-agent permission -- https://github.com/jenkinsci/jenkins/pull/4531#pullrequestreview-408283044 prevents this so far
118-
// TODO use this once it works upstream
119-
// final AuthorizationMatrixNodeProperty prop = new AuthorizationMatrixNodeProperty();
120-
// prop.add(Computer.CONFIGURE, Jenkins.ANONYMOUS.getName());
121-
// agent.setNodeProperties(Collections.singletonList(prop));
124+
final AuthorizationMatrixNodeProperty prop = new AuthorizationMatrixNodeProperty();
125+
prop.add(Computer.CONFIGURE, Jenkins.ANONYMOUS.getName());
126+
agent.setNodeProperties(Collections.singletonList(prop));
122127
assertPresentAndEditable( "computer/" + agent.getNodeName() + "/configure");
123128
}
124129
}

0 commit comments

Comments
 (0)