Skip to content

Commit

Permalink
add membership to PSDrive
Browse files Browse the repository at this point in the history
  • Loading branch information
Seekatar committed Aug 10, 2019
1 parent fbc3a09 commit 5594277
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 6.3.2

Add PSDrive support for memberships

- Memberships
- Groups
- Group1
- Users
- User1


## 6.3.1

Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/178) from [Jim W](https://github.com/Seekatar) which included the following:
Expand Down
3 changes: 2 additions & 1 deletion Source/Classes/VSTeamAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class VSTeamAccount : SHiPSDirectory {
$poolsAndProjects = @(
[VSTeamPools]::new('Agent Pools'),
[VSTeamExtensions]::new('Extensions')
[VSTeamFeeds]::new('Feeds')
[VSTeamFeeds]::new('Feeds'),
[VSTeamPermissions]::new('Permissions')
)

$items = Get-VSTeamProject | Sort-Object Name
Expand Down
29 changes: 29 additions & 0 deletions Source/Classes/VSTeamGroups.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using namespace Microsoft.PowerShell.SHiPS

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamGroups : VSTeamDirectory {

# Default constructor
VSTeamGroups(
[string]$Name
) : base($Name, $null) {
$this.AddTypeName('Team.Groups')

$this.DisplayMode = 'd-r-s-'
}

[object[]] GetChildItem() {
$Groups = Get-VSTeamGroup -ErrorAction SilentlyContinue | Sort-Object name

$objs = @()

foreach ($Group in $Groups) {
$Group.AddTypeName('Team.Provider.Group')

$objs += $Group
}

return $objs
}
}
24 changes: 24 additions & 0 deletions Source/Classes/VSTeamPermissions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using namespace Microsoft.PowerShell.SHiPS

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamPermissions : VSTeamDirectory {

# Default constructor
VSTeamPermissions(
[string]$Name
) : base($Name, $null) {
$this.AddTypeName('Team.Permissions')

$this.DisplayMode = 'd-r-s-'
}

[object[]] GetChildItem() {
$groupsAndUsers = @(
[VSTeamGroups]::new('Groups'),
[VSTeamUsers]::new('Users')
)

return $groupsAndUsers
}
}
29 changes: 29 additions & 0 deletions Source/Classes/VSTeamUsers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using namespace Microsoft.PowerShell.SHiPS

[SHiPSProvider(UseCache = $true)]
[SHiPSProvider(BuiltinProgress = $false)]
class VSTeamUsers : VSTeamDirectory {

# Default constructor
VSTeamUsers(
[string]$Name
) : base($Name, $null) {
$this.AddTypeName('Team.Users')

$this.DisplayMode = 'd-r-s-'
}

[object[]] GetChildItem() {
$Users = Get-VSTeamUser -ErrorAction SilentlyContinue | Sort-Object name

$objs = @()

foreach ($User in $Users) {
$User.AddTypeName('Team.Provider.User')

$objs += $User
}

return $objs
}
}
3 changes: 3 additions & 0 deletions Source/Classes/_classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"VSTeamBuildDefinition.ps1",
"VSTeamExtension.ps1",
"VSTeamFeed.ps1",
"VSTeamUsers.ps1",
"VSTeamGroups.ps1",
"VSTeamPermissions.ps1",
"VSTeamProcess.ps1",
"VSTeamRef.ps1",
"VSTeamTeam.ps1",
Expand Down
17 changes: 14 additions & 3 deletions Source/en-US/about_vsteam_provider.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ SHORT DESCRIPTION
- Agent1
- JobRequest1
- JobRequest2
- Extensions
- Extension1
- Extension2
- Feeds
- Feed1
- Feed2
- Memberships
- Groups
- Group1
- Users
- User1
- Project1
- Project2
- Builds
Expand All @@ -33,10 +44,10 @@ SHORT DESCRIPTION
- Ref2

LONG DESCRIPTION
You use the New-PSDrive cmdlet to mount a drive to your account.
You use the New-PSDrive cmdlet to mount a drive to your account.

You can also use the -Drive parameter of Set-VSTeamAccount to have
the required command written to the console so you can copy and
the required command written to the console so you can copy and
paste the command.

The provider caches the results. To force a round trip to skip the
Expand All @@ -49,7 +60,7 @@ EXAMPLES
Get-ChildItem

Set-VSTeamAccount -Profile '[profileName]' -Drive '[driveName]'

To map a drive run the following command:
New-PSDrive -Name driveName -PSProvider SHiPS -Root 'VSTeam#VSTeamAccount'

Expand Down
2 changes: 1 addition & 1 deletion Source/formats/Team.Build.TableView.ps1xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" ?><Configuration><ViewDefinitions><View><Name>Team.Build.TableView</Name><ViewSelectedBy><TypeName>Team.Provider.Build</TypeName><TypeName>VSTeamBuild</TypeName></ViewSelectedBy><TableControl><TableHeaders><TableColumnHeader><Label>Mode</Label></TableColumnHeader><TableColumnHeader><Label>Build Number</Label></TableColumnHeader><TableColumnHeader><Label>Status</Label></TableColumnHeader><TableColumnHeader><Label>Result</Label></TableColumnHeader><TableColumnHeader><Label>Build Definition</Label></TableColumnHeader></TableHeaders><TableRowEntries><TableRowEntry><TableColumnItems><TableColumnItem><PropertyName>DisplayMode</PropertyName></TableColumnItem><TableColumnItem><PropertyName>name</PropertyName></TableColumnItem><TableColumnItem><PropertyName>status</PropertyName></TableColumnItem><TableColumnItem><PropertyName>result</PropertyName></TableColumnItem><TableColumnItem><PropertyName>BuildDefinition</PropertyName></TableColumnItem></TableColumnItems></TableRowEntry></TableRowEntries></TableControl></View></ViewDefinitions></Configuration>
<?xml version="1.0" encoding="utf-8"?><Configuration><ViewDefinitions><View><Name>Team.PSDrive.Default.TableView</Name><ViewSelectedBy><TypeName>Microsoft.PowerShell.SHiPS.SHiPSDirectory</TypeName><TypeName>Team.Account</TypeName><TypeName>Team.Pool</TypeName><TypeName>Team.Queues</TypeName><TypeName>Team.Pools</TypeName><TypeName>Team.Provider.Pools</TypeName><TypeName>Team.Builds</TypeName><TypeName>Team.BuildDefinitions</TypeName><TypeName>Team.Releases</TypeName><TypeName>Team.Repositories</TypeName><TypeName>Team.Teams</TypeName><TypeName>Team.Permissions</TypeName><TypeName>Team.Groups</TypeName><TypeName>Team.Users</TypeName></ViewSelectedBy><TableControl><AutoSize /><TableHeaders><TableColumnHeader><Label>Mode</Label></TableColumnHeader><TableColumnHeader><Label>Name</Label></TableColumnHeader></TableHeaders><TableRowEntries><TableRowEntry><Wrap /><TableColumnItems><TableColumnItem><PropertyName>DisplayMode</PropertyName></TableColumnItem><TableColumnItem><PropertyName>Name</PropertyName></TableColumnItem></TableColumnItems></TableRowEntry></TableRowEntries></TableControl></View></ViewDefinitions></Configuration>
2 changes: 1 addition & 1 deletion Source/formats/Team.PSDrive.Default.TableView.ps1xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8" ?><Configuration><ViewDefinitions><View><Name>Team.PSDrive.Default.TableView</Name><ViewSelectedBy><TypeName>Microsoft.PowerShell.SHiPS.SHiPSDirectory</TypeName><TypeName>Team.Account</TypeName><TypeName>Team.Pool</TypeName><TypeName>Team.Queues</TypeName><TypeName>Team.Pools</TypeName><TypeName>Team.Provider.Pools</TypeName><TypeName>Team.Builds</TypeName><TypeName>Team.BuildDefinitions</TypeName><TypeName>Team.Releases</TypeName><TypeName>Team.Repositories</TypeName><TypeName>Team.Teams</TypeName></ViewSelectedBy><TableControl><AutoSize /><TableHeaders><TableColumnHeader><Label>Mode</Label></TableColumnHeader><TableColumnHeader><Label>Name</Label></TableColumnHeader></TableHeaders><TableRowEntries><TableRowEntry><Wrap /><TableColumnItems><TableColumnItem><PropertyName>DisplayMode</PropertyName></TableColumnItem><TableColumnItem><PropertyName>Name</PropertyName></TableColumnItem></TableColumnItems></TableRowEntry></TableRowEntries></TableControl></View></ViewDefinitions></Configuration>
<?xml version="1.0" encoding="utf-8"?><Configuration><ViewDefinitions><View><Name>Team.PSDrive.Default.TableView</Name><ViewSelectedBy><TypeName>Microsoft.PowerShell.SHiPS.SHiPSDirectory</TypeName><TypeName>Team.Account</TypeName><TypeName>Team.Pool</TypeName><TypeName>Team.Queues</TypeName><TypeName>Team.Pools</TypeName><TypeName>Team.Provider.Pools</TypeName><TypeName>Team.Builds</TypeName><TypeName>Team.BuildDefinitions</TypeName><TypeName>Team.Releases</TypeName><TypeName>Team.Repositories</TypeName><TypeName>Team.Teams</TypeName><TypeName>Team.Permissions</TypeName><TypeName>Team.Groups</TypeName><TypeName>Team.Users</TypeName></ViewSelectedBy><TableControl><AutoSize /><TableHeaders><TableColumnHeader><Label>Mode</Label></TableColumnHeader><TableColumnHeader><Label>Name</Label></TableColumnHeader></TableHeaders><TableRowEntries><TableRowEntry><Wrap /><TableColumnItems><TableColumnItem><PropertyName>DisplayMode</PropertyName></TableColumnItem><TableColumnItem><PropertyName>Name</PropertyName></TableColumnItem></TableColumnItems></TableRowEntry></TableRowEntries></TableControl></View></ViewDefinitions></Configuration>
29 changes: 27 additions & 2 deletions unit/test/teamspsdrive.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ InModuleScope VSTeam {
}
}
}

