Skip to content

Commit 3b17bf7

Browse files
authored
enable compatibility with future Jenkins version (#1150)
Adapts to jenkinsci/jenkins#23873 so the tests pass on the current Jenkins version as well as a version containing the PR
1 parent 4566f24 commit 3b17bf7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/test/java/com/cloudbees/jenkins/plugins/bitbucket/Security2033Test.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.htmlunit.Page;
4141
import org.htmlunit.WebResponse;
4242
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject;
43+
import org.junit.jupiter.api.BeforeAll;
4344
import org.junit.jupiter.api.BeforeEach;
4445
import org.junit.jupiter.api.Test;
4546
import org.jvnet.hudson.test.Issue;
@@ -62,6 +63,12 @@ class Security2033Test {
6263

6364
private WorkflowMultiBranchProject pr;
6465

66+
@BeforeAll
67+
static void enableManagePermission() {
68+
// TODO remove when baseline contains https://github.com/jenkinsci/jenkins/pull/23873
69+
Jenkins.MANAGE.setEnabled(true);
70+
}
71+
6572
@BeforeEach
6673
void setup(JenkinsRule rule) throws Exception {
6774
j = rule;
@@ -151,7 +158,7 @@ void doShowStatsWhenUserWithoutAdminPermissionThenReturnForbiddenStatus() {
151158
try (ACLContext aclContext = ACL.as(User.getOrCreateByIdOrFullName(NOT_AUTHORIZED_USER))) {
152159
assertThatThrownBy(() -> descriptor.doShowStats())
153160
.isInstanceOf(AccessDeniedException3.class)
154-
.hasMessage(NOT_AUTHORIZED_USER + " is missing the Overall/Administer permission");
161+
.hasMessage(NOT_AUTHORIZED_USER + " is missing the Overall/Manage permission");
155162
}
156163
}
157164

@@ -162,7 +169,7 @@ void doClearWhenUserWithoutAdminPermissionThenReturnForbiddenStatus() {
162169
try (ACLContext aclContext = ACL.as(User.getOrCreateByIdOrFullName(NOT_AUTHORIZED_USER))) {
163170
assertThatThrownBy(() -> descriptor.doClear())
164171
.isInstanceOf(AccessDeniedException3.class)
165-
.hasMessage(NOT_AUTHORIZED_USER + " is missing the Overall/Administer permission");
172+
.hasMessage(NOT_AUTHORIZED_USER + " is missing the Overall/Manage permission");
166173
}
167174
}
168175

src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfigurationTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class BitbucketEndpointConfigurationTest {
7373

7474
private static JenkinsRule r;
7575

76+
@BeforeAll
77+
static void enableManagePermission() {
78+
// TODO remove when baseline contains https://github.com/jenkinsci/jenkins/pull/23873
79+
Jenkins.MANAGE.setEnabled(true);
80+
}
81+
7682
@BeforeAll
7783
static void init(JenkinsRule rule) {
7884
r = rule;
@@ -131,7 +137,7 @@ void given__newInstance__when__configuredAsAnon__then__permissionError() {
131137
assertThatThrownBy(() ->
132138
instance.setEndpoints(List.of(buildCloudEndpoint(true, "first"), buildCloudEndpoint(true, "second"), buildCloudEndpoint(true, "third")))
133139
)
134-
.hasMessage(hudson.security.Messages.AccessDeniedException2_MissingPermission("anonymous", "Overall/Administer"));
140+
.hasMessage(hudson.security.Messages.AccessDeniedException2_MissingPermission("anonymous", "Overall/Manage"));
135141
} finally {
136142
r.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
137143
}

0 commit comments

Comments
 (0)