From bfb4e2594b6f3425c83582162e09012190c3f614 Mon Sep 17 00:00:00 2001 From: Stefan Hubertus Date: Thu, 21 Sep 2023 10:04:51 +0200 Subject: [PATCH] Revert "Merge pull request #38 from karthickgandhiTV/main" This reverts commit 7e620256404ebe50af0689b7c829c5399b10f737, reversing changes made to 4d70b5dd4990b2ce361257c42e6c8c1e40dbaa15. --- .github/workflows/powershell-analysis.yml | 6 +++--- .github/workflows/publish_production.yml | 2 +- .github/workflows/publish_testing.yml | 2 +- Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 | 3 +++ docs/Cmdlets/Private/Get-ClientId.ps1 | 1 + docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 | 2 +- docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 | 1 + docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 | 1 + 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/powershell-analysis.yml b/.github/workflows/powershell-analysis.yml index cd0427c..27cb284 100644 --- a/.github/workflows/powershell-analysis.yml +++ b/.github/workflows/powershell-analysis.yml @@ -22,7 +22,7 @@ jobs: name: PSScriptAnalyzer runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@2044ae068e37d0161fa2127de04c19633882f061 @@ -31,8 +31,8 @@ jobs: # The below set up runs PSScriptAnalyzer to your entire repository and runs some basic security rules. path: .\ recurse: true - # Exclude your own basic security rules. Removing this option will run all the rules - excludeRule: '"PSUseToExportFieldsInManifest","PSAvoidGlobalVars"' + # Include your own basic security rules. Removing this option will run all the rules + # includeRule: '"PSAvoidGlobalAliases", "PSAvoidUsingConvertToSecureStringWithPlainText"' output: results.sarif # Upload the SARIF file generated in the previous step diff --git a/.github/workflows/publish_production.yml b/.github/workflows/publish_production.yml index 8b5fc43..ff69da6 100644 --- a/.github/workflows/publish_production.yml +++ b/.github/workflows/publish_production.yml @@ -10,7 +10,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/.github/workflows/publish_testing.yml b/.github/workflows/publish_testing.yml index b943a5c..11b03b6 100644 --- a/.github/workflows/publish_testing.yml +++ b/.github/workflows/publish_testing.yml @@ -8,7 +8,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - name: Build package shell: pwsh diff --git a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 index d6ca0ac..0d6dec6 100644 --- a/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 +++ b/Tests/Public/Add-TeamViewerRoleToUserGroup.Tests.ps1 @@ -9,6 +9,7 @@ BeforeAll { $null = $testUserGroup $testUserRoleId = '9b465ea2-2f75-4101-a057-58a81ed0e57b' $null = $testUserRoleId + Mock Get-TeamViewerApiUri { '//unit.test' } $mockArgs = @{} Mock Invoke-TeamViewerRestMethod { $mockArgs.Body = $Body @@ -19,8 +20,10 @@ BeforeAll { } } Describe 'Add-TeamViewerRoleToUserGroup' { + It 'Should call the correct API endpoint' { Add-TeamViewerRoleToUserGroup -ApiToken $testApiToken -UserRoleId $testUserRoleId -UserGroup $testUserGroup + Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter { $ApiToken -eq $testApiToken -And ` $Uri -eq '//unit.test/userroles/assign/usergroup' -And ` diff --git a/docs/Cmdlets/Private/Get-ClientId.ps1 b/docs/Cmdlets/Private/Get-ClientId.ps1 index eedf9f6..5312ba5 100644 --- a/docs/Cmdlets/Private/Get-ClientId.ps1 +++ b/docs/Cmdlets/Private/Get-ClientId.ps1 @@ -7,5 +7,6 @@ function Get-ClientId { $mainKey = Get-ItemProperty -Path 'HKLM:\Software\TeamViewer' $id = [int]$mainKey.ClientID } + return $id } diff --git a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 index e560a5a..58cd1f3 100644 --- a/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 +++ b/docs/Cmdlets/Public/Add-TeamViewerRoleToUserGroup.ps1 @@ -21,7 +21,7 @@ function Add-TeamViewerRoleToUserGroup { Begin { $RoleId = $UserRole | Resolve-TeamViewerUserRoleId - $null = $ApiToken + $null = $ApiToken $resourceUri = "$(Get-TeamViewerApiUri)/userroles/assign/usergroup" $body = @{ UserRoleId = $RoleId diff --git a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 index f053140..faffda7 100644 --- a/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 +++ b/docs/Cmdlets/Public/Remove-TeamViewerPSProxy.ps1 @@ -4,6 +4,7 @@ function Remove-TeamViewerPSProxy { $global:TeamViewerProxyUriRemoved = $true $global:TeamViewerProxyUriRemoved | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 + if($PSCmdlet.ShouldProcess($TeamViewerProxyUriRemoved,"Remove proxy for WebAPI")){ $global:TeamViewerProxyUriSet = $null $global:TeamViewerProxyUriSet | Out-Null # https://github.com/PowerShell/PSScriptAnalyzer/issues/1472 diff --git a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 index d8dbae1..aecc984 100644 --- a/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 +++ b/docs/Cmdlets/Public/Set-TeamViewerUserRole.ps1 @@ -34,6 +34,7 @@ function Set-TeamViewerUserRole { $body.Permissions = @($Permissions) } } + Process { if ($PSCmdlet.ShouldProcess($Name, 'Update User Role')) { $response = Invoke-TeamViewerRestMethod `