Skip to content

test: fix the credential and grant tests on the hosted runners - #154

Merged
fadwen merged 5 commits into
mainfrom
fix/ci-runner-tests
Nov 26, 2026
Merged

fadwen merged 5 commits into
mainfrom
fix/ci-runner-tests

Conversation

@fadwen

@fadwen fadwen commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Since #149 merged, three CI jobs on main fail on tests that pass on a developer's computer:

The grant itself is right for another account: the test that grants by SID to BUILTIN\Users found its two entries on the runners, and on VM 125 the run account isl-user held only those two (#149).

Changes

  • Tests/Unit/Module.Credential.Tests.ps1: runs the platform script in the x86 host, the one every Windows has.
  • Tests/Unit/Private/Grant-IslFolderAccess.Tests.ps1: the two by-name tests grant to LOCAL SERVICE, an account no test folder names, as a run grants to another account than the caller; its name is translated from S-1-5-19, so the tests run in any display language. Assert-RunGrant matches entries by SID and asserts the grant's exact shape for the by-SID and the by-name tests: two entries, an inherit-only Modify to files and folders, and list and add rights on the folder without Delete or DeleteSubdirectoriesAndFiles. A failure lists the entries.

Verification

  • Both files pass on PowerShell 7.6 and Windows PowerShell 5.1 locally (not elevated); PSScriptAnalyzer clean.
  • On the hosted runners, the previous commit of this branch showed the third entry as FullControl ContainerInherit, ObjectInherit/None Allow for runneradmin on all three jobs, and the credential tests passing on ARM. The CI of this head is the check that the jobs pass.

… test in the x86 host

On the hosted runners the grant to the runner's own account showed three entries where the tests counted two, and Windows on ARM has no x64 host, so the credential test stopped before the task. The grant tests now assert the inherit-only Modify, the list and add rights on the folder and no Delete there, and list every entry when one fails.
On a hosted runner the account that runs the tests already has full control of its own test folder, an entry the old single grant merged into and the two new ones sit beside. The tests record the account's entries before the grant and assert on the ones it added.
On a hosted runner the account that runs the tests owns its test folder, and a grant to it there also writes FullControl for it, which the folder did not hold before. A run grants to another account, so the by-name tests grant to NT AUTHORITY\LOCAL SERVICE, which no test folder names.

@fadwen-ai fadwen-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this. The runner diagnosis is clear, and CI is green on all five jobs for this head. I also ran Grant-IslFolderAccess.Tests.ps1 locally on PowerShell 7 (5 passed). There are three things on the grant tests:

  1. Important: $script:Stranger hardcodes the English name NT AUTHORITY\LOCAL SERVICE. On Windows in another display language, Get-Acl names S-1-5-19 in that language, so the two by-name tests fail. Take the name from the SID instead.
  2. Nit: Assert-RunGrant is looser than the assertion it replaces: it checks for at least one entry, where the old test required exactly two, and it doesn't check the inheritance flags. With LOCAL SERVICE, $before is always empty, so the exact assertions of the by-SID test would hold here.
  3. Nit: Assert-RunGrant's help, and both helpers' examples, still describe granting to the account that runs the tests (DOC-21).

The x86 change in Module.Credential.Tests.ps1 looks right to me: the task cmdlets are faked, so the architecture only picks the host path.

🤖 Generated with Claude Code

…d assert the grant's exact shape

The English name of LOCAL SERVICE is not what Get-Acl returns on Windows in another language. The name is now translated from S-1-5-19, entries are matched by SID, and one helper asserts the two entries of the grant exactly for both the by-SID and the by-name tests.
@fadwen

fadwen commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

Round 1: 3 fixed, 0 not changed.

  • Tests/Unit/Private/Grant-IslFolderAccess.Tests.ps1:20 (English account name): translated from S-1-5-19; entries matched by SID.
  • :171 (looser assertions): one helper asserts the exact two-entry shape for the by-SID and by-name tests; the before/after plumbing is gone.
  • :127 (stale help): the helper's help and example describe it as it is.

5 passed on PowerShell 7.6 and 5.1; PSScriptAnalyzer clean. The description is updated. New head 1c10ed8.

🤖 Generated with Claude Code

@fadwen-ai fadwen-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Round 2: all three round-1 findings are fixed, and I resolved their threads. The name is translated from S-1-5-19, entries are matched by SID, and one Assert-RunGrant asserts the exact two-entry shape for the by-SID test and both by-name tests. Its help now describes what it does.

On the head 1c10ed8, Grant-IslFolderAccess.Tests.ps1 passes locally on PowerShell 7 and Windows PowerShell 5.1 (5/5 each), and PSScriptAnalyzer is clean. CI for this head was still running when I reviewed.

One small leftover:

  1. Nit: $script:Me (line 17) is no longer read by any test. Its only mention is the Grant-Access help example at line 45.

🤖 Generated with Claude Code

@fadwen

fadwen commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

Round 2: 1 fixed, 0 not changed.

  • Tests/Unit/Private/Grant-IslFolderAccess.Tests.ps1:17: the unused `` is removed and the helper's example grants to LOCAL SERVICE.

5 passed; PSScriptAnalyzer clean. New head 941bcf2; this PR targets main, so its CI runs on the push.

🤖 Generated with Claude Code

@fadwen-ai fadwen-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Round 3: the last nit is fixed. $script:Me is gone, and the Grant-Access example grants to LOCAL SERVICE. I resolved the thread.

I reviewed the whole diff against main again. In Grant-IslFolderAccess.Tests.ps1, the grantee's name is translated from S-1-5-19, entries are matched by SID, and one helper asserts the grant's exact two-entry shape for the by-SID test and both by-name tests. The credential test runs in the x86 host, which also exists on Windows on ARM. On 941bcf2, the grant tests pass locally on PowerShell 7 and Windows PowerShell 5.1 (5/5 each), and PSScriptAnalyzer is clean.

CI for 941bcf2 was still running when I approved, so the hosted runners have not yet confirmed the exact-shape assertion for LOCAL SERVICE.

A side note, not about the code: in the round-2 summary and thread reply, $script:Me and $script:Stranger came out as empty backticks, probably expanded by the shell that posted them.

🤖 Generated with Claude Code

@fadwen
fadwen merged commit 677054f into main Nov 26, 2026
5 checks passed
@fadwen
fadwen deleted the fix/ci-runner-tests branch November 26, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants