Spaces:
Running
Running
deploy(hf): sync szl-holdings/nexus@4c254a5cb191d15fd7f914e7507fd99e6bb9aaf1 derived COPY set
8432f6b verified Download scripts/native-assets.test.mjs from SZLHOLDINGS/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/SZLHOLDINGS/nexus/resolve/main/scripts/native-assets.test.mjs
- Command line
-
hf download hf://spaces/SZLHOLDINGS/nexus/scripts/native-assets.test.mjs
-
curl -L -o native-assets.test.mjs https://huggingface.co/spaces/SZLHOLDINGS/nexus/resolve/main/scripts/native-assets.test.mjs
1.42 kB
| import assert from "node:assert/strict"; | |
| import { cpSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; | |
| import { tmpdir } from "node:os"; | |
| import { join } from "node:path"; | |
| import test from "node:test"; | |
| import { ROOT, verifyAssets } from "./native-assets.mjs"; | |
| test("native source, full upstream manifest and installed projection retain exact bytes", () => { | |
| assert.equal(verifyAssets().files.length, 5); | |
| }); | |
| test("tampering, an extra file, or a symlink cannot pass native asset qualification", () => { | |
| const temp = mkdtempSync(join(tmpdir(), "nexus-native-")); | |
| try { | |
| const root = join(temp, "public"); | |
| const folder = join(root, "assets", "szl"); | |
| const reset = () => { | |
| rmSync(root, { recursive: true, force: true }); | |
| cpSync(join(ROOT, "public/assets/szl"), folder, { recursive: true }); | |
| }; | |
| reset(); | |
| writeFileSync(join(folder, "szl-icon-32.svg"), "changed"); | |
| assert.throws(() => verifyAssets(root), /native bytes changed/); | |
| reset(); | |
| writeFileSync(join(folder, "unused.svg"), "extra"); | |
| assert.throws(() => verifyAssets(root)); | |
| if (process.platform !== "win32") { | |
| reset(); | |
| rmSync(join(folder, "SOURCE.json")); | |
| symlinkSync(join(ROOT, "public/assets/szl/SOURCE.json"), join(folder, "SOURCE.json")); | |
| assert.throws(() => verifyAssets(root)); | |
| } | |
| } finally { | |
| rmSync(temp, { recursive: true, force: true }); | |
| } | |
| }); | |