"use strict"; const test = require("node:test"); const assert = require("node:assert/strict"); const fs = require("node:fs"); const path = require("node:path"); const { parseProductIdentity } = require("./product-identity"); const ini = fs.readFileSync(path.join(__dirname, "app.ini.template"), "utf8"); const unit = fs.readFileSync(path.join(__dirname, "guanghu-forgejo.service"), "utf8"); test("native Forgejo binds only to JD loopback", () => { assert.match(ini, /HTTP_ADDR = 127\.0\.0\.1/); assert.match(ini, /HTTP_PORT = 3001/); }); test("registration and push-create are disabled", () => { assert.match(ini, /DISABLE_REGISTRATION = true/); assert.match(ini, /ENABLE_PUSH_CREATE_USER = false/); }); test("secrets remain server-side placeholders", () => { assert.equal((ini.match(/PRIVATE_SERVER_VALUE/g) || []).length, 2); assert.doesNotMatch(ini, /[a-f0-9]{40,}/); assert.match(unit, /User=git/); }); test("product identity probe rejects Gitea being labeled as Forgejo", () => { const identity = parseProductIdentity( { version: "1.23.7" }, '', ); assert.deepEqual(identity, { product: "GITEA", version: "1.23.7", author: "Gitea - Git with a cup of tea", }); assert.notEqual(identity.product, "FORGEJO"); }); test("product identity probe recognizes Forgejo independently", () => { const identity = parseProductIdentity( { version: "15.0.5" }, '', ); assert.equal(identity.product, "FORGEJO"); assert.equal(identity.version, "15.0.5"); });