feat: add in-app update flow and native e2e verification (#1112)

* feat(app-update): add in-app update flow with native e2e coverage

* docs(ai-workflow): infer closed-issue labels automatically

* fix(app-update): address native updater review findings

* fix(android): validate updater redirect hosts

* fix(electron): harden updater file names
This commit is contained in:
Tommaso Casaburi
2026-03-20 13:31:52 +08:00
committed by GitHub
parent dd4451c8c5
commit 5ecf8fbea8
11 changed files with 321 additions and 42 deletions
@@ -0,0 +1,69 @@
package fivechan.android;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class AppUpdaterPluginTest {
@Test
public void initialDownload_requiresGithubHost() {
assertTrue(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://github.com/bitsocialnet/5chan/releases/download/v0.7.3/5chan.apk",
false,
false));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://objects.githubusercontent.com/github-production-release-asset.apk",
false,
false));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://evil.example/5chan.apk", false, false));
}
@Test
public void redirectedDownload_allowsGithubContentHostsOnly() {
assertTrue(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://objects.githubusercontent.com/github-production-release-asset.apk",
true,
false));
assertTrue(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://release-assets.githubusercontent.com/file.apk", true, false));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://githubusercontent.evil.example/file.apk", true, false));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://evil.example/file.apk", true, false));
}
@Test
public void debugDownloads_allowOnlyLocalHosts() {
assertTrue(
AppUpdaterPlugin.isAllowedDownloadUrl(
"http://10.0.2.2:56405/5chan.apk", false, true));
assertTrue(
AppUpdaterPlugin.isAllowedDownloadUrl(
"https://localhost:56405/5chan.apk", false, true));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"http://192.168.1.8:56405/5chan.apk", false, true));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"http://10.0.2.2:56405/5chan.apk", false, false));
}
@Test
public void malformedOrUnsupportedUrls_areRejected() {
assertFalse(AppUpdaterPlugin.isAllowedDownloadUrl(null, true, true));
assertFalse(AppUpdaterPlugin.isAllowedDownloadUrl("not a url", true, true));
assertFalse(
AppUpdaterPlugin.isAllowedDownloadUrl(
"ftp://github.com/bitsocialnet/5chan/file.apk", true, true));
}
}