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
1 change: 1 addition & 0 deletions dsc/src/resource_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: Option<&GetOutputF
let format = match format {
Some(&GetOutputFormat::PrettyJson) => Some(&OutputFormat::PrettyJson),
Some(&GetOutputFormat::Yaml) => Some(&OutputFormat::Yaml),
None => None,
_ => Some(&OutputFormat::Json),
};
write_object(&json, format, include_separator);
Expand Down
40 changes: 21 additions & 19 deletions powershell-adapter/Tests/win_powershellgroup.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ Describe 'WindowsPowerShell adapter resource tests - requires elevated permissio
BeforeAll {
if ($isWindows) {
winrm quickconfig -quiet -force
}
$OldPSModulePath = $env:PSModulePath
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
$OldPSModulePath = $env:PSModulePath
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot

$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"
if ($isWindows) {
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"
if ($isWindows) {
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
}
}
}
AfterAll {
$env:PSModulePath = $OldPSModulePath
if ($isWindows) {
$env:PSModulePath = $OldPSModulePath

# Remove after all the tests are done
Remove-Module $script:winPSModule -Force -ErrorAction Ignore
# Remove after all the tests are done
Remove-Module $script:winPSModule -Force -ErrorAction Ignore
}
}

BeforeEach {
Expand Down Expand Up @@ -161,7 +163,7 @@ resources:
- "[resourceId('Microsoft.Windows/WindowsPowerShell', 'File')]"
- name: TestPSRepository
type: PSTestModule/TestPSRepository
properties:
properties:
Name: NuGet
dependsOn:
- "[resourceId('Microsoft.Windows/WindowsPowerShell', 'File')]"
Expand Down Expand Up @@ -201,7 +203,7 @@ resources:
type: PsDesiredStateConfiguration/Service
properties:
Name: Spooler
State: $SecondState
State: $SecondState
"@

$inDesiredState = if ($FirstState -eq $SecondState) {
Expand Down Expand Up @@ -242,11 +244,11 @@ resources:
# Instead of calling dsc.exe we call the cmdlet directly to be able to test the output and mocks
$resourceObject = Get-DscResourceObject -jsonInput $jsonInput
$cacheEntry = Invoke-DscCacheRefresh -Module PSDesiredStateConfiguration

$out = Invoke-DscOperation -Operation Test -DesiredState $resourceObject -dscResourceCache $cacheEntry
$LASTEXITCODE | Should -Be 0
$out.properties.InDesiredState.InDesiredState | Should -Be $false

Should -Invoke -CommandName ConvertTo-SecureString -Exactly -Times 1 -Scope It
}

Expand All @@ -261,7 +263,7 @@ resources:
Credential:
UserName: 'User'
OtherProperty: 'Password'
"@
"@
# Compared to PowerShell we use test here as it filters out the properties
$out = dsc config test -i $yaml 2>&1 | Out-String
$LASTEXITCODE | Should -Be 2
Expand Down Expand Up @@ -339,7 +341,7 @@ class PSClassResource {
}

[void] Set() {

}

static [PSClassResource[]] Export()
Expand Down Expand Up @@ -374,23 +376,23 @@ class PSClassResource {
}

It 'Get works with class-based PS DSC resources' -Skip:(!$IsWindows) {

$out = dsc resource get -r PSClassResource/PSClassResource --input (@{Name = 'TestName' } | ConvertTo-Json) | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0
$out.actualState.Name | Should -Be 'TestName'
$propCount = $out.actualState | Get-Member -MemberType NoteProperty
$propCount = $out.actualState | Get-Member -MemberType NoteProperty
$propCount.Count | Should -Be 1 # Only the DscProperty should be returned
}

It 'Set works with class-based PS DSC resources' -Skip:(!$IsWindows) {

$out = dsc resource set -r PSClassResource/PSClassResource --input (@{Name = 'TestName' } | ConvertTo-Json) | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0
$out.afterstate.InDesiredState | Should -Be $true
}

It 'Export works with class-based PS DSC resources' -Skip:(!$IsWindows) {

$out = dsc resource export -r PSClassResource/PSClassResource | ConvertFrom-Json
$LASTEXITCODE | Should -Be 0
$out | Should -Not -BeNullOrEmpty
Expand Down
6 changes: 6 additions & 0 deletions process/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ fn get_task_list() -> Vec<ProcessInfo>
let mut result = Vec::new();
let mut s = System::new();
s.refresh_processes(ProcessesToUpdate::All, true);
let mut count = 0;
for (pid, process) in s.processes() {
let mut p = ProcessInfo::new();
p.pid = pid.as_u32();
p.name = process.name().to_string_lossy().to_string();
p.cmdline = format!("{:?}", process.cmd());
result.push(p);
count += 1;
if count > 3 {
// limit to 3 processes as this is just for testing
break;
}
}

result
Expand Down
Loading