noteconnection 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/appimage.update.test.js +127 -0
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const fs = __importStar(require("fs"));
|
|
37
|
+
const os = __importStar(require("os"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const { APPIMAGE_UPDATE_INFORMATION, verifyAppImageUpdate } = require('../scripts/appimage-update');
|
|
40
|
+
const describeLinux = process.platform === 'linux' ? describe : describe.skip;
|
|
41
|
+
describeLinux('AppImage update artifact boundary', () => {
|
|
42
|
+
let directory;
|
|
43
|
+
let artifact;
|
|
44
|
+
const filename = 'NoteConnection_fixture_amd64.AppImage';
|
|
45
|
+
const updateInformation = 'gh-releases-zsync|Jacobinwwey|NoteConnection|latest|NoteConnection_*_amd64.AppImage.zsync';
|
|
46
|
+
const runtime = `#!/bin/sh\nprintf '%s\\n' '${updateInformation}'\n`;
|
|
47
|
+
// Generated by bundled official zsyncmake 0.6.2: zsyncmake -u "$filename" "$filename".
|
|
48
|
+
// The shell fixture exposes the runtime metadata boundary; its table is not synthesized by this test.
|
|
49
|
+
const control = Buffer.from('enN5bmM6IDAuNi4yCkZpbGVuYW1lOiBOb3RlQ29ubmVjdGlvbl9maXh0dXJlX2FtZDY0LkFwcEltYWdlCk1UaW1lOiBNb24sIDA1IE9jdCAyMDI2IDA0OjM4OjAwICswMDAwCkJsb2Nrc2l6ZTogMjA0OApMZW5ndGg6IDExNgpIYXNoLUxlbmd0aHM6IDEsMiw0ClVSTDogTm90ZUNvbm5lY3Rpb25fZml4dHVyZV9hbWQ2NC5BcHBJbWFnZQpTSEEtMTogYjY3NDMyZTc0ZDM1ZjI5MmNmOTA1ZWMzZDk2MGI5MDg5YjFkYjQwMQoK3tOgETED', 'base64');
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
directory = fs.mkdtempSync(path.join(os.tmpdir(), 'appimage update '));
|
|
52
|
+
artifact = path.join(directory, filename);
|
|
53
|
+
fs.writeFileSync(artifact, runtime, { mode: 0o755 });
|
|
54
|
+
fs.writeFileSync(`${artifact}.zsync`, control);
|
|
55
|
+
});
|
|
56
|
+
afterEach(() => fs.rmSync(directory, { recursive: true, force: true }));
|
|
57
|
+
test('accepts an official control file for the exact final bytes and Latest amd64 target', () => {
|
|
58
|
+
expect(APPIMAGE_UPDATE_INFORMATION).toBe(updateInformation);
|
|
59
|
+
expect(verifyAppImageUpdate(artifact)).toEqual({
|
|
60
|
+
updateInformation,
|
|
61
|
+
zsyncPath: `${artifact}.zsync`,
|
|
62
|
+
sha1: 'b67432e74d35f292cf905ec3d960b9089b1db401',
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
test('requires the companion file at the adjacent release path', () => {
|
|
66
|
+
fs.renameSync(`${artifact}.zsync`, path.join(directory, 'elsewhere.zsync'));
|
|
67
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/ENOENT/);
|
|
68
|
+
});
|
|
69
|
+
test.each(['', updateInformation.replace('Jacobinwwey', 'other-owner'),
|
|
70
|
+
updateInformation.replace('|NoteConnection|', '|other-repository|'),
|
|
71
|
+
updateInformation.replace('|latest|', '|v1.9.0|'),
|
|
72
|
+
updateInformation.replace('_amd64.', '_aarch64.'),
|
|
73
|
+
updateInformation.replace('_amd64.', '_*.'),
|
|
74
|
+
])('rejects missing or wrong embedded update target: %s', (metadata) => {
|
|
75
|
+
fs.writeFileSync(artifact, `#!/bin/sh\nprintf '%s\\n' '${metadata}'\n`);
|
|
76
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/update information must be/);
|
|
77
|
+
});
|
|
78
|
+
test.each(['Other_fixture_amd64.AppImage', 'NoteConnection_fixture_aarch64.AppImage'])('rejects unsupported product or architecture: %s', (wrongName) => {
|
|
79
|
+
const moved = path.join(directory, wrongName);
|
|
80
|
+
fs.renameSync(artifact, moved);
|
|
81
|
+
fs.renameSync(`${artifact}.zsync`, `${moved}.zsync`);
|
|
82
|
+
expect(() => verifyAppImageUpdate(moved)).toThrow(/supported product amd64 filename/);
|
|
83
|
+
});
|
|
84
|
+
test('rejects a stale control file after AppImage bytes are appended', () => {
|
|
85
|
+
fs.appendFileSync(artifact, '# rebuilt\n');
|
|
86
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/Length does not match/);
|
|
87
|
+
});
|
|
88
|
+
test('rejects same-size AppImage corruption even when metadata still prints correctly', () => {
|
|
89
|
+
fs.writeFileSync(artifact, runtime.replace('printf ', 'printf\t'));
|
|
90
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/SHA-1 does not match/);
|
|
91
|
+
});
|
|
92
|
+
test.each([
|
|
93
|
+
['Filename: NoteConnection_fixture_amd64.AppImage', 'Filename: old.AppImage', /Filename and relative URL/],
|
|
94
|
+
['URL: NoteConnection_fixture_amd64.AppImage', 'URL: https://example.com/image.AppImage', /Filename and relative URL/],
|
|
95
|
+
['Length: 116', 'Length: 117', /Length does not match/],
|
|
96
|
+
['Length: 116', 'Length: 1.16e2', /Length does not match/],
|
|
97
|
+
['Blocksize: 2048', 'Blocksize: 0', /Blocksize/],
|
|
98
|
+
['Blocksize: 2048', 'Blocksize: 2047', /Blocksize/],
|
|
99
|
+
['Blocksize: 2048', 'Blocksize: 9007199254740991', /Blocksize/],
|
|
100
|
+
['Hash-Lengths: 1,2,4', 'Hash-Lengths: 3,2,4', /Hash-Lengths/],
|
|
101
|
+
['Hash-Lengths: 1,2,4', 'Hash-Lengths: 1,5,4', /Hash-Lengths/],
|
|
102
|
+
['Hash-Lengths: 1,2,4', 'Hash-Lengths: 1,2,17', /Hash-Lengths/],
|
|
103
|
+
['Hash-Lengths: 1,2,4', 'Hash-Lengths: 1,2,3', /checksum table/],
|
|
104
|
+
['SHA-1: b67432e74d35f292cf905ec3d960b9089b1db401', 'SHA-1: 0000000000000000000000000000000000000000', /SHA-1 does not match/],
|
|
105
|
+
['zsync: 0.6.2', 'zsync: unknown', /format version/],
|
|
106
|
+
['MTime:', 'Min-Version:', /unsupported/],
|
|
107
|
+
['MTime:', 'Unknown:', /unsupported/],
|
|
108
|
+
['MTime:', 'Z-URL:', /unsupported/],
|
|
109
|
+
['MTime:', 'Filename:', /duplicate/],
|
|
110
|
+
['Filename: Note', 'Filename: \xceote', /malformed/],
|
|
111
|
+
])('rejects malformed or mismatched control field: %s', (before, after, message) => {
|
|
112
|
+
fs.writeFileSync(`${artifact}.zsync`, Buffer.from(control.toString('latin1').replace(before, after), 'latin1'));
|
|
113
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(message);
|
|
114
|
+
});
|
|
115
|
+
test('rejects a truncated checksum table', () => {
|
|
116
|
+
fs.writeFileSync(`${artifact}.zsync`, control.subarray(0, -1));
|
|
117
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/checksum table/);
|
|
118
|
+
});
|
|
119
|
+
test('rejects trailing bytes after the checksum table', () => {
|
|
120
|
+
fs.appendFileSync(`${artifact}.zsync`, Buffer.from([0]));
|
|
121
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/checksum table/);
|
|
122
|
+
});
|
|
123
|
+
test('rejects a header without the checksum table separator', () => {
|
|
124
|
+
fs.writeFileSync(`${artifact}.zsync`, control.subarray(0, control.indexOf('\n\n')));
|
|
125
|
+
expect(() => verifyAppImageUpdate(artifact)).toThrow(/separator/);
|
|
126
|
+
});
|
|
127
|
+
});
|