diff --git a/src/parts/TssVersionObject.ps1 b/src/parts/TssVersionObject.ps1 index bccd5b88..ba338e5b 100644 --- a/src/parts/TssVersionObject.ps1 +++ b/src/parts/TssVersionObject.ps1 @@ -51,7 +51,7 @@ process { } } - switch ($source) { + switch ($source.Name) { 'Get-TssVersion' { $returnProps = 'Version' } diff --git a/tests/reports/New-TssReport.Tests.ps1 b/tests/reports/New-TssReport.Tests.ps1 index 6fd843a9..641d580e 100644 --- a/tests/reports/New-TssReport.Tests.ps1 +++ b/tests/reports/New-TssReport.Tests.ps1 @@ -1,8 +1,6 @@ BeforeDiscovery { $commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf . ([IO.Path]::Combine([string]$PSScriptRoot,'..','constants.ps1')) - - $PSDefaultParameterValues.Remove("*:TssSession") } Describe "$commandName verify parameters" { BeforeDiscovery { @@ -29,9 +27,8 @@ Describe "$commandName works" { BeforeDiscovery { $reportName = ("TssTestReport$(Get-Random)") $session = New-TssSession -SecretServer $ss -Credential $ssCred - $PSDefaultParameterValues.Add("*:TssSession",$session) - $categoryId = (Get-TssReportCategory -All).Where({$_.Name -eq 'tssModuleTest'}).CategoryId + $categoryId = (Get-TssReportCategory -TssSession $session -All).Where({$_.Name -eq 'tssModuleTest'}).CategoryId if ($null -eq $categoryId) { $bodData = @{ data = @{ @@ -41,10 +38,11 @@ Describe "$commandName works" { } | ConvertTo-Json # bug in endpoint where it won't return the Category ID properly Invoke-TssRestApi -Uri "$($session.ApiUrl)/reports/categories" -Method 'POST' -Body $bodData -PersonalAccessToken $session.AccessToken > $null - $categoryId = (Get-TssReportCategory -All).Where({$_.Name -eq 'tssModuleTest'}).CategoryId + $categoryId = (Get-TssReportCategory -TssSession $session -All).Where({$_.Name -eq 'tssModuleTest'}).CategoryId } $newReport = @{ + TssSession = $session ReportName = $reportName CategoryId = $categoryId Description = "Tss Module Test report" @@ -55,9 +53,8 @@ Describe "$commandName works" { # delete report created Invoke-TssRestApi -Uri "$($session.ApiUrl)/reports/$($object.Id)" -Method DELETE -PersonalAccessToken $session.AccessToken > $null - Remove-TssReportCategory -ReportCategoryId $categoryId -Confirm:$false > $null + Remove-TssReportCategory -TssSession $session -ReportCategoryId $categoryId -Confirm:$false > $null $session.SessionExpire() - $PSDefaultParameterValues.Remove("*:TssSession") } Context "Checking" -Foreach @{object = $object} { It "Should not be empty" { diff --git a/tests/reports/Remove-TssReportCategory.Tests.ps1 b/tests/reports/Remove-TssReportCategory.Tests.ps1 index 2e25cdd3..7449483a 100644 --- a/tests/reports/Remove-TssReportCategory.Tests.ps1 +++ b/tests/reports/Remove-TssReportCategory.Tests.ps1 @@ -1,8 +1,6 @@ BeforeDiscovery { $commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf . ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1')) - - $PSDefaultParameterValues.Remove("*:TssSession") } Describe "$commandName verify parameters" { BeforeDiscovery { @@ -28,7 +26,6 @@ Describe "$commandName verify parameters" { Describe "$commandName works" { BeforeDiscovery { $session = New-TssSession -SecretServer $ss -Credential $ssCred - $PSDefaultParameterValues.Add("*:TssSession",$session) $reportCatName = "tssModuleTest$(Get-Random)" $bodData = @{ @@ -39,12 +36,15 @@ Describe "$commandName works" { } | ConvertTo-Json # bug in endpoint where it won't return the Category ID properly Invoke-TssRestApi -Uri "$($session.ApiUrl)/reports/categories" -Method 'POST' -Body $bodData -PersonalAccessToken $session.AccessToken > $null - $categoryId = (Get-TssReportCategory -All).Where({$_.Name -eq $reportCatName}).CategoryId + $categoryId = (Get-TssReportCategory -TssSession $session -All).Where({$_.Name -eq $reportCatName}).CategoryId } - Context "Checking" -Foreach @{categoryId = $categoryId} { + Context "Checking" -Foreach @{categoryId = $categoryId; session = $session} { + AfterAll { + $session.SessionExpire() + } It "Should delete the category" { - Remove-TssReportCategory -ReportCategoryId $categoryId -Confirm:$false - $cat = Get-TssReportCategory -ReportCategoryId $categoryId -ErrorAction SilentlyContinue -WarningAction SilentlyContinue + Remove-TssReportCategory -TssSession $session -ReportCategoryId $categoryId -Confirm:$false + $cat = Get-TssReportCategory -TssSession $session -ReportCategoryId $categoryId -ErrorAction SilentlyContinue -WarningAction SilentlyContinue $cat | Should -BeNullOrEmpty } } diff --git a/tests/secrets/Set-TssSecret.Tests.ps1 b/tests/secrets/Set-TssSecret.Tests.ps1 index da7befcb..c52a4446 100644 --- a/tests/secrets/Set-TssSecret.Tests.ps1 +++ b/tests/secrets/Set-TssSecret.Tests.ps1 @@ -1,8 +1,6 @@ BeforeDiscovery { $commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf . ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1')) - - $PSDefaultParameterValues.Remove("*:TssSession") } Describe "$commandName verify parameters" { BeforeDiscovery {