Repository navigation
fix(harness): the stored-password task is registered for the account's Windows name #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,6 +269,45 @@ Describe 'Invoke-IslProcess' -Tag 'Unit', 'Private' { | |
| } | ||
| } | ||
|
|
||
| It 'registers the stored-password task for an Entra account by its Windows name (VM 125)' { | ||
| # The scheduler refuses the sign-in name with "No mapping between account names and | ||
| # security IDs"; AzureAD\<Windows name> registers | ||
| Mock Resolve-IslAccount -ModuleName IntuneScriptLab { | ||
| [pscustomobject]@{ | ||
| Name = 'AzureAD\IslVerylongdisplayna' | ||
| Sid = 'S-1-12-1-1497552185-1263987200-3276725654-805488699' | ||
| } | ||
| } | ||
| Mock Get-IslLogonSession -ModuleName IntuneScriptLab { @() } | ||
| $launchSplat = $script:LaunchSplat.Clone() | ||
| $signInName = 'isl-verylongusername-test01@4nlnm3.onmicrosoft.com' | ||
| $launchSplat.Credential = [pscredential]::new($signInName, $script:Credential.Password) | ||
| $result = Invoke-Process $launchSplat | ||
| $result.LogonType | Should-Be 'Password' | ||
| $result.UserName | Should-Be $signInName | ||
| Should-Invoke Register-ScheduledTask -ModuleName IntuneScriptLab -Exactly -Times 1 -ParameterFilter { | ||
| $User -eq 'AzureAD\IslVerylongdisplayna' -and $Password -eq 'pw' -and $null -eq $Principal | ||
| } | ||
| } | ||
|
|
||
| It 'says that a stored-password task does not start for an Entra account, right or no right (VM 125)' { | ||
| # With the account granted "Log on as a batch job" for the test, the task still sat | ||
| # Ready with 0x00041303, so the usual hint about the right would send someone the wrong way | ||
| Mock Resolve-IslAccount -ModuleName IntuneScriptLab { | ||
| [pscustomobject]@{ Name = 'AzureAD\IslVerylongdisplayna'; Sid = 'S-1-12-1-1-2-3-4' } | ||
| } | ||
| Mock Get-IslLogonSession -ModuleName IntuneScriptLab { @() } | ||
| Mock Start-ScheduledTask -ModuleName IntuneScriptLab { } | ||
| Mock Get-ScheduledTaskInfo -ModuleName IntuneScriptLab { [pscustomobject]@{ LastTaskResult = 267011 } } | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 267011 is 0x00041303, "the task has not run yet", as Get-ScheduledTaskInfo reports it: in decimal. |
||
| $launchSplat = $script:LaunchSplat.Clone() | ||
| $launchSplat.Credential = [pscredential]::new('someone@contoso.com', $script:Credential.Password) | ||
| $failure = { Invoke-Process $launchSplat } | Should-Throw | ||
| $failure.Exception.Message | Should-BeLikeString ('*someone@contoso.com did not start: 0x00041303 ' + | ||
| '(the scheduler never launched it: a stored-password task did not start for a Microsoft Entra ' + | ||
| 'account*sign the account in and run while it holds a session)') | ||
| $failure.Exception.Message | Should-NotBeLikeString '*grant it in the local security policy*' | ||
| } | ||
|
|
||
| It 'does not take another account''s session for a sign-in name that only looks like it' { | ||
| # The part before the @ of one account can be the Windows name of another | ||
| Mock Resolve-IslAccount -ModuleName IntuneScriptLab { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placed before the generic clause, and keyed on the account rather than on the failure code, so an Entra account never receives the hint about the "Log on as a batch job" right: on the lab device granting the right changed nothing, and the hint would send someone the wrong way.