diff --git a/tests/configurations/Get-TssConfiguration.Tests.ps1 b/tests/configurations/Get-Configuration.Tests.ps1 similarity index 100% rename from tests/configurations/Get-TssConfiguration.Tests.ps1 rename to tests/configurations/Get-Configuration.Tests.ps1 diff --git a/tests/constants.ps1 b/tests/constants.ps1 deleted file mode 100644 index 6792f648..00000000 --- a/tests/constants.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -if (Test-Path "$env:USERPROFILE\constants.ps1") { - if (-not $IsLinux) { - . "$env:USERPROFILE\constants.ps1" - } else { - . "$env:HOME/constants.ps1" - } -} else { - $script:ss = 'http://alpha' - # $script:ss = 'https://tenant.secretservercloud.com' - - $script:ssCred = $secretalphaCred - # $script:ssCred = $secretCloudCred - - $tssTestUsingWindowsAuth = $false -} diff --git a/tests/directory-services/Search-TssDirectoryServiceDomain.Tests.ps1 b/tests/directory-services/Search-DirectoryServiceDomain.Tests.ps1 similarity index 100% rename from tests/directory-services/Search-TssDirectoryServiceDomain.Tests.ps1 rename to tests/directory-services/Search-DirectoryServiceDomain.Tests.ps1 diff --git a/tests/folder-permissions/Get-TssFolderPermission.Tests.ps1 b/tests/folder-permissions/Get-FolderPermission.Tests.ps1 similarity index 100% rename from tests/folder-permissions/Get-TssFolderPermission.Tests.ps1 rename to tests/folder-permissions/Get-FolderPermission.Tests.ps1 diff --git a/tests/folder-permissions/New-TssFolderPermission.Tests.ps1 b/tests/folder-permissions/New-FolderPermission.Tests.ps1 similarity index 100% rename from tests/folder-permissions/New-TssFolderPermission.Tests.ps1 rename to tests/folder-permissions/New-FolderPermission.Tests.ps1 diff --git a/tests/folder-permissions/Remove-TssFolderPermission.Tests.ps1 b/tests/folder-permissions/Remove-FolderPermission.Tests.ps1 similarity index 100% rename from tests/folder-permissions/Remove-TssFolderPermission.Tests.ps1 rename to tests/folder-permissions/Remove-FolderPermission.Tests.ps1 diff --git a/tests/folder-permissions/Search-TssFolderPermission.Tests.ps1 b/tests/folder-permissions/Search-FolderPermission.Tests.ps1 similarity index 100% rename from tests/folder-permissions/Search-TssFolderPermission.Tests.ps1 rename to tests/folder-permissions/Search-FolderPermission.Tests.ps1 diff --git a/tests/folder-permissions/Set-TssFolderPermission.Tests.ps1 b/tests/folder-permissions/Set-FolderPermission.Tests.ps1 similarity index 100% rename from tests/folder-permissions/Set-TssFolderPermission.Tests.ps1 rename to tests/folder-permissions/Set-FolderPermission.Tests.ps1 diff --git a/tests/folders/Find-TssFolder.Tests.ps1 b/tests/folders/Find-Folder.Tests.ps1 similarity index 100% rename from tests/folders/Find-TssFolder.Tests.ps1 rename to tests/folders/Find-Folder.Tests.ps1 diff --git a/tests/folders/Get-TssFolder.Tests.ps1 b/tests/folders/Get-Folder.Tests.ps1 similarity index 100% rename from tests/folders/Get-TssFolder.Tests.ps1 rename to tests/folders/Get-Folder.Tests.ps1 diff --git a/tests/folders/Get-TssFolderAudit.Tests.ps1 b/tests/folders/Get-FolderAudit.Tests.ps1 similarity index 100% rename from tests/folders/Get-TssFolderAudit.Tests.ps1 rename to tests/folders/Get-FolderAudit.Tests.ps1 diff --git a/tests/folders/Get-TssFolderStub.Tests.ps1 b/tests/folders/Get-FolderStub.Tests.ps1 similarity index 100% rename from tests/folders/Get-TssFolderStub.Tests.ps1 rename to tests/folders/Get-FolderStub.Tests.ps1 diff --git a/tests/folders/New-TssFolder.Tests.ps1 b/tests/folders/New-Folder.Tests.ps1 similarity index 100% rename from tests/folders/New-TssFolder.Tests.ps1 rename to tests/folders/New-Folder.Tests.ps1 diff --git a/tests/folders/Remove-TssFolder.Tests.ps1 b/tests/folders/Remove-Folder.Tests.ps1 similarity index 100% rename from tests/folders/Remove-TssFolder.Tests.ps1 rename to tests/folders/Remove-Folder.Tests.ps1 diff --git a/tests/folders/Remove-TssFolderTemplate.Tests.ps1 b/tests/folders/Remove-FolderTemplate.Tests.ps1 similarity index 100% rename from tests/folders/Remove-TssFolderTemplate.Tests.ps1 rename to tests/folders/Remove-FolderTemplate.Tests.ps1 diff --git a/tests/folders/Search-TssFolder.Tests.ps1 b/tests/folders/Search-Folder.Tests.ps1 similarity index 100% rename from tests/folders/Search-TssFolder.Tests.ps1 rename to tests/folders/Search-Folder.Tests.ps1 diff --git a/tests/folders/Set-TssFolder.Tests.ps1 b/tests/folders/Set-Folder.Tests.ps1 similarity index 100% rename from tests/folders/Set-TssFolder.Tests.ps1 rename to tests/folders/Set-Folder.Tests.ps1 diff --git a/tests/functions/Get-TssVersion.Tests.ps1 b/tests/functions/Get-Version.Tests.ps1 similarity index 100% rename from tests/functions/Get-TssVersion.Tests.ps1 rename to tests/functions/Get-Version.Tests.ps1 diff --git a/tests/functions/Initialize-TssSdkClient.Tests.ps1 b/tests/functions/Initialize-SdkClient.Tests.ps1 similarity index 100% rename from tests/functions/Initialize-TssSdkClient.Tests.ps1 rename to tests/functions/Initialize-SdkClient.Tests.ps1 diff --git a/tests/functions/Invoke-TssRestApi.Tests.ps1 b/tests/functions/Invoke-RestApi.Tests.ps1 similarity index 56% rename from tests/functions/Invoke-TssRestApi.Tests.ps1 rename to tests/functions/Invoke-RestApi.Tests.ps1 index 71dcc988..213b88ea 100644 --- a/tests/functions/Invoke-TssRestApi.Tests.ps1 +++ b/tests/functions/Invoke-RestApi.Tests.ps1 @@ -16,31 +16,4 @@ Describe "$commandName Unit Tests" { $_ | Should -BeNullOrEmpty } } -} -Describe "$commandName works" { - BeforeDiscovery { - $invokeParams = @{} - if ($tssTestUsingWindowsAuth) { - $session = New-TssSession -SecretServer $ss -UseWindowsAuth - $invokeParams.UseDefaultCredentials = $true - } else { - $session = New-TssSession -SecretServer $ss -Credential $ssCred - $invokeParams.PersonalAccessToken = $session.AccessToken - } - - $invokeParams.Uri = $session.ApiUrl, "version" -join '/' - $restResponse = Invoke-TssRestApi @invokeParams - - if (-not $tssTestUsingWindowsAuth) { - $session.SessionExpire() - } - } - Context "Checking" -Foreach @{restResponse = $restResponse} { - It "Should not be empty" { - $restResponse | Should -Not -BeNullOrEmpty - } - It "Should be successful" { - $restResponse.success | Should -BeTrue - } - } } \ No newline at end of file diff --git a/tests/functions/New-Session.Tests.ps1 b/tests/functions/New-Session.Tests.ps1 new file mode 100644 index 00000000..0319916e --- /dev/null +++ b/tests/functions/New-Session.Tests.ps1 @@ -0,0 +1,25 @@ +BeforeDiscovery { + $commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf + . ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1')) +} +Describe "$commandName verify parameters" { + BeforeDiscovery { + [object[]]$knownParameters = 'SecretServer', 'Credential', 'AccessToken', 'UseWindowsAuth', 'UseSdkClient', 'ConfigPath' + [object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName, 'Function')).Parameters.Keys + [object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function') + $unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru + } + Context "Verify parameters" -ForEach @{currentParams = $currentParams } { + It "$commandName should contain <_> parameter" -TestCases $knownParameters { + $_ -in $currentParams | Should -Be $true + } + It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters { + $_ | Should -BeNullOrEmpty + } + } + Context "Command specific details" { + It "$commandName should set OutputType to TssSession" -TestCases $commandDetails { + $_.OutputType.Name | Should -Be 'TssSession' + } + } +} \ No newline at end of file diff --git a/tests/functions/New-TssSession.Tests.ps1 b/tests/functions/New-TssSession.Tests.ps1 deleted file mode 100644 index 4cae5030..00000000 --- a/tests/functions/New-TssSession.Tests.ps1 +++ /dev/null @@ -1,145 +0,0 @@ -BeforeDiscovery { - $commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf - . ([IO.Path]::Combine([string]$PSScriptRoot, '..', 'constants.ps1')) -} -Describe "$commandName verify parameters" { - BeforeDiscovery { - [object[]]$knownParameters = 'SecretServer', 'Credential', 'AccessToken', 'UseWindowsAuth', 'UseSdkClient', 'ConfigPath' - [object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName, 'Function')).Parameters.Keys - [object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function') - $unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru - } - Context "Verify parameters" -ForEach @{currentParams = $currentParams } { - It "$commandName should contain <_> parameter" -TestCases $knownParameters { - $_ -in $currentParams | Should -Be $true - } - It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters { - $_ | Should -BeNullOrEmpty - } - } - Context "Command specific details" { - It "$commandName should set OutputType to TssSession" -TestCases $commandDetails { - $_.OutputType.Name | Should -Be 'TssSession' - } - } -} - -Describe "$commandName works" { - Context "Validates SecretServer argument" { - It "Should catch invalid URL arguments" { - { New-TssSession -SecretServer 'https://alpha/api/v1' -AccessToken "$(Get-Random)" } | Should -Throw - } - It "Should not contain double forward slashes in PathAndQuery of ApiUrl" { - ([uri](New-TssSession -SecretServer 'https://alpah/SecretServer/' -AccessToken "$(Get-Random)").ApiUrl).PathAndQuery | Should -Not -Match "(?:\/\/)" - } - } - Context "Credential parameter" -Skip:$tssTestUsingWindowsAuth { - BeforeAll { - $apiV = 'api/v1' - $sessionCredential = New-TssSession -SecretServer $ss -Credential $ssCred - } - It "Populates SecretServer Property" { - $sessionCredential.SecretServer | Should -Be ([uri]$ss) - } - It "ApiVersion Property is set" { - $sessionCredential.ApiVersion | Should -Be $apiV - } - It "ApiUrl Property is set" { - $sessionCredential.ApiUrl | Should -Not -BeNullOrEmpty - } - It "Populates AccessToken Property" { - $sessionCredential.AccessToken | Should -Not -BeNullOrEmpty - } - It "Populates RefreshToken Property" { - $sessionCredential.RefreshToken | Should -Not -BeNullOrEmpty - } - It "Calculates TimeOfDeath" { - $expectedValue = "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f [datetime]::Now.Add([timespan]::FromSeconds($expiresIn)) - "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f $sessionCredential.TimeOfDeath | Should -BeGreaterOrEqual $expectedValue - } - It "Calculates StartTime" { - $currentTime = "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f [datetime]::Now - "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f $sessionCredential.StartTime | Should -BeGreaterOrEqual $currentTime - } - It "RefreshSession() method updates AccessToken" { - $orgAccessToken = $sessionCredential.AccessToken - $sessionCredential.SessionRefresh() | Should -Be $true - $sessionCredential.AccessToken | Should -Not -Match $orgAccessToken - } - It "SessionExpire() method should return true" { - $sessionCredential.SessionExpire() | Should -Be $true - } - It "Sets TokenType to bearer" { - $sessionCredential.TokenType | Should -Be 'bearer' - } - } - Context "AccessToken parameter" { - BeforeAll { - $secretServerHost = 'https://tenant.secretservercloud.com' - $generatedAccessToken = (New-Guid).Guid - $sessionAccessToken = New-TssSession -SecretServer $secretServerHost -AccessToken $generatedAccessToken - } - It "Should set SecretServer to <_>" -TestCases $secretServerHost { - $sessionAccessToken.SecretServer | Should -Be $_ - } - It "Sets AccessToken to <_>" -TestCases $generatedAccessToken { - $sessionAccessToken.AccessToken | Should $_ - } - It "ApiUrl Property is set" { - $sessionAccessToken.ApiUrl | Should -Not -BeNullOrEmpty - } - It "Does not populate a RefreshToken Property" { - $sessionAccessToken.RefreshToken | Should -BeNullOrEmpty - } - It "SessionExpire() method should return true" { - $sessionAccessToken.SessionExpire() | Should -Be $true - } - It "SessionRefresh() method should return false" { - $sessionAccessToken.SessionRefresh() 3>$null | Should -Be $false - } - It "Does not calculate a TimeOfDeath" { - "{0:yyyy}-{0:MM}-{0:dd}" -f $sessionAccessToken.TimeOfDeath | Should -Be ([datetime]'0001-01-01') - } - It "Calculates StartTime" { - $currentTime = "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f [datetime]::Now - "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f $sessionAccessToken.StartTime | Should -BeLessOrEqual $currentTime - } - It "Sets TokenType to ExternalToken" { - $sessionAccessToken.TokenType | Should -Be 'ExternalToken' - } - } - Context "UseWindowsAuth" { - BeforeAll { - $secretServerHost = 'https://tenant.secretservercloud.com' - $sessionWinAuth = New-TssSession -SecretServer $secretServerHost -UseWindowsAuth - } - It "Should set SecretServer to <_>" -TestCases $secretServerHost { - $sessionWinAuth.SecretServer | Should -Be $_ - } - It "Does not set AccessToken" { - $sessionWinAuth.AccessToken | Should -BeNullOrEmpty - } - It "ApiUrl Property is set" { - $sessionWinAuth.ApiUrl | Should -Not -BeNullOrEmpty - } - It "Does not populate a RefreshToken Property" { - $sessionWinAuth.RefreshToken | Should -BeNullOrEmpty - } - It "SessionExpire() method should return false" { - $sessionWinAuth.SessionExpire() 3>$null | Should -Be $false - } - It "SessionRefresh() method should return false" { - $sessionWinAuth.SessionRefresh() 3>$null | Should -Be $false - } - It "Does not calculate a TimeOfDeath" { - "{0:yyyy}-{0:MM}-{0:dd}" -f $sessionWinAuth.TimeOfDeath | Should -Be ([datetime]'0001-01-01') - } - It "Calculates StartTime" { - $currentTime = "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f [datetime]::Now - "{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}" -f $sessionWinAuth.StartTime | Should -BeLessOrEqual $currentTime - } - It "Sets TokenType to WindowsAuth" { - $sessionWinAuth.TokenType | Should -Be 'WindowsAuth' - } - } -} diff --git a/tests/functions/Test-TssVersion.Tests.ps1 b/tests/functions/Test-Version.Tests.ps1 similarity index 64% rename from tests/functions/Test-TssVersion.Tests.ps1 rename to tests/functions/Test-Version.Tests.ps1 index 0c1849eb..bf5244bc 100644 --- a/tests/functions/Test-TssVersion.Tests.ps1 +++ b/tests/functions/Test-Version.Tests.ps1 @@ -22,26 +22,4 @@ Describe "$commandName verify parameters" { $_.OutputType.Name | Should -Be 'TssVersion' } } -} -Describe "$commandName works" { - BeforeDiscovery { - if ($tssTestUsingWindowsAuth) { - $session = New-TssSession -SecretServer $ss -UseWindowsAuth - } else { - $session = New-TssSession -SecretServer $ss -Credential $ssCred - } - $object = Test-TssVersion $session - - if (-not $tssTestUsingWindowsAuth) { - $session.SessionExpire() - } - } - Context "Checking" -Foreach @{object = $object} { - It "Should not be empty" { - $object | Should -Not -BeNullOrEmpty - } - It "Should contain property <_>" -TestCases 'Version','LatestVersion','IsLatest' { - $object.PSObject.Properties.Name | Should -Contain $_ - } - } } \ No newline at end of file diff --git a/tests/reports/Get-TssReport.Tests.ps1 b/tests/reports/Get-Report.Tests.ps1 similarity index 100% rename from tests/reports/Get-TssReport.Tests.ps1 rename to tests/reports/Get-Report.Tests.ps1 diff --git a/tests/reports/Get-TssReportCategory.Tests.ps1 b/tests/reports/Get-ReportCategory.Tests.ps1 similarity index 100% rename from tests/reports/Get-TssReportCategory.Tests.ps1 rename to tests/reports/Get-ReportCategory.Tests.ps1 diff --git a/tests/reports/New-TssReport.Tests.ps1 b/tests/reports/New-Report.Tests.ps1 similarity index 100% rename from tests/reports/New-TssReport.Tests.ps1 rename to tests/reports/New-Report.Tests.ps1 diff --git a/tests/reports/Remove-TssReportCategory.Tests.ps1 b/tests/reports/Remove-ReportCategory.Tests.ps1 similarity index 100% rename from tests/reports/Remove-TssReportCategory.Tests.ps1 rename to tests/reports/Remove-ReportCategory.Tests.ps1 diff --git a/tests/reports/Search-TssReportSchedule.Tests.ps1 b/tests/reports/Search-ReportSchedule.Tests.ps1 similarity index 100% rename from tests/reports/Search-TssReportSchedule.Tests.ps1 rename to tests/reports/Search-ReportSchedule.Tests.ps1 diff --git a/tests/roles/Search-TssRole.Tests.ps1 b/tests/roles/Search-Role.Tests.ps1 similarity index 100% rename from tests/roles/Search-TssRole.Tests.ps1 rename to tests/roles/Search-Role.Tests.ps1 diff --git a/tests/secrets/Disable-TssSecretCheckout.Tests.ps1 b/tests/secrets/Disable-SecretCheckout.Tests.ps1 similarity index 100% rename from tests/secrets/Disable-TssSecretCheckout.Tests.ps1 rename to tests/secrets/Disable-SecretCheckout.Tests.ps1 diff --git a/tests/secrets/Disable-TssSecretEmail.Tests.ps1 b/tests/secrets/Disable-SecretEmail.Tests.ps1 similarity index 100% rename from tests/secrets/Disable-TssSecretEmail.Tests.ps1 rename to tests/secrets/Disable-SecretEmail.Tests.ps1 diff --git a/tests/secrets/Enable-TssSecretCheckout.Tests.ps1 b/tests/secrets/Enable-SecretCheckout.Tests.ps1 similarity index 100% rename from tests/secrets/Enable-TssSecretCheckout.Tests.ps1 rename to tests/secrets/Enable-SecretCheckout.Tests.ps1 diff --git a/tests/secrets/Enable-TssSecretEmail.Tests.ps1 b/tests/secrets/Enable-SecretEmail.Tests.ps1 similarity index 100% rename from tests/secrets/Enable-TssSecretEmail.Tests.ps1 rename to tests/secrets/Enable-SecretEmail.Tests.ps1 diff --git a/tests/secrets/Find-TssSecret.Tests.ps1 b/tests/secrets/Find-Secret.Tests.ps1 similarity index 100% rename from tests/secrets/Find-TssSecret.Tests.ps1 rename to tests/secrets/Find-Secret.Tests.ps1 diff --git a/tests/secrets/Get-TssSecretAttachment.Tests.ps1 b/tests/secrets/Get-SecretAttachment.Tests.ps1 similarity index 100% rename from tests/secrets/Get-TssSecretAttachment.Tests.ps1 rename to tests/secrets/Get-SecretAttachment.Tests.ps1 diff --git a/tests/secrets/Get-TssSecretAudit.Tests.ps1 b/tests/secrets/Get-SecretAudit.Tests.ps1 similarity index 100% rename from tests/secrets/Get-TssSecretAudit.Tests.ps1 rename to tests/secrets/Get-SecretAudit.Tests.ps1 diff --git a/tests/secrets/Get-TssSecretField.Tests.ps1 b/tests/secrets/Get-SecretField.Tests.ps1 similarity index 100% rename from tests/secrets/Get-TssSecretField.Tests.ps1 rename to tests/secrets/Get-SecretField.Tests.ps1 diff --git a/tests/secrets/Get-TssSecretHeartbeatStatus.Tests.ps1 b/tests/secrets/Get-SecretHeartbeatStatus.Tests.ps1 similarity index 100% rename from tests/secrets/Get-TssSecretHeartbeatStatus.Tests.ps1 rename to tests/secrets/Get-SecretHeartbeatStatus.Tests.ps1 diff --git a/tests/secrets/Get-TssSecretPasswordStatus.Tests.ps1 b/tests/secrets/Get-SecretPasswordStatus.Tests.ps1 similarity index 100% rename from tests/secrets/Get-TssSecretPasswordStatus.Tests.ps1 rename to tests/secrets/Get-SecretPasswordStatus.Tests.ps1 diff --git a/tests/secrets/Get-TssSecretState.Tests.ps1 b/tests/secrets/Get-SecretState.Tests.ps1 similarity index 100% rename from tests/secrets/Get-TssSecretState.Tests.ps1 rename to tests/secrets/Get-SecretState.Tests.ps1 diff --git a/tests/secrets/Search-TssSecret.Tests.ps1 b/tests/secrets/Search-Secret.Tests.ps1 similarity index 100% rename from tests/secrets/Search-TssSecret.Tests.ps1 rename to tests/secrets/Search-Secret.Tests.ps1