Files
anonymous_github/test/admin-user-filter.test.js
T
Thomas DurieuxandClaude Opus 5.5 d8a777cd35 fix(logging): keep reviewers unlinkable, look admin users up by explicit id
- Requests carry userId on warn and error records only. The app calls
  /api/user on every page load, so a userId on routine info records sat
  next to the repoId a signed-in reviewer opened, and timestamps linked
  them. Jobs keep it at every level. Logger, collector and the admin
  projection apply the same rule.
- Admin user routes take an _id only as id:<_id>; a 24-hex GitHub login
  can no longer match another account's _id for ban or promote.
- The download-job expectation includes the owner id the PR adds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 13:08:19 +00:00

15 lines
678 B
JavaScript

const { expect } = require("chai");
require("ts-node/register/transpile-only");
const { adminUserFilter } = require("../src/server/routes/admin");
describe("admin user lookup", () => {
it("looks a user up by _id only when asked with id:", () => {
const hex = "0123456789abcdef01234567";
// A 24-hex GitHub login is a username, never another account's _id.
expect(adminUserFilter(hex)).to.deep.equal({ username: hex });
expect(adminUserFilter("id:" + hex)).to.deep.equal({ _id: hex });
expect(adminUserFilter("id:not-an-id")).to.deep.equal({ username: "id:not-an-id" });
expect(adminUserFilter("alice")).to.deep.equal({ username: "alice" });
});
});