Skip to content

Commit

Permalink
ADManagedServiceAccount: Test SamAccountName parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelicWizard committed May 20, 2021
1 parent 9eff9e2 commit 1fdea03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function Get-TargetResource
Path = Get-ADObjectParentDN -DN $adServiceAccount.DistinguishedName
Description = $adServiceAccount.Description
DisplayName = $adServiceAccount.DisplayName
SamAccountName = $SamAccountName
SamAccountName = $adServiceAccount.SamAccountName
DistinguishedName = $adServiceAccount.DistinguishedName
Enabled = $adServiceAccount.Enabled
KerberosEncryptionType = $adServiceAccount.KerberosEncryptionType -split (', ')
Expand Down
12 changes: 10 additions & 2 deletions tests/Unit/MSFT_ADManagedServiceAccount.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ try
DistinguishedName = "CN=TestSMSA,$mockDefaultMsaPath"
Description = 'Dummy StandAlone service account for unit testing'
DisplayName = 'TestSMSA'
SamAccountName = 'TestSMSA'
Enabled = $true
KerberosEncryptionType = 'RC4', 'AES128', 'AES256'
ManagedPasswordPrincipals = @()
Expand All @@ -87,6 +88,7 @@ try
DistinguishedName = $null
Description = $null
DisplayName = $null
SamAccountName = $null
Enabled = $false
ManagedPasswordPrincipals = @()
MembershipAttribute = $mockAdServiceAccountStandalone.MembershipAttribute
Expand All @@ -97,6 +99,7 @@ try
$mockAdServiceAccountChanged = @{
Description = 'Changed description'
DisplayName = 'Changed displayname'
SamAccountName = 'ChangedSMSA'
KerberosEncryptionType = 'AES128', 'AES256'
ManagedPasswordPrincipals = $mockADUSer.SamAccountName
}
Expand All @@ -107,6 +110,7 @@ try
DistinguishedName = "CN=TestGMSA,$mockDefaultMsaPath"
Description = 'Dummy group service account for unit testing'
DisplayName = 'TestGMSA'
SamAccountName = 'TestGMSA'
Enabled = $true
KerberosEncryptionType = 'RC4', 'AES128', 'AES256'
ManagedPasswordPrincipals = $mockADUSer.SamAccountName, $mockADComputer.SamAccountName
Expand All @@ -120,6 +124,7 @@ try
DistinguishedName = $null
Description = $null
DisplayName = $null
SamAccountName = $null
Enabled = $false
ManagedPasswordPrincipals = @()
MembershipAttribute = $mockAdServiceAccountGroup.MembershipAttribute
Expand All @@ -136,7 +141,7 @@ try
Name = $mockAdServiceAccountStandalone.ServiceAccountName
ObjectClass = 'msDS-ManagedServiceAccount'
ObjectGUID = '91bffe90-4c84-4026-b1fc-d03671ff56ad'
SamAccountName = $mockAdServiceAccountStandalone.ServiceAccountName
SamAccountName = $mockAdServiceAccountStandalone.SamAccountName
SID = 'S-1-5-21-1409167834-891301383-2860967316-1144'
UserPrincipalName = ''
}
Expand All @@ -151,7 +156,7 @@ try
ObjectClass = 'msDS-GroupManagedServiceAccount'
ObjectGUID = '91bffe90-4c84-4026-b1fc-d03671ff56ae'
PrincipalsAllowedToRetrieveManagedPassword = $mockAdServiceAccountGroup.ManagedPasswordPrincipals
SamAccountName = $mockAdServiceAccountGroup.ServiceAccountName
SamAccountName = $mockAdServiceAccountGroup.SamAccountName
SID = 'S-1-5-21-1409167834-891301383-2860967316-1145'
UserPrincipalName = ''
}
Expand All @@ -162,6 +167,7 @@ try
Path = $mockDefaultMsaPath
Description = $mockGetAdServiceAccountResultsStandAlone.Description
DisplayName = $mockGetAdServiceAccountResultsStandAlone.DisplayName
SamAccountName = $mockGetAdServiceAccountResultsStandAlone.SamAccountName
AccountType = 'Standalone'
Ensure = 'Present'
Enabled = $true
Expand All @@ -177,6 +183,7 @@ try
DistinguishedName = $mockGetAdServiceAccountResultsGroup.DistinguishedName
Path = $mockDefaultMsaPath
Description = $mockGetAdServiceAccountResultsGroup.Description
SamAccountName = $mockGetAdServiceAccountResultsStandAlone.SamAccountName
DisplayName = $mockGetAdServiceAccountResultsGroup.DisplayName
AccountType = 'Group'
Ensure = 'Present'
Expand All @@ -194,6 +201,7 @@ try
Path = $null
Description = $null
DisplayName = $null
SamAccountName = $null
AccountType = $null
Ensure = 'Absent'
Enabled = $false
Expand Down

0 comments on commit 1fdea03

Please sign in to comment.