-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-73760] Updates fail due to invalid JSON from HTTP Update Center #9760
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -538,14 +538,17 @@ public String getDownloadUrl() { | |
|
||
/** | ||
* Is this the legacy default update center site? | ||
* @deprecated | ||
* Will be removed, currently returns always false. | ||
* @since 2.343 | ||
* @since 1.357 | ||
Comment on lines
-543
to
+541
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was just wrong. This method was introduced in 1.357. |
||
*/ | ||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverting this hunk of #6116, since this functionality is useful and should not be 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/"); | ||
Comment on lines
+548
to
+551
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adapting the pre-#6116 code to handle the migration from http://updates.jenkins-ci.org to https://updates.jenkins.io rather than the migration from http://hudson-ci.org to http://updates.jenkins-ci.org |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@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()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ | |
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 void shutdownWebserver() throws Exception { | |
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()); | ||
} | ||
|
||
Comment on lines
+209
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adapting the pre-#6116 code to handle the migration from http://updates.jenkins-ci.org to https://updates.jenkins.io rather than the migration from http://hudson-ci.org to http://updates.jenkins-ci.org |
||
@Test public void getAvailables() throws Exception { | ||
UpdateSite site = getUpdateSite("/plugins/available-update-center.json"); | ||
List<UpdateSite.Plugin> available = site.getAvailables(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverting this hunk of #6116, since this functionality is useful and should not be deprecated.