Skip to content

Commit b2e21fc

Browse files
committed
fix: trim slack allowed users entries in audit check
1 parent 9b0678f commit b2e21fc

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

bin/checks/slack-allowed-users.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function countUsers(rawValue) {
88
if (!rawValue) return 0;
99
return rawValue
1010
.split(",")
11+
.map((entry) => entry.trim())
1112
.filter((entry) => entry.length > 0).length;
1213
}
1314

test/slack-allowed-users-check.test.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ describe("bin/checks/slack-allowed-users.mjs", () => {
4848
expect(payload.count).toBe("3");
4949
});
5050

51+
it("ignores whitespace-only entries", () => {
52+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "baudbot-slack-users-check-"));
53+
tmpDirs.push(tmpDir);
54+
55+
const envPath = path.join(tmpDir, ".env");
56+
fs.writeFileSync(envPath, "SLACK_ALLOWED_USERS=U1, , U2\n");
57+
58+
const payload = runCheck(envPath);
59+
expect(payload.defined).toBe("1");
60+
expect(payload.raw_non_empty).toBe("1");
61+
expect(payload.count).toBe("2");
62+
});
63+
5164
it("handles empty allowed users setting", () => {
5265
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "baudbot-slack-users-check-"));
5366
tmpDirs.push(tmpDir);

0 commit comments

Comments
 (0)