Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 2.5.2 (not released yet)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## 2.5.2 (not released yet)
## 2.6.0 (not released yet)

Please note that you have to request a release for this from @ChristianJ-TV or @stefanhubertus when it is merged.


### Updated

- Updates `Get-TeamViewerGroup` to list the assigned PolicyID of a defined group


## 2.5.1 (not released yet)

Expand Down
1 change: 1 addition & 0 deletions Cmdlets/Private/ConvertTo-TeamViewerGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function ConvertTo-TeamViewerGroup {
Id = $InputObject.id
Name = $InputObject.name
Permissions = $InputObject.permissions
PolicyId = $InputObject.policy_id
SharedWith = @($InputObject.shared_with | ConvertTo-TeamViewerGroupShare)
}
if ($InputObject.owner) {
Expand Down
4 changes: 3 additions & 1 deletion Cmdlets/Public/Get-TeamViewerGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function Get-TeamViewerGroup {
Write-Output ($response | ConvertTo-TeamViewerGroup)
}
else {
Write-Output ($response.groups | ConvertTo-TeamViewerGroup)
$groups = @($response.groups | ConvertTo-TeamViewerGroup)
$groups | ForEach-Object { $_.PSObject.Properties.Remove('PolicyId') }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why don't we want the PolicyId field when requesting multiple groups?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes, this is very individual. Personally, I don't need this information in the all group output.
If you say you want it, I can remove my filter again.
I just wanted to keep the "general" output streamlined.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the WebApi endpoint exposes it, I don't see a reason for not including it in the Powershell's response :)

Write-Output $groups
}
}
2 changes: 1 addition & 1 deletion Cmdlets/TeamViewerPS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RootModule = 'TeamViewerPS.psm1'

# Version number of this module.
ModuleVersion = '2.5.1'
ModuleVersion = '2.5.2'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch version is for documentation changes and other such fixes. Here, we are doing much more than that, hence a minor version bump is in order.

Suggested change
ModuleVersion = '2.5.2'
ModuleVersion = '2.6.0'


# Supported PSEditions.
# CompatiblePSEditions = @()
Expand Down
21 changes: 17 additions & 4 deletions Tests/Public/Get-TeamViewerGroup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ BeforeAll {
Mock Get-TeamViewerApiUri { '//unit.test' }
Mock Invoke-TeamViewerRestMethod { @{
groups = @(
@{ id = 'g1234'; name = 'test group 1' },
@{ id = 'g4567'; name = 'test group 2' },
@{ id = 'g8901'; name = 'test group 3' }
@{ id = 'g1234'; name = 'test group 1'; policy_id = 'p1234' },
@{ id = 'g4567'; name = 'test group 2'; policy_id = 'p4567' },
@{ id = 'g8901'; name = 'test group 3'; policy_id = 'p8901' }
)
} }
Mock Invoke-TeamViewerRestMethod { @{ id = 'g1234'; name = 'test group 1'; policy_id = 'p1234' } } -ParameterFilter {
$Uri -eq '//unit.test/groups/g1234'
}
}

Describe 'Get-TeamViewerGroup' {
Expand All @@ -29,7 +32,7 @@ Describe 'Get-TeamViewerGroup' {
}

It 'Should call the correct API endpoint for single group' {
Get-TeamViewerGroup -ApiToken $testApiToken -Group 'g1234'
Get-TeamViewerGroup -ApiToken $testApiToken -Id 'g1234'

Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter {
$ApiToken -eq $testApiToken -And `
Expand Down Expand Up @@ -62,4 +65,14 @@ Describe 'Get-TeamViewerGroup' {
Assert-MockCalled Invoke-TeamViewerRestMethod -Times 1 -Scope It -ParameterFilter {
$Body -And $Body['name'] -eq 'TestName' }
}

It 'Should include PolicyId when getting single group' {
$result = Get-TeamViewerGroup -ApiToken $testApiToken -Id 'g1234'
$result.PolicyId | Should -Be 'p1234'
}

It 'Should exclude PolicyId when filtering groups' {
$result = Get-TeamViewerGroup -ApiToken $testApiToken
$result[0].PSObject.Properties.Name | Should -Not -Contain 'PolicyId'
}
}