|
24 | 24 |
|
25 | 25 | package hudson.model; |
26 | 26 |
|
| 27 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 28 | +import static org.hamcrest.Matchers.containsString; |
27 | 29 | import static org.junit.jupiter.api.Assertions.assertEquals; |
28 | 30 | import static org.junit.jupiter.api.Assertions.assertFalse; |
29 | 31 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
@@ -299,4 +301,45 @@ private PluginWrapper buildPluginWrapper(String name, String wikiUrl) { |
299 | 301 | new ArrayList<>() |
300 | 302 | ); |
301 | 303 | } |
| 304 | + |
| 305 | + @Test |
| 306 | + void signatureVerificationFailureIncludesUpdateSiteUrl() throws Exception { |
| 307 | + // Create an UpdateSite with an invalid/malformed signature that will trigger an error |
| 308 | + URL url = new URL(baseUrl, "/plugins/invalid-signature-update-center.json"); |
| 309 | + UpdateSite site = new UpdateSite(UpdateCenter.ID_DEFAULT, url.toString()); |
| 310 | + overrideUpdateSite(site); |
| 311 | + |
| 312 | + FormValidation validation = site.updateDirectlyNow(true); |
| 313 | + |
| 314 | + assertEquals(FormValidation.Kind.ERROR, validation.kind); |
| 315 | + |
| 316 | + String message = validation.getMessage(); |
| 317 | + assertNotNull(message); |
| 318 | + assertTrue( |
| 319 | + message.contains(url.toString()), |
| 320 | + "Signature verification error should include update site URL" |
| 321 | + ); |
| 322 | + assertThat(message, containsString("Empty input")); |
| 323 | + } |
| 324 | + |
| 325 | + @Test |
| 326 | + void signatureVerificationFailureIncludesUpdateSiteUrlWithoutPath() throws Exception { |
| 327 | + // Create an UpdateSite with an invalid/malformed signature that will trigger an error that involves Path |
| 328 | + URL url = new URL(baseUrl, "/plugins/invalid-signature-update-center-core-cm.json"); |
| 329 | + UpdateSite site = new UpdateSite(UpdateCenter.ID_DEFAULT, url.toString()); |
| 330 | + overrideUpdateSite(site); |
| 331 | + |
| 332 | + FormValidation validation = site.updateDirectlyNow(true); |
| 333 | + |
| 334 | + assertEquals(FormValidation.Kind.ERROR, validation.kind); |
| 335 | + |
| 336 | + String message = validation.getMessage(); |
| 337 | + assertNotNull(message); |
| 338 | + assertTrue( |
| 339 | + message.contains(url.toString()), |
| 340 | + "Signature verification error should include update site URL" |
| 341 | + ); |
| 342 | + assertThat(message, containsString("Path does not chain with any of the trust anchors")); |
| 343 | + } |
| 344 | + |
302 | 345 | } |
0 commit comments