Skip to content

test(bundle): drive the authorization policy arms of auth.ts (members/collaborators/root-OWNERS admits, trusted refusal, config-load failures, empty login) through dist/index.js - #378

Merged
mrbobbytables merged 3 commits into
mainfrom
quality/test-authorization-policy-arms
Oct 9, 2026
Merged

mrbobbytables merged 3 commits into
mainfrom
quality/test-authorization-policy-arms

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds __tests__/bundle/authorizationPolicyArms.test.ts: seven issue_comment runs through dist/index.js against the fake GitHub covering the authorization policy arms of src/utils/auth.ts that authorization.test.ts (from #367) leaves out —

  • /triage accepted under labels: members by an org member → policyAllows admits on the membership read (L313), no collaborator read
  • /triage accepted under labels: collaborators by a collaborator → admits on the collaborator read (L316), no membership read
  • /triage accepted under labels: trusted by a root-OWNERS reviewer who is neither member, collaborator nor in users → rootOwnersIncludes admits from the OWNERS file (L460–462)
  • /triage accepted under labels: collaborators from a payload without comment.user.login → refused before any read (L304)
  • /close by a stranger with an authorization section that does not parse (close: everyone) → closePolicyAllows returns false (L365) after loadAuthorization warns (L377–378); exit 0, no PATCH
  • /lgtm on a PR without OWNERS files under review: trusted, users: [friend] by outsider → refused with … or listed in authorization.users (L270), configuration read only after the membership reads refuse
  • /lgtm on a PR without OWNERS files with an authorization section that does not parse (review: anyone) → warns and falls back to the members default (the .catch(() => defaultAuthorization) on L265)

Measured on main @ 5061d57 with npm run test:coverage:e2e: auth.ts 70.14 % → 82.08 % lines; newly reached auth.ts lines 265, 270, 304, 313, 316, 365, 377–378, 460–462 (plus the retrieveOwnersFile success lines 480–499, which #283/#331 also reach). Files/functions claimed: __tests__/bundle/authorizationPolicyArms.test.ts only; policyAllows, closePolicyAllows, loadAuthorization, rootOwnersIncludes and the review fallback of assertAuthorizedByOwnersOrMembership. Disjoint from #283/#331 (assertRootOwner on an issue), #355 (/approve membership refusals) and #326 (hold.ts).

Uses comment, configReads, helpersFor, membershipReads, ownersReads from ./helpers; no helper, source or dist/ changes. Error and warning assertions check fragments only.

Verified locally: npx eslint __tests__/bundle/authorizationPolicyArms.test.ts clean; npx vitest run __tests__/bundle/authorizationPolicyArms.test.ts → 7 passed; npm run test:coverage:e2e → 222 passed.

Related Issue

Closes #377


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-fable-5.1

…dist/index.js

policyAllows' member, collaborator and empty-login arms, the trusted
fallback to the root OWNERS file (rootOwnersIncludes), closePolicyAllows'
and the review fallback's behaviour when the authorization section does
not parse, and review: trusted refusing a user outside authorization.users.

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 8, 2026 02:28
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 8, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

/kind cleanup


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: aa6a0f8

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind labels Oct 8, 2026

@jeefy jeefy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seven cases add coverage, and most of the documented ### authorization behaviour is asserted. Two documented guarantees run but aren't checked:

  1. authorizationPolicyArms.test.ts:162: the docs say the fallback exists "so the configuration error never reaches the public comment", but this case never inspects the reply. After :173, assert there is exactly one POST …/issues/1/comments, that its body contains not a org member or collaborator, and that it does not contain authorization. These pass on main.
  2. :129: the collaborator read is grouped with the config reads "in any order", so a /close that read the config first would still pass. The docs say the section is read "only when both refuse". Pin calls()[0] to the collaborator read, or reuse the indexOf check at :159.

…n the collaborator read first

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Addressed in cb868f1:

  1. the does-not-parse case now asserts exactly one POST …/issues/1/comments, whose body contains not a org member or collaborator and does not contain authorization.
  2. the /close fallback case pins calls()[0] to GET …/collaborators/stranger before the expectRequests group.

🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: cb868f1

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@mrbobbytables
mrbobbytables merged commit 47f1b72 into main Oct 9, 2026
5 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-authorization-policy-arms branch October 9, 2026 17:59
mrbobbytables added a commit that referenced this pull request Oct 9, 2026
… the cross-tier users union through dist/index.js (#381)

* test(bundle): drive the authorization section's schema rejections and the cross-tier users union through dist/index.js

normalizeAuthorization's non-mapping, unknown-key, bad-policy and users
rejections (config.ts 666, 671, 686, normalizeLogins 704) and
mergeAuthorization's case-insensitive dedup of users listed by both the
organization and the repository tier (753) had unit hits only; this file
reaches them through a /triage accepted against a malformed .github/prow.yaml
and a two-tier configuration.

Signed-off-by: quality <quality@hive.kubestellar.io>

* test(bundle): run the users-union case as an organization-only login and drop the policy-set rows #378 reaches

Signed-off-by: quality <quality@hive.kubestellar.io>

---------

Signed-off-by: quality <quality@hive.kubestellar.io>
Co-authored-by: quality <quality@hive.kubestellar.io>
Co-authored-by: Bob Killen <bkillen@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

2 participants