mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- client: update endpoint now sends {{target}}-{{arch}}-{{bundle_type}} so the
server-echoed platforms key matches the updater plugin's
{os}-{arch}-{installer} lookup (previously bare {{target}} produced a key
the plugin never matches, so no update was ever surfaced)
- client: TOFU cert pin is scoped to the OwnCord server host via
HostScopedVerifier; the GitHub installer download validates against web PKI
instead of failing the pinned-fingerprint check on every install
- client: check/install share one build_updater helper so the two paths cannot
diverge; tauri-plugin-updater minor-pinned per its configure_client guidance
- server: client-update endpoint serves target-specific artifacts (NSIS,
per-arch AppImage) and returns 204 for targets without a published updater
artifact (deb, darwin) instead of always serving the Windows NSIS installer
- release: server-update-manifest.json now binds both OS assets (legacy
top-level pair kept pointing at the Windows binary so deployed servers still
verify); VerifyReleaseManifest resolves the entry matching the downloaded
asset, fixing Linux server self-update
- release: ARM64 staging renames installer, tar.gz and .sig consistently so
signatures keep pairing and arch-less names cannot collide with x86_64 assets
- ci: run cargo test --lib (Rust #[cfg(test)] code was never compiled in CI);
merge the two ptt tests that raced on the global PTT_VKEY atomic
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
89 lines
3.2 KiB
Go
89 lines
3.2 KiB
Go
package updater
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func testHash(seed string) string {
|
|
sum := sha256.Sum256([]byte(seed))
|
|
return hex.EncodeToString(sum[:])
|
|
}
|
|
|
|
// multiAssetManifest mirrors the exact JSON the release workflow generates:
|
|
// legacy top-level fields bind the Windows binary (kept so already-deployed
|
|
// servers, which only understand the single-asset schema, can still verify)
|
|
// and the assets list binds every OS.
|
|
func multiAssetManifest(exeHash, linuxHash string) []byte {
|
|
return fmt.Appendf(nil,
|
|
`{"version":"v1.0.0","asset":"chatserver.exe","sha256":"%s","assets":[{"asset":"chatserver.exe","sha256":"%s"},{"asset":"chatserver-linux-amd64.tar.gz","sha256":"%s"}]}`,
|
|
exeHash, exeHash, linuxHash)
|
|
}
|
|
|
|
func TestVerifyReleaseManifest_MultiAssetSelectsLinuxEntry(t *testing.T) {
|
|
u, key := newSignedTestUpdater(t, "", "1.0.0")
|
|
manifest := multiAssetManifest(testHash("exe"), testHash("linux"))
|
|
sig := signTestAsset(t, key, manifest)
|
|
|
|
got, err := u.VerifyReleaseManifest(manifest, sig, "v1.0.0", "chatserver-linux-amd64.tar.gz")
|
|
if err != nil {
|
|
t.Fatalf("VerifyReleaseManifest: %v", err)
|
|
}
|
|
if got.Asset != "chatserver-linux-amd64.tar.gz" || got.SHA256 != testHash("linux") {
|
|
t.Errorf("resolved binding = {%s, %s}, want linux entry", got.Asset, got.SHA256)
|
|
}
|
|
}
|
|
|
|
func TestVerifyReleaseManifest_MultiAssetSelectsWindowsEntry(t *testing.T) {
|
|
u, key := newSignedTestUpdater(t, "", "1.0.0")
|
|
manifest := multiAssetManifest(testHash("exe"), testHash("linux"))
|
|
sig := signTestAsset(t, key, manifest)
|
|
|
|
got, err := u.VerifyReleaseManifest(manifest, sig, "v1.0.0", "chatserver.exe")
|
|
if err != nil {
|
|
t.Fatalf("VerifyReleaseManifest: %v", err)
|
|
}
|
|
if got.Asset != "chatserver.exe" || got.SHA256 != testHash("exe") {
|
|
t.Errorf("resolved binding = {%s, %s}, want windows entry", got.Asset, got.SHA256)
|
|
}
|
|
}
|
|
|
|
func TestVerifyReleaseManifest_MultiAssetUnknownAssetFails(t *testing.T) {
|
|
u, key := newSignedTestUpdater(t, "", "1.0.0")
|
|
manifest := multiAssetManifest(testHash("exe"), testHash("linux"))
|
|
sig := signTestAsset(t, key, manifest)
|
|
|
|
if _, err := u.VerifyReleaseManifest(manifest, sig, "v1.0.0", "other.bin"); err == nil {
|
|
t.Error("expected error for asset the manifest does not bind")
|
|
}
|
|
}
|
|
|
|
func TestVerifyReleaseManifest_MultiAssetBadChecksumFails(t *testing.T) {
|
|
u, key := newSignedTestUpdater(t, "", "1.0.0")
|
|
manifest := fmt.Appendf(nil,
|
|
`{"version":"v1.0.0","asset":"chatserver.exe","sha256":"%s","assets":[{"asset":"chatserver-linux-amd64.tar.gz","sha256":"not-a-hash"}]}`,
|
|
testHash("exe"))
|
|
sig := signTestAsset(t, key, manifest)
|
|
|
|
if _, err := u.VerifyReleaseManifest(manifest, sig, "v1.0.0", "chatserver-linux-amd64.tar.gz"); err == nil {
|
|
t.Error("expected error for invalid checksum in assets entry")
|
|
}
|
|
}
|
|
|
|
func TestVerifyReleaseManifest_LegacySingleAssetStillVerifies(t *testing.T) {
|
|
u, key := newSignedTestUpdater(t, "", "1.0.0")
|
|
manifest := fmt.Appendf(nil,
|
|
`{"version":"v1.0.0","asset":"chatserver.exe","sha256":"%s"}`, testHash("exe"))
|
|
sig := signTestAsset(t, key, manifest)
|
|
|
|
got, err := u.VerifyReleaseManifest(manifest, sig, "v1.0.0", "chatserver.exe")
|
|
if err != nil {
|
|
t.Fatalf("VerifyReleaseManifest: %v", err)
|
|
}
|
|
if got.SHA256 != testHash("exe") {
|
|
t.Errorf("SHA256 = %s, want legacy hash", got.SHA256)
|
|
}
|
|
}
|