Repository navigation
test: fix the credential and grant tests on the hosted runners - #154
Conversation
… 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
left a comment
There was a problem hiding this comment.
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:
- Important:
$script:Strangerhardcodes the English nameNT 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. - Nit:
Assert-RunGrantis 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,$beforeis always empty, so the exact assertions of the by-SID test would hold here. - 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.
|
Round 1: 3 fixed, 0 not changed.
5 passed on PowerShell 7.6 and 5.1; PSScriptAnalyzer clean. The description is updated. New head 🤖 Generated with Claude Code |
fadwen-ai
left a comment
There was a problem hiding this comment.
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:
- 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
|
Round 2: 1 fixed, 0 not changed.
5 passed; PSScriptAnalyzer clean. New head 🤖 Generated with Claude Code |
fadwen-ai
left a comment
There was a problem hiding this comment.
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
Summary
Since #149 merged, three CI jobs on
mainfail on tests that pass on a developer's computer:No x64 PowerShell host on this Arm64 device), so the run stopped before it reached the scheduled task and four tests failed.Grant-IslFolderAccesstests counted the grantee's entries on the folder and expected two, and found three. They granted to the account that runs the tests, which on a hosted runner owns its test folder: there the grant also writes an explicitFullControl (OI)(CI)for it, which the folder did not hold before (recorded before and after the grant on the runner). The single(OI)(CI)Mgrant before fix: close the run folder of a run as another account to other users #149 merged into that entry, so its count was 1; the two entries of fix: close the run folder of a run as another account to other users #149 have other flags and sit beside it.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-userheld 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 fromS-1-5-19, so the tests run in any display language.Assert-RunGrantmatches 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
FullControl ContainerInherit, ObjectInherit/None Allowforrunneradminon all three jobs, and the credential tests passing on ARM. The CI of this head is the check that the jobs pass.