Describe 'VSTS Build Definition' {
# Mock the call to Get-Projects by the dynamic parameter for ProjectName
Mock Invoke-RestMethod { return @() } -ParameterFilter {
Expand Down Expand Up @@ -209,7 +209,8 @@ InModuleScope VSTeam {
# Skip 0 because that will be Agent Pools
# Skip 1 because that will be Extensions
# Skip 2 because that will be Feeds
$project = $account.GetChildItem()[3]
# Skip 3 because that will be Permissions
$project = $account.GetChildItem()[4]

It 'Should return projects' {
$project | Should Not Be $null
Expand Down Expand Up @@ -538,5 +539,29 @@ InModuleScope VSTeam {
$team | Should Not Be $null
}
}

Context 'Permissions' {
Set-StrictMode -Version Latest
Mock Get-VSTeamGroup { return [VSTeamGroup]::new(@{})}
Mock Get-VSTeamUser { return [VSTeamGroup]::new(@{})}

$permissions = [VSTeamPermissions]::new('Permissions')

It 'Should create Permissions' {
$permissions | Should Not Be $null
$permissions.GetChildItem().Count | Should Be 2
}

$groups = $permissions.GetChildItem()[0]
$users = $permissions.GetChildItem()[1]

It 'Should return groups' {
$groups | Should Not Be $null
}

It 'Should return users' {
$users | Should Not Be $null
}
}
}
}

0 comments on commit 5594277

Please sign in to comment.