Tests/Integration/MSFT_ADUser.config.ps1

#region HEADER
# Integration Test Config Template Version: 1.2.0
#endregion

$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, 'json')
if (Test-Path -Path $configFile)
{
    <#
        Allows reading the configuration data from a JSON file, for real testing
        scenarios outside of the CI.
    #>

    $ConfigurationData = Get-Content -Path $configFile | ConvertFrom-Json
}
else
{
    $currentDomain = Get-ADDomain
    $netBiosDomainName = $currentDomain.NetBIOSName
    $domainDistinguishedName = $currentDomain.DistinguishedName

    $ConfigurationData = @{
        AllNodes = @(
            @{
                NodeName                = 'localhost'
                CertificateFile         = $env:DscPublicCertificatePath

                DomainDistinguishedName = $domainDistinguishedName
                NetBIOSName             = $netBiosDomainName

                UserName1               = 'DscTestUser1'
                DisplayName1            = 'Dsc Test User 1'

                ThumbnailPhotoBase64 = '/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABgESAAMAAAABAAEAAAMBAAUAAAABAAAAVgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAOxFESAAQAAAABAAAOxAAAAAAAAYagAACxj//bAEMAAgEBAgEBAgICAgICAgIDBQMDAwMDBgQEAwUHBgcHBwYHBwgJCwkICAoIBwcKDQoKCwwMDAwHCQ4PDQwOCwwMDP/bAEMBAgICAwMDBgMDBgwIBwgMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDP/AABEIAGAAYAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExc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Y4oAxRRWJsf/9k='
                ThumbnailPhotoHash   = 'E3253C13DFF396BE98D6144F0DFA6105'
                ThumbnailPhotoPath   = Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\DSC_Logo_96.jpg'

                Password                = New-Object `
                    -TypeName System.Management.Automation.PSCredential `
                    -ArgumentList @(
                    'AnyName',
                    (ConvertTo-SecureString -String 'P@ssW0rd1' -AsPlainText -Force)
                )

                AdministratorUserName   = ('{0}\Administrator' -f $netBiosDomainName)
                AdministratorPassword   = 'P@ssw0rd1'
            }
        )
    }
}

<#
    .SYNOPSIS
        Removes a user account.
#>

Configuration MSFT_ADUser_CreateUser1_Config
{
    Import-DscResource -ModuleName 'ActiveDirectoryDsc'

    node $AllNodes.NodeName
    {
        ADUser 'Integration_Test'
        {
            # Using distinguished name for DomainName - Regression test for issue #451.
            DomainName           = $Node.DomainDistinguishedName
            UserName             = $Node.UserName1
            UserPrincipalName    = $Node.UserName1
            DisplayName          = $Node.DisplayName1
            PasswordNeverExpires = $true
            Password             = $Node.Password

            Credential           = New-Object `
                -TypeName System.Management.Automation.PSCredential `
                -ArgumentList @(
                $Node.AdministratorUserName,
                (ConvertTo-SecureString -String $Node.AdministratorPassword -AsPlainText -Force)
            )
        }
    }
}

<#
    .SYNOPSIS
        Updates the thumbnail photo on a user account from a Base64-encoded jpeg
        image.
#>

Configuration MSFT_ADUser_UpdateThumbnailPhotoUsingBase64_Config
{
    Import-DscResource -ModuleName 'ActiveDirectoryDsc'

    node $AllNodes.NodeName
    {
        ADUser 'Integration_Test'
        {
            DomainName     = $Node.DomainDistinguishedName
            UserName       = $Node.UserName1
            ThumbnailPhoto = $Node.ThumbnailPhotoBase64

            Credential     = New-Object `
                -TypeName System.Management.Automation.PSCredential `
                -ArgumentList @(
                $Node.AdministratorUserName,
                (ConvertTo-SecureString -String $Node.AdministratorPassword -AsPlainText -Force)
            )
        }
    }
}

<#
    .SYNOPSIS
        Updates the thumbnail photo on a user account from a Base64-encoded jpeg
        image.
#>

Configuration MSFT_ADUser_RemoveThumbnailPhoto_Config
{
    Import-DscResource -ModuleName 'ActiveDirectoryDsc'

    node $AllNodes.NodeName
    {
        ADUser 'Integration_Test'
        {
            DomainName     = $Node.DomainDistinguishedName
            UserName       = $Node.UserName1
            ThumbnailPhoto = ''

            Credential     = New-Object `
                -TypeName System.Management.Automation.PSCredential `
                -ArgumentList @(
                $Node.AdministratorUserName,
                (ConvertTo-SecureString -String $Node.AdministratorPassword -AsPlainText -Force)
            )
        }
    }
}

<#
    .SYNOPSIS
        Updates the thumbnail photo on a user account from a Base64-encoded jpeg
        file.
#>

Configuration MSFT_ADUser_UpdateThumbnailPhotoFromFile_Config
{
    Import-DscResource -ModuleName 'ActiveDirectoryDsc'

    node $AllNodes.NodeName
    {
        ADUser 'Integration_Test'
        {
            DomainName     = $Node.DomainDistinguishedName
            UserName       = $Node.UserName1
            ThumbnailPhoto = $Node.ThumbnailPhotoPath

            Credential     = New-Object `
                -TypeName System.Management.Automation.PSCredential `
                -ArgumentList @(
                $Node.AdministratorUserName,
                (ConvertTo-SecureString -String $Node.AdministratorPassword -AsPlainText -Force)
            )
        }
    }
}

<#
    .SYNOPSIS
        Creates a user account with a password that never expires.
#>

Configuration MSFT_ADUser_RemoveUser1_Config
{
    Import-DscResource -ModuleName 'ActiveDirectoryDsc'

    node $AllNodes.NodeName
    {
        ADUser 'Integration_Test'
        {
            Ensure     = 'Absent'
            DomainName = $Node.DomainDistinguishedName
            UserName   = $Node.UserName1

            Credential           = New-Object `
                -TypeName System.Management.Automation.PSCredential `
                -ArgumentList @(
                $Node.AdministratorUserName,
                (ConvertTo-SecureString -String $Node.AdministratorPassword -AsPlainText -Force)
            )
        }
    }
}