Skip to content

Commit 4fc7f45

Browse files
committed
Merge branch 'test-core-env-coverage' of https://github.com/A1shalia/jenkins into test-core-env-coverage
2 parents 053345f + b05c513 commit 4fc7f45

File tree

6 files changed

+74
-94
lines changed

6 files changed

+74
-94
lines changed

.gitpod/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM gitpod/workspace-full:latest
22
ARG JAVA_VERSION=21.0.6-tem
3-
ARG MAVEN_VERSION=3.9.11
3+
ARG MAVEN_VERSION=3.9.12
44
# Install Java 21, Maven and GitHub CLI
55
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && \
66
sdk install java ${JAVA_VERSION} && \

bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ THE SOFTWARE.
326326
<dependency>
327327
<groupId>org.ow2.asm</groupId>
328328
<artifactId>asm</artifactId>
329-
<version>9.9</version>
329+
<version>9.9.1</version>
330330
</dependency>
331331
<dependency>
332332
<!-- provided by jcl-over-slf4j -->

core/src/main/resources/lib/layout/settings-subpage.jelly

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ THE SOFTWARE.
105105
<div class="app-settings-container__inner">
106106
<j:if test="${!attrs.containsKey('header')}">
107107
<l:app-bar title="${managementLink.displayName}" />
108-
<div class="jenkins-page-description">
109-
${managementLink.description}
110-
</div>
108+
<j:if test="${!empty(managementLink.description)}">
109+
<div class="jenkins-page-description">
110+
${managementLink.description}
111+
</div>
112+
</j:if>
111113
</j:if>
112114

113115
<j:out value="${attrs.header}" />

test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ THE SOFTWARE.
192192
<dependency>
193193
<groupId>org.jenkins-ci.main</groupId>
194194
<artifactId>jenkins-test-harness</artifactId>
195-
<version>2533.vb_b_4e14045e01</version>
195+
<version>2535.va_83a_c5b_19a_89</version>
196196
<scope>test</scope>
197197
<exclusions>
198198
<exclusion>

test/src/test/java/jenkins/install/SetupWizardTest.java

Lines changed: 65 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@
3030
import static org.junit.jupiter.api.Assertions.fail;
3131

3232
import edu.umd.cs.findbugs.annotations.NonNull;
33-
import hudson.FilePath;
3433
import hudson.model.DownloadService;
3534
import hudson.model.UpdateSite;
36-
import hudson.security.AuthorizationStrategy;
37-
import hudson.security.SecurityRealm;
3835
import java.io.ByteArrayInputStream;
39-
import java.io.ByteArrayOutputStream;
4036
import java.io.File;
4137
import java.io.IOException;
4238
import java.net.MalformedURLException;
@@ -63,6 +59,9 @@
6359
import org.eclipse.jetty.server.ServerConnector;
6460
import org.eclipse.jetty.util.Callback;
6561
import org.htmlunit.Page;
62+
import org.htmlunit.html.HtmlForm;
63+
import org.htmlunit.html.HtmlFormUtil;
64+
import org.htmlunit.html.HtmlPage;
6665
import org.junit.jupiter.api.AfterEach;
6766
import org.junit.jupiter.api.BeforeEach;
6867
import org.junit.jupiter.api.Tag;
@@ -83,39 +82,40 @@ class SetupWizardTest {
8382

8483
private JenkinsRule j;
8584

85+
private String initialAdminPassword;
86+
8687
@BeforeEach
8788
void setUp(JenkinsRule rule) throws Exception {
8889
j = rule;
8990

9091
tmpdir = Files.createTempDirectory("junit-").toFile();
9192

92-
final SetupWizard wizard = j.jenkins.getSetupWizard();
93-
wizard.init(true);
93+
j.jenkins.setInstallState(jenkins.install.InstallState.INITIAL_SECURITY_SETUP);
9494

95-
// Retrieve admin credentials
96-
final FilePath adminPassFile = wizard.getInitialAdminPasswordFile();
97-
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
98-
adminPassFile.copyTo(ostream);
99-
final String password = ostream.toString(StandardCharsets.UTF_8);
95+
initialAdminPassword = j.jenkins.getSetupWizard().getInitialAdminPasswordFile().readToString().trim();
10096
}
10197

10298
@AfterEach
10399
void tearDown() {
104100
tmpdir.delete();
105101
}
106102

103+
private void wizardLogin(JenkinsRule.WebClient wc) throws Exception {
104+
HtmlPage page = wc.goTo("login");
105+
HtmlForm form = page.getForms().get(0);
106+
form.getInputByName("j_password").setValue(initialAdminPassword);
107+
HtmlFormUtil.submit(form, null);
108+
}
109+
107110
@Test
108-
void shouldReturnPluginListsByDefault() {
109-
JenkinsRule.WebClient wc = j.createWebClient();
110-
// TODO: This is a hack, wc.login does not work with the form
111-
j.jenkins.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
112-
j.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
113-
// wc.setCredentialsProvider(adminCredentialsProvider);
114-
// wc.login("admin");
115-
116-
String response = jsonRequest(wc, "setupWizard/platformPluginList");
117-
assertThat("Missing plugin is suggestions ", response, containsString("active-directory"));
118-
assertThat("Missing category is suggestions ", response, containsString("Pipelines and Continuous Delivery"));
111+
void shouldReturnPluginListsByDefault() throws Exception {
112+
try (JenkinsRule.WebClient wc = j.createWebClient()) {
113+
wizardLogin(wc);
114+
115+
String response = jsonRequest(wc, "setupWizard/platformPluginList");
116+
assertThat("Missing plugin is suggestions ", response, containsString("active-directory"));
117+
assertThat("Missing category is suggestions ", response, containsString("Pipelines and Continuous Delivery"));
118+
}
119119
}
120120

121121
@Test
@@ -126,19 +126,15 @@ void shouldReturnUpdateSiteJSONIfSpecified() throws Exception {
126126
us.init();
127127
j.jenkins.getUpdateCenter().getSites().add(us);
128128

129-
// Prepare the connection
130-
JenkinsRule.WebClient wc = j.createWebClient();
131-
// TODO: This is a hack, wc.login does not work with the form
132-
j.jenkins.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
133-
j.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
134-
// wc.setCredentialsProvider(adminCredentialsProvider);
135-
// wc.login("admin");
136-
137-
String response = jsonRequest(wc, "setupWizard/platformPluginList");
138-
assertThat("Missing plugin in suggestions ", response, containsString("antisamy-markup-formatter"));
139-
assertThat("Missing category in suggestions ", response, containsString("Organization and Administration"));
140-
assertThat("Unexpected plugin in suggestions ", response, not(containsString("active-directory")));
141-
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
129+
try (JenkinsRule.WebClient wc = j.createWebClient()) {
130+
wizardLogin(wc);
131+
132+
String response = jsonRequest(wc, "setupWizard/platformPluginList");
133+
assertThat("Missing plugin in suggestions ", response, containsString("antisamy-markup-formatter"));
134+
assertThat("Missing category in suggestions ", response, containsString("Organization and Administration"));
135+
assertThat("Unexpected plugin in suggestions ", response, not(containsString("active-directory")));
136+
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
137+
}
142138
}
143139

144140
@Test
@@ -149,19 +145,15 @@ void shouldReturnWrappedUpdateSiteJSONIfSpecified() throws Exception {
149145
us.init();
150146
j.jenkins.getUpdateCenter().getSites().add(us);
151147

152-
// Prepare the connection
153-
JenkinsRule.WebClient wc = j.createWebClient();
154-
// TODO: This is a hack, wc.login does not work with the form
155-
j.jenkins.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
156-
j.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
157-
// wc.setCredentialsProvider(adminCredentialsProvider);
158-
// wc.login("admin");
159-
160-
String response = jsonRequest(wc, "setupWizard/platformPluginList");
161-
assertThat("Missing plugin in suggestions ", response, containsString("dashboard-view"));
162-
assertThat("Missing category in suggestions ", response, containsString("Administration and Organization"));
163-
assertThat("Unexpected plugin in suggestions ", response, not(containsString("matrix-auth")));
164-
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
148+
try (JenkinsRule.WebClient wc = j.createWebClient()) {
149+
wizardLogin(wc);
150+
151+
String response = jsonRequest(wc, "setupWizard/platformPluginList");
152+
assertThat("Missing plugin in suggestions ", response, containsString("dashboard-view"));
153+
assertThat("Missing category in suggestions ", response, containsString("Administration and Organization"));
154+
assertThat("Unexpected plugin in suggestions ", response, not(containsString("matrix-auth")));
155+
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
156+
}
165157
}
166158

167159
@Test
@@ -235,18 +227,14 @@ void testRemoteUpdateSiteFailingValidation() throws Exception {
235227
CustomRemoteUpdateSite us = new CustomRemoteUpdateSite(baseUrl.toString(), false);
236228
j.jenkins.getUpdateCenter().getSites().add(us);
237229

238-
// Prepare the connection
239-
JenkinsRule.WebClient wc = j.createWebClient();
240-
// TODO: This is a hack, wc.login does not work with the form
241-
j.jenkins.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
242-
j.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
243-
// wc.setCredentialsProvider(adminCredentialsProvider);
244-
// wc.login("admin");
230+
try (JenkinsRule.WebClient wc = j.createWebClient()) {
231+
wizardLogin(wc);
245232

246-
String response = jsonRequest(wc, "setupWizard/platformPluginList");
247-
// We need to assert that signature check fails, and we're falling back to the bundled resource
248-
assertThat("Missing plugin in suggestions ", response, not(containsString("my-plugin")));
249-
assertThat("Missing category in suggestions ", response, not(containsString("Very Useful Category")));
233+
String response = jsonRequest(wc, "setupWizard/platformPluginList");
234+
// We need to assert that signature check fails, and we're falling back to the bundled resource
235+
assertThat("Missing plugin in suggestions ", response, not(containsString("my-plugin")));
236+
assertThat("Missing category in suggestions ", response, not(containsString("Very Useful Category")));
237+
}
250238
} finally {
251239
server.stop();
252240
}
@@ -269,21 +257,16 @@ void testRemoteUpdateSiteSkippingValidation() throws Exception {
269257
CustomRemoteUpdateSite us = new CustomRemoteUpdateSite(baseUrl.toString(), false);
270258
j.jenkins.getUpdateCenter().getSites().add(us);
271259

260+
try (JenkinsRule.WebClient wc = j.createWebClient()) {
261+
wizardLogin(wc);
272262

273-
// Prepare the connection
274-
JenkinsRule.WebClient wc = j.createWebClient();
275-
// TODO: This is a hack, wc.login does not work with the form
276-
j.jenkins.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
277-
j.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
278-
// wc.setCredentialsProvider(adminCredentialsProvider);
279-
// wc.login("admin");
280-
281-
String response = jsonRequest(wc, "setupWizard/platformPluginList");
282-
// We need to assert that signature check fails, and we're falling back to the bundled resource
283-
assertThat("Missing plugin in suggestions ", response, containsString("my-plugin"));
284-
assertThat("Missing category in suggestions ", response, containsString("Very Useful Category"));
285-
assertThat("Unexpected plugin in suggestions ", response, not(containsString("matrix-auth")));
286-
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
263+
String response = jsonRequest(wc, "setupWizard/platformPluginList");
264+
// We need to assert that signature check fails, and we're falling back to the bundled resource
265+
assertThat("Missing plugin in suggestions ", response, containsString("my-plugin"));
266+
assertThat("Missing category in suggestions ", response, containsString("Very Useful Category"));
267+
assertThat("Unexpected plugin in suggestions ", response, not(containsString("matrix-auth")));
268+
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
269+
}
287270
} finally {
288271
DownloadService.signatureCheck = true;
289272
server.stop();
@@ -306,21 +289,16 @@ void testRemoteUpdateSitePerformingValidation() throws Exception {
306289
CustomRemoteUpdateSite us = new CustomRemoteUpdateSite(baseUrl.toString(), true);
307290
j.jenkins.getUpdateCenter().getSites().add(us);
308291

292+
try (JenkinsRule.WebClient wc = j.createWebClient()) {
293+
wizardLogin(wc);
309294

310-
// Prepare the connection
311-
JenkinsRule.WebClient wc = j.createWebClient();
312-
// TODO: This is a hack, wc.login does not work with the form
313-
j.jenkins.setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
314-
j.jenkins.setAuthorizationStrategy(AuthorizationStrategy.UNSECURED);
315-
// wc.setCredentialsProvider(adminCredentialsProvider);
316-
// wc.login("admin");
317-
318-
String response = jsonRequest(wc, "setupWizard/platformPluginList");
319-
// We need to assert that signature check fails, and we're falling back to the bundled resource
320-
assertThat("Missing plugin in suggestions ", response, containsString("my-plugin"));
321-
assertThat("Missing category in suggestions ", response, containsString("Very Useful Category"));
322-
assertThat("Unexpected plugin in suggestions ", response, not(containsString("matrix-auth")));
323-
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
295+
String response = jsonRequest(wc, "setupWizard/platformPluginList");
296+
// We need to assert that signature check fails, and we're falling back to the bundled resource
297+
assertThat("Missing plugin in suggestions ", response, containsString("my-plugin"));
298+
assertThat("Missing category in suggestions ", response, containsString("Very Useful Category"));
299+
assertThat("Unexpected plugin in suggestions ", response, not(containsString("matrix-auth")));
300+
assertThat("Unexpected category in suggestions ", response, not(containsString("Pipelines and Continuous Delivery")));
301+
}
324302
} finally {
325303
server.stop();
326304
}

war/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ THE SOFTWARE.
520520
<!-- dependency of scm-api -->
521521
<groupId>io.jenkins.plugins</groupId>
522522
<artifactId>asm-api</artifactId>
523-
<version>9.9-185.va_6c6b_3348b_c3</version>
523+
<version>9.9.1-189.vb_5ef2964da_91</version>
524524
<type>hpi</type>
525525
</artifactItem>
526526
<artifactItem>

0 commit comments

Comments
 (0)