mirror of https://github.com/jenkinsci/jenkins.git
[JENKINS-73760] Updates fail due to invalid JSON from HTTP Update Center (#9760)
This commit is contained in:
parent
39e6622524
commit
47a212aa79
|
@ -538,14 +538,17 @@ public class UpdateSite {
|
|||
|
||||
/**
|
||||
* Is this the legacy default update center site?
|
||||
* @deprecated
|
||||
* Will be removed, currently returns always false.
|
||||
* @since 2.343
|
||||
* @since 1.357
|
||||
*/
|
||||
@Deprecated
|
||||
@Restricted(NoExternalUse.class)
|
||||
public boolean isLegacyDefault() {
|
||||
return false;
|
||||
return isJenkinsCI();
|
||||
}
|
||||
|
||||
private boolean isJenkinsCI() {
|
||||
return url != null
|
||||
&& UpdateCenter.PREDEFINED_UPDATE_SITE_ID.equals(id)
|
||||
&& url.startsWith("http://updates.jenkins-ci.org/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package hudson.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.jvnet.hudson.test.Issue;
|
||||
import org.jvnet.hudson.test.JenkinsRule;
|
||||
import org.jvnet.hudson.test.recipes.LocalData;
|
||||
|
||||
public class UpdateCenterMigrationTest {
|
||||
|
||||
@Rule
|
||||
public JenkinsRule j = new JenkinsRule() {
|
||||
@Override
|
||||
protected void configureUpdateCenter() {
|
||||
// Avoid reverse proxy
|
||||
DownloadService.neverUpdate = true;
|
||||
UpdateSite.neverUpdate = true;
|
||||
}
|
||||
};
|
||||
|
||||
@Issue("JENKINS-73760")
|
||||
@LocalData
|
||||
@Test
|
||||
public void updateCenterMigration() {
|
||||
UpdateSite site = j.jenkins.getUpdateCenter().getSites().stream()
|
||||
.filter(s -> UpdateCenter.PREDEFINED_UPDATE_SITE_ID.equals(s.getId()))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
assertFalse(site.isLegacyDefault());
|
||||
assertEquals(j.jenkins.getUpdateCenter().getDefaultBaseUrl() + "update-center.json", site.getUrl());
|
||||
}
|
||||
}
|
|
@ -72,6 +72,7 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.jvnet.hudson.test.Issue;
|
||||
import org.jvnet.hudson.test.JenkinsRule;
|
||||
|
||||
public class UpdateSiteTest {
|
||||
|
@ -205,6 +206,19 @@ public class UpdateSiteTest {
|
|||
assertNotEquals("plugin data is present", Collections.emptyMap(), site.getData().plugins);
|
||||
}
|
||||
|
||||
@Issue("JENKINS-73760")
|
||||
@Test
|
||||
public void isLegacyDefault() {
|
||||
assertFalse("isLegacyDefault should be false with null id", new UpdateSite(null, "url").isLegacyDefault());
|
||||
assertFalse(
|
||||
"isLegacyDefault should be false when id is not default and url is http://updates.jenkins-ci.org/",
|
||||
new UpdateSite("dummy", "http://updates.jenkins-ci.org/").isLegacyDefault());
|
||||
assertTrue(
|
||||
"isLegacyDefault should be true when id is default and url is http://updates.jenkins-ci.org/",
|
||||
new UpdateSite(UpdateCenter.PREDEFINED_UPDATE_SITE_ID, "http://updates.jenkins-ci.org/").isLegacyDefault());
|
||||
assertFalse("isLegacyDefault should be false with null url", new UpdateSite(null, null).isLegacyDefault());
|
||||
}
|
||||
|
||||
@Test public void getAvailables() throws Exception {
|
||||
UpdateSite site = getUpdateSite("/plugins/available-update-center.json");
|
||||
List<UpdateSite.Plugin> available = site.getAvailables();
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<sites>
|
||||
<site>
|
||||
<id>default</id>
|
||||
<url>http://updates.jenkins-ci.org/update-center.json</url>
|
||||
</site>
|
||||
</sites>
|
Loading…
Reference in New Issue