Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions e2e-win/bootstrap.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Describe 'bootstrap' {
BeforeAll {
$script:OriginalDir = Get-Location
Set-Location TestDrive:

$script:OriginalTrusted = [Environment]::GetEnvironmentVariable('MISE_TRUSTED_CONFIG_PATHS', 'Process')
$env:MISE_TRUSTED_CONFIG_PATHS = $TestDrive

$script:RepoTarget = (Join-Path $TestDrive 'repo') -replace '\\', '/'
$script:FileTarget = (Join-Path $TestDrive 'managed') -replace '\\', '/'
}

BeforeEach {
@"
[bootstrap.repos]
"$script:RepoTarget" = { url = "https://example.invalid/repo.git" }
"@ | Out-File -FilePath mise.toml -Encoding utf8NoBOM
Comment thread
jdx marked this conversation as resolved.
Resolved
}

AfterAll {
Set-Location $script:OriginalDir
if ($null -eq $script:OriginalTrusted) {
Remove-Item Env:MISE_TRUSTED_CONFIG_PATHS -ErrorAction Ignore
} else {
[Environment]::SetEnvironmentVariable('MISE_TRUSTED_CONFIG_PATHS', $script:OriginalTrusted, 'Process')
}
}

It 'allows aggregate commands when no system files are configured' {
mise bootstrap --dry-run 2>&1 | Out-String | Out-Null
$LASTEXITCODE | Should -Be 0

mise bootstrap status 2>&1 | Out-String | Out-Null
$LASTEXITCODE | Should -Be 0

mise bootstrap plan 2>&1 | Out-String | Out-Null
$LASTEXITCODE | Should -Be 0
}

It 'still rejects configured system files' {
@"

[bootstrap.files."$script:FileTarget"]
content = "managed"
"@ | Out-File -FilePath mise.toml -Encoding utf8NoBOM -Append

$out = mise bootstrap plan 2>&1 | Out-String
$LASTEXITCODE | Should -Not -Be 0
$out | Should -BeLike '*managed system files are only supported on Unix*'
}
}
7 changes: 5 additions & 2 deletions src/system/managed_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,14 @@ pub fn validate_principals(

#[cfg(not(unix))]
pub fn validate_principals(
_files: &[ManagedFileRequest],
_directories: &[ManagedDirectoryRequest],
files: &[ManagedFileRequest],
directories: &[ManagedDirectoryRequest],
_accounts: Option<&super::accounts::AccountRequests>,
_allow_pending_accounts: bool,
) -> Result<()> {
if files.is_empty() && directories.is_empty() {
return Ok(());
}
bail!("managed system files are only supported on Unix")
}

Expand Down
Loading