Functions/Convert-ActiveDirectoryUserToMSPCompleteUser.Tests.ps1
describe "BitTitan.Runbooks.ActiveDirectory/Convert-ActiveDirectoryUserToMSPCompleteUser" -Tag "module", "unit" { # Import the function to test . "$($PSScriptRoot)\Convert-ActiveDirectoryUserToMSPCompleteUser.ps1" it "converts an Active Directory user to a MSPComplete user" { # Declare the task inputs $activeDirectoryUser = [PSCustomObject]@{ givenName = "givenName" sn = "sn" displayName = "displayName" name = "name" mail = "mail" UserPrincipalName = "userPrincipalName" streetAddress = "streetAddress" l = "l" st = "st" postalCode = "postalCode" co = "co" mobile = "mobile" telephoneNumber = "telephoneNumber" company = "company" department = "department" title = "title" Fax = "fax" Office = "office" SID = "sid" } # Call the function $output = Convert-ActiveDirectoryUserToMSPCompleteUser -User $activeDirectoryUser # Verify the output $output.FirstName | Should Be "givenName" $output.LastName | Should Be "sn" $output.DisplayName | Should Be "displayName" $output.FullName | Should Be "name" $output.PrimaryEmailAddress | Should Be "mail" $output.UserPrincipalName | Should Be "userPrincipalName" $output.ExtendedProperties.AddressLine1 | Should Be "streetAddress" $output.ExtendedProperties.City | Should Be "l" $output.ExtendedProperties.StateOrProvince | Should Be "st" $output.ExtendedProperties.PostalOrZipCode | Should Be "postalCode" $output.ExtendedProperties.CountryOrRegion | Should Be "co" $output.ExtendedProperties.MobilePhoneNumber | Should Be "mobile" $output.ExtendedProperties.TelephoneNumber | Should Be "telephoneNumber" $output.ExtendedProperties.CompanyName | Should Be "company" $output.ExtendedProperties.Department | Should Be "department" $output.ExtendedProperties.JobTitle | Should Be "title" $output.ExtendedProperties.Fax | Should Be "fax" $output.ExtendedProperties.Office | Should Be "office" $output.ExtendedProperties.OnPremisesSecurityIdentifier | Should Be "sid" } it "converts an Active Directory user to a MSPComplete user and uses the UserPrincipalName property as the PrimaryEmailAddress property" { # Declare the task inputs $activeDirectoryUser = [PSCustomObject]@{ givenName = "givenName" sn = "sn" displayName = "displayName" name = "name" UserPrincipalName = "userPrincipalName" streetAddress = "streetAddress" l = "l" st = "st" postalCode = "postalCode" co = "co" mobile = "mobile" telephoneNumber = "telephoneNumber" company = "company" department = "department" title = "title" Fax = "fax" Office = "office" SID = "sid" } # Call the function $output = Convert-ActiveDirectoryUserToMSPCompleteUser -User $activeDirectoryUser # Verify the output $output.FirstName | Should Be "givenName" $output.LastName | Should Be "sn" $output.DisplayName | Should Be "displayName" $output.FullName | Should Be "name" $output.PrimaryEmailAddress | Should Be "userPrincipalName" $output.UserPrincipalName | Should Be "userPrincipalName" $output.ExtendedProperties.AddressLine1 | Should Be "streetAddress" $output.ExtendedProperties.City | Should Be "l" $output.ExtendedProperties.StateOrProvince | Should Be "st" $output.ExtendedProperties.PostalOrZipCode | Should Be "postalCode" $output.ExtendedProperties.CountryOrRegion | Should Be "co" $output.ExtendedProperties.MobilePhoneNumber | Should Be "mobile" $output.ExtendedProperties.TelephoneNumber | Should Be "telephoneNumber" $output.ExtendedProperties.CompanyName | Should Be "company" $output.ExtendedProperties.Department | Should Be "department" $output.ExtendedProperties.JobTitle | Should Be "title" $output.ExtendedProperties.Fax | Should Be "fax" $output.ExtendedProperties.Office | Should Be "office" $output.ExtendedProperties.OnPremisesSecurityIdentifier | Should Be "sid" } } |