Skip to content

Commit

Permalink
ADGroup: Test SamAccountName parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelicWizard committed May 20, 2021
1 parent 0eea8a4 commit 47c730e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/Unit/MSFT_ADGroup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ try
Path = 'OU=OU,DC=contoso,DC=com'
Description = 'Test AD group description'
DisplayName = 'Test display name'
SamAccountName = 'TestGroup'
Ensure = 'Present'
Notes = 'This is a test AD group'
ManagedBy = 'CN=User 1,CN=Users,DC=contoso,DC=com'
Expand Down Expand Up @@ -91,6 +92,7 @@ try
Path = $mockGroupPath
Description = 'Test AD group description'
DisplayName = 'Test display name'
SamAccountName = $mockGroupName
Info = 'This is a test AD group'
ManagedBy = 'CN=User 1,CN=Users,DC=contoso,DC=com'
DistinguishedName = "CN=$mockGroupName,$mockGroupPath"
Expand All @@ -101,6 +103,7 @@ try
GroupScope = 'Universal'
Description = 'Test AD group description changed'
DisplayName = 'Test display name changed'
SamAccountName = 'TestGroup2'
ManagedBy = 'CN=User 2,CN=Users,DC=contoso,DC=com'
}

Expand All @@ -111,6 +114,7 @@ try
Path = $mockADGroup.Path
Description = $mockADGroup.Description
DisplayName = $mockADGroup.DisplayName
SamAccountName = $mockAdGroup.SamAccountName
Notes = $mockADGroup.Info
ManagedBy = $mockADGroup.ManagedBy
DistinguishedName = $mockADGroup.DistinguishedName
Expand All @@ -125,6 +129,7 @@ try
Path = $null
Description = $null
DisplayName = $null
SamAccountName = $null
Notes = $null
ManagedBy = $null
DistinguishedName = $null
Expand Down Expand Up @@ -162,6 +167,7 @@ try
$result.Path | Should -Be $mockADGroup.Path
$result.Description | Should -Be $mockADGroup.Description
$result.DisplayName | Should -Be $mockADGroup.DisplayName
$result.SamAccountName | Should -Be $mockADGroup.SamAccountName
$result.MembersToInclude | Should -BeNullOrEmpty
$result.MembersToExclude | Should -BeNullOrEmpty
$result.MembershipAttribute | Should -Be 'SamAccountName'
Expand Down Expand Up @@ -338,6 +344,7 @@ try
$result.Path | Should -BeNullOrEmpty
$result.Description | Should -BeNullOrEmpty
$result.DisplayName | Should -BeNullOrEmpty
$result.SamAccountName | Should -BeNullOrEmpty
$result.Members | Should -BeNullOrEmpty
$result.MembersToInclude | Should -BeNullOrEmpty
$result.MembersToExclude | Should -BeNullOrEmpty
Expand Down Expand Up @@ -369,6 +376,7 @@ try
Path = $mockADGroup.Path
Description = $mockADGroup.Description
DisplayName = $mockADGroup.DisplayName
SamAccountName = $mockADGroup.SamAccountName
ManagedBy = $mockADGroup.ManagedBy
Notes = $mockADGroup.Info
Members = $mockADGroup.Members
Expand Down Expand Up @@ -552,6 +560,7 @@ try
Path = $mockADGroup.Path
Description = $mockADGroup.Description
DisplayName = $mockADGroup.DisplayName
SamAccountName = $mockADGroup.SamAccountName
ManagedBy = $mockADGroup.ManagedBy
Notes = $mockADGroup.Info
Members = $mockADGroup.Members
Expand Down
20 changes: 20 additions & 0 deletions tests/Unit/Stubs/ActiveDirectory_2019.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -10812,6 +10812,16 @@ function New-ADGroup {
$parameter = New-Object System.Management.Automation.RuntimeDefinedParameter("DisplayName", [System.String], $attributes)
$parameters.Add("DisplayName", $parameter)

# SamAccountName
$attributes = New-Object System.Collections.Generic.List[Attribute]

$attribute = New-Object System.Management.Automation.ParameterAttribute
$attribute.ValueFromPipelineByPropertyName = $True
$attributes.Add($attribute)

$parameter = New-Object System.Management.Automation.RuntimeDefinedParameter("SamAccountName", [System.String], $attributes)
$parameters.Add("SamAccountName", $parameter)

# GroupCategory
$attributes = New-Object System.Collections.Generic.List[Attribute]

Expand Down Expand Up @@ -20251,6 +20261,16 @@ Set-ADGroup -Instance <ADGroup> [-WhatIf] [-Confirm] [-AuthType <ADAuthType>] [-
$parameter = New-Object System.Management.Automation.RuntimeDefinedParameter("DisplayName", [System.String], $attributes)
$parameters.Add("DisplayName", $parameter)

# SamAccountName
$attributes = New-Object System.Collections.Generic.List[Attribute]

$attribute = New-Object System.Management.Automation.ParameterAttribute
$attribute.ParameterSetName = "Identity"
$attributes.Add($attribute)

$parameter = New-Object System.Management.Automation.RuntimeDefinedParameter("SamAccountName", [System.String], $attributes)
$parameters.Add("SamAccountName", $parameter)

# GroupCategory
$attributes = New-Object System.Collections.Generic.List[Attribute]

Expand Down

0 comments on commit 47c730e

Please sign in to comment.