Skip to content

Commit

Permalink
ActiveDirectoryDsc: Fix PowerShell Script Formatting (#545)
Browse files Browse the repository at this point in the history
- ActiveDirectoryDsc
  - Fix PowerShell script file formatting and culture string alignment.
  - Add the `pipelineIndentationStyle` setting to the Visual Studio Code settings file.
  • Loading branch information
X-Guardian authored and johlju committed Jan 13, 2020
1 parent 4b2be8e commit 6734fa4
Show file tree
Hide file tree
Showing 44 changed files with 651 additions and 640 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"powershell.codeFormatting.whitespaceAroundOperator": true,
"powershell.codeFormatting.whitespaceAfterSeparator": true,
"powershell.codeFormatting.ignoreOneLineBlock": false,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline",
"powershell.codeFormatting.preset": "Custom",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
- Updated PowerShell help files.
- Updated Wiki link in README.md.
- Remove verbose parameters from unit tests.
- Fix PowerShell script file formatting and culture string alignment.
- Add the `pipelineIndentationStyle` setting to the Visual Studio Code settings file.

### Fixed

Expand Down
195 changes: 102 additions & 93 deletions Tests/Unit/ActiveDirectoryDsc.Common.Tests.ps1

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions Tests/Unit/MSFT_ADDomain.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ try
)

$mockDefaultParameters = @{
DomainName = $mockDomainName
Credential = $mockAdministratorCredential
DomainName = $mockDomainName
Credential = $mockAdministratorCredential
SafeModeAdministratorPassword = $mockAdministratorCredential
}

Expand Down Expand Up @@ -130,17 +130,17 @@ try
BeforeAll {
Mock -CommandName Get-ADDomain -MockWith {
[PSObject] @{
Forest = $mockDomainName
DomainMode = $mgmtDomainMode
Forest = $mockDomainName
DomainMode = $mgmtDomainMode
ParentDomain = $mockDomainName
NetBIOSName = $mockNetBiosName
DnsRoot = $mockDnsRoot
NetBIOSName = $mockNetBiosName
DnsRoot = $mockDnsRoot
}
}

Mock -CommandName Get-ADForest -MockWith {
[PSObject] @{
Name = $mockDomainName
Name = $mockDomainName
ForestMode = $mgmtForestMode
}
}
Expand Down Expand Up @@ -396,19 +396,19 @@ try
)

$mockDefaultParameters = @{
Credential = $mockAdministratorCredential
Credential = $mockAdministratorCredential
SafeModeAdministratorPassword = $mockAdministratorCredential
}

$stubDomain = @{
DnsRoot = $mockDomainName
DnsRoot = $mockDomainName
DomainNetBIOSName = $correctDomainNetBIOSName
}

# Get-TargetResource returns the domain FQDN for .DomainName
$stubChildDomain = @{
DnsRoot = "$correctChildDomainName.$parentDomainName"
ParentDomainName = $parentDomainName
DnsRoot = "$correctChildDomainName.$parentDomainName"
ParentDomainName = $parentDomainName
DomainNetBIOSName = $correctDomainNetBIOSName
}

Expand Down Expand Up @@ -487,26 +487,26 @@ try
)

$newForestParams = @{
DomainName = $testDomainName
Credential = $mockAdministratorCredential
DomainName = $testDomainName
Credential = $mockAdministratorCredential
SafeModeAdministratorPassword = $testSafemodeCredential
}

$newDomainParams = @{
DomainName = $testDomainName
ParentDomainName = $testParentDomainName
Credential = $mockAdministratorCredential
DomainName = $testDomainName
ParentDomainName = $testParentDomainName
Credential = $mockAdministratorCredential
SafeModeAdministratorPassword = $testSafemodeCredential
}

$stubTargetResource = @{
DomainName = $testDomainName
ParentDomainName = $testParentDomainName
DomainName = $testDomainName
ParentDomainName = $testParentDomainName
DomainNetBIOSName = $testDomainNetBIOSNameName
ForestName = $testParentDomainName
ForestMode = $testDomainForestMode
DomainMode = $testDomainForestMode
DomainExist = $false
ForestName = $testParentDomainName
ForestMode = $testDomainForestMode
DomainMode = $testDomainForestMode
DomainExist = $false
}

Mock -CommandName Get-TargetResource -MockWith { return $stubTargetResource }
Expand All @@ -517,7 +517,7 @@ try

Set-TargetResource @newForestParams

Assert-MockCalled -CommandName Install-ADDSForest -ParameterFilter { $DomainName -eq $testDomainName } -Scope It
Assert-MockCalled -CommandName Install-ADDSForest -ParameterFilter { $DomainName -eq $testDomainName } -Scope It
}

It 'Calls "Install-ADDSForest" with "SafeModeAdministratorPassword" when creating forest' {
Expand All @@ -533,15 +533,15 @@ try

Set-TargetResource @newForestParams -DnsDelegationCredential $testDelegationCredential

Assert-MockCalled -CommandName Install-ADDSForest -ParameterFilter { $DnsDelegationCredential -eq $testDelegationCredential } -Scope It
Assert-MockCalled -CommandName Install-ADDSForest -ParameterFilter { $DnsDelegationCredential -eq $testDelegationCredential } -Scope It
}

It 'Calls "Install-ADDSForest" with "CreateDnsDelegation" when creating forest, if specified' {
Mock -CommandName Install-ADDSForest -ParameterFilter { $CreateDnsDelegation -eq $true }

Set-TargetResource @newForestParams -DnsDelegationCredential $testDelegationCredential

Assert-MockCalled -CommandName Install-ADDSForest -ParameterFilter { $CreateDnsDelegation -eq $true } -Scope It
Assert-MockCalled -CommandName Install-ADDSForest -ParameterFilter { $CreateDnsDelegation -eq $true } -Scope It
}

It 'Calls "Install-ADDSForest" with "DatabasePath" when creating forest, if specified' {
Expand Down Expand Up @@ -602,23 +602,23 @@ try

Set-TargetResource @newDomainParams

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $NewDomainName -eq $testDomainName } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $NewDomainName -eq $testDomainName } -Scope It
}

It 'Calls "Install-ADDSDomain" with "ParentDomainName" when creating child domain' {
Mock -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName }

Set-TargetResource @newDomainParams

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName } -Scope It
}

It 'Calls "Install-ADDSDomain" with "DomainType" when creating child domain' {
Mock -CommandName Install-ADDSDomain -ParameterFilter { $DomainType -eq 'ChildDomain' }

Set-TargetResource @newDomainParams

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $DomainType -eq 'ChildDomain' } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $DomainType -eq 'ChildDomain' } -Scope It
}

It 'Calls "Install-ADDSDomain" with "SafeModeAdministratorPassword" when creating child domain' {
Expand All @@ -634,31 +634,31 @@ try

Set-TargetResource @newDomainParams

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName } -Scope It
}

It 'Calls "Install-ADDSDomain" with "ParentDomainName" when creating child domain' {
Mock -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName }

Set-TargetResource @newDomainParams

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $ParentDomainName -eq $testParentDomainName } -Scope It
}

It 'Calls "Install-ADDSDomain" with "DnsDelegationCredential" when creating child domain, if specified' {
Mock -CommandName Install-ADDSDomain -ParameterFilter { $DnsDelegationCredential -eq $testDelegationCredential }

Set-TargetResource @newDomainParams -DnsDelegationCredential $testDelegationCredential

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $DnsDelegationCredential -eq $testDelegationCredential } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $DnsDelegationCredential -eq $testDelegationCredential } -Scope It
}

It 'Calls "Install-ADDSDomain" with "CreateDnsDelegation" when creating child domain, if specified' {
Mock -CommandName Install-ADDSDomain -ParameterFilter { $CreateDnsDelegation -eq $true }

Set-TargetResource @newDomainParams -DnsDelegationCredential $testDelegationCredential

Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $CreateDnsDelegation -eq $true } -Scope It
Assert-MockCalled -CommandName Install-ADDSDomain -ParameterFilter { $CreateDnsDelegation -eq $true } -Scope It
}

It 'Calls "Install-ADDSDomain" with "DatabasePath" when creating child domain, if specified' {
Expand Down
Loading

0 comments on commit 6734fa4

Please sign in to comment.