Skip to content

Commit

Permalink
Carbon_Group: Use Carbon_Accounts_Identity.FullName for Members
Browse files Browse the repository at this point in the history
This takes care of missing `.Dispose()`
  • Loading branch information
qubetzl committed Nov 29, 2024
1 parent cbe2f45 commit fba560a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Carbon.DSC/DscResources/Carbon_Group/Carbon_Group.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ function Get-TargetResource
if( $group )
{
$description = $group.Description
$members = $group.Members
$members = @($group.Members | Resolve-PrincipalName)
$ensure = 'Present'
$group.Dispose()
}

@{
Expand Down Expand Up @@ -166,7 +167,7 @@ function Set-TargetResource
{
$memberNames = $Members | Resolve-MemberName
}
$currentMemberNames = @((Get-TargetResource -Name $Name).Members | Resolve-PrincipalName)
$currentMemberNames = (Get-TargetResource -Name $Name).Members

$membershipChanges = Resolve-MembershipChange -EnsureMembers $EnsureMembers `
-MemberNames $memberNames `
Expand Down Expand Up @@ -266,11 +267,10 @@ function Test-TargetResource
{
$memberNames = $Members | Resolve-MemberName
}
$currentMemberNames = @($resource.Members | Resolve-PrincipalName)

$membershipChanges = Resolve-MembershipChange -EnsureMembers $EnsureMembers `
-MemberNames $memberNames `
-CurrentMemberNames $currentMemberNames
-CurrentMemberNames $resource.Members

if ($membershipChanges.ToAdd)
{
Expand Down
15 changes: 2 additions & 13 deletions Tests/Carbon_Group.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,9 @@ Describe 'Carbon_Group' {
Assert-DscResourcePresent $resource

$resource.Members.Count | Should -Be $admins.Members.Count
$resourceMembers = $resource.Members | ForEach-Object { Resolve-CIdentity -Name $_ }

foreach( $admin in $admins.Members )
{
$found = $false
foreach( $potentialAdmin in $resource.Members )
{
if( $potentialAdmin.Sid -eq $admin.Sid )
{
$found = $true
break
}
}
$found | Should -BeTrue
}
$resourceMembers.Sid | Should -Be $admins.Members.Sid
}

It 'get target resource does not exist' {
Expand Down

0 comments on commit fba560a

Please sign in to comment.