Skip to content

Commit

Permalink
Merge pull request #1239 from ykuijs/UpdatePester
Browse files Browse the repository at this point in the history
Update Pester tests to remove legacy syntax
  • Loading branch information
ykuijs authored Sep 28, 2020
2 parents f510b6d + 8cfa599 commit 7d1fe7f
Show file tree
Hide file tree
Showing 139 changed files with 35,519 additions and 33,079 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- SPTrustedIdentityTokenIssuer
- Property ClaimProviderName is never set

### Added

- SPProductUpdate
Expand All @@ -19,8 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
application

### Changed

- SharePointDsc
- Changed ModuleBuilder module to latest version
- Update Pester tests to remove legacy Pester syntax
- SPFarm
- Added support for specifying port number in the CentralAdministrationUrl parameter.
If CentralAdministrationPort is also specified both port numbers must match.
Expand Down Expand Up @@ -49,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed issue where code failed because the State database already existed
- SPTrustedIdentityTokenIssuer
- Run Get-SPClaimProvider only if property ClaimProviderName is omitted/null/empty
- Property ClaimProviderName is never set
- SPWeb
- Fixed issue with incorrect detection of SPWeb that has to be absent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ function Set-TargetResource

if ($Ensure -eq "Absent")
{
throw "This resource cannot undo InfoPath Forms Service Configuration changes. `
Please set Ensure to Present or omit the resource"
throw ("This resource cannot undo InfoPath Forms Service Configuration changes. " + `
"Please set Ensure to Present or omit the resource")
}

Invoke-SPDscCommand -Credential $InstallAccount `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function Set-TargetResource

if ($Ensure -eq "Absent")
{
throw "This resource cannot undo Security Token Service Configuration changes. `
Please set Ensure to Present or omit the resource"
throw ("This resource cannot undo Security Token Service Configuration changes. " + `
"Please set Ensure to Present or omit the resource")
}

Invoke-SPDscCommand -Credential $InstallAccount `
Expand Down
56 changes: 28 additions & 28 deletions tests/Integration/PreflightChecks/Preflight.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ $ErrorActionPreference = 'stop'
Set-StrictMode -Off

Describe -Tags @("Preflight") "SharePointDsc Integration Tests - Preflight Check" {

It "Includes all required service accounts" {
$Global:SPDscIntegrationCredPool.ContainsKey("Setup") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("Farm") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("WebApp") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("ServiceApp") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("SuperUser") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("SuperReader") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("Crawler") | Should Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("Setup") | Should -Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("Farm") | Should -Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("WebApp") | Should -Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("ServiceApp") | Should -Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("SuperUser") | Should -Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("SuperReader") | Should -Be $true
$Global:SPDscIntegrationCredPool.ContainsKey("Crawler") | Should -Be $true
}

it "is being run from a machine on the specified domain" {
$env:USERDOMAIN | Should Be $global:SPDscIntegrationGlobals.ActiveDirectory.NetbiosName
It "is being run from a machine on the specified domain" {
$env:USERDOMAIN | Should -Be $global:SPDscIntegrationGlobals.ActiveDirectory.NetbiosName
}

it "Has valid credentials for all service accounts" {
It "Has valid credentials for all service accounts" {
$failedCredentials = $false
$Global:SPDscIntegrationCredPool.Keys | ForEach-Object -Process {
$cred = $Global:SPDscIntegrationCredPool.$_
$username = $cred.username
$password = $cred.GetNetworkCredential().password
$domain = New-Object -TypeName System.DirectoryServices.DirectoryEntry("",$UserName,$Password)
$domain = New-Object -TypeName System.DirectoryServices.DirectoryEntry("", $UserName, $Password)
if ($domain.name -eq $null)
{
Write-Warning "Credential for $username is not valid"
$failedCredentials = $true
}
}
}
$failedCredentials | Should Be $false
$failedCredentials | Should -Be $false
}

it "Can connect to SQL server using the setup credential" {
It "Can connect to SQL server using the setup credential" {

{
Invoke-Command -Credential $Global:SPDscIntegrationCredPool.Setup -ComputerName . {
Expand All @@ -44,43 +44,43 @@ Describe -Tags @("Preflight") "SharePointDsc Integration Tests - Preflight Check
$SqlConnection.Open()
$SqlConnection.Close()
}
} | Should Not Throw
} | Should -Not -Throw
}

it "Has PowerShell 5 installed" {
($PSVersionTable.PSVersion.Major -ge 5) | Should Be $true
It "Has PowerShell 5 installed" {
($PSVersionTable.PSVersion.Major -ge 5) | Should -Be $true
}

it "Has the SharePoint prerequisites installed" {
It "Has the SharePoint prerequisites installed" {
Configuration PrereqTest {
param([PSCredential] $RunAs)
Import-DscResource -ModuleName SharePointDsc
node "localhost" {
SPInstallPrereqs PrereqCheck {
InstallerPath = (Join-Path $Global:SPDscIntegrationGlobals.SharePoint.BinaryPath "prerequisiteinstaller.exe")
Ensure = "Present"
OnlineMode = $true
InstallerPath = (Join-Path $Global:SPDscIntegrationGlobals.SharePoint.BinaryPath "prerequisiteinstaller.exe")
Ensure = "Present"
OnlineMode = $true
PsDscRunAsCredential = $RunAs
}
}
}
PrereqTest -ConfigurationData $global:SPDscIntegrationConfigData -RunAs $Global:SPDscIntegrationCredPool.Setup -OutputPath "TestDrive:\PrereqTest"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\PrereqTest\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\PrereqTest\localhost.mof").InDesiredState | Should -Be $true
}

it "Has SharePoint installed" {
It "Has SharePoint installed" {
Configuration InstallCheck {
Import-DscResource -ModuleName SharePointDsc
node "localhost" {
SPInstall InstallCheck {
BinaryDir = $Global:SPDscIntegrationGlobals.SharePoint.BinaryPath
Ensure = "Present"
ProductKey = "TestValueOnly"
BinaryDir = $Global:SPDscIntegrationGlobals.SharePoint.BinaryPath
Ensure = "Present"
ProductKey = "TestValueOnly"
PsDscRunAsCredential = $Global:SPDscIntegrationCredPool.Setup
}
}
}
InstallCheck -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\InstallCheck\"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\InstallCheck\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\InstallCheck\localhost.mof").InDesiredState | Should -Be $true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Describe -Tags @("ServiceApp") "SPAccessServiceApp - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

Expand All @@ -49,10 +49,10 @@ Describe -Tags @("ServiceApp") "SPAccessServiceApp - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

AfterEach {
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Force -Confirm:$false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Describe -Tags @("PostWebApp") "SPAlternateUrl - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

Expand All @@ -49,7 +49,7 @@ Describe -Tags @("PostWebApp") "SPAlternateUrl - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

Expand All @@ -70,7 +70,7 @@ Describe -Tags @("PostWebApp") "SPAlternateUrl - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Describe -Tags @("PostFarm") "SPAntivirusSettings - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

AfterEach {
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Force -Confirm:$false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Describe -Tags @("PostSite") "SPAppCatalog - Integration Tests" {
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

AfterEach {
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Force -Confirm:$false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Describe -Tags @("PreServiceApp") "SPAppManagementServiceApp - Integration Tests
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

Expand All @@ -49,7 +49,7 @@ Describe -Tags @("PreServiceApp") "SPAppManagementServiceApp - Integration Tests
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

Expand All @@ -70,10 +70,10 @@ Describe -Tags @("PreServiceApp") "SPAppManagementServiceApp - Integration Tests
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

AfterEach {
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Force -Confirm:$false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ Describe -Tags @("Farm") "SPCreateFarm - Integration Tests" {
Import-DscResource -ModuleName SharePointDsc
node "localhost" {
SPCreateFarm CreateLocalFarm {
FarmConfigDatabaseName = "SP_Config"
FarmConfigDatabaseName = "SP_Config"
AdminContentDatabaseName = "SP_AdminContent"
DatabaseServer = $env:COMPUTERNAME
FarmAccount = $Global:SPDscIntegrationCredPool.Farm
Passphrase = $Global:SPDscFarmPassphrase
PsDscRunAsCredential = $Global:SPDscIntegrationCredPool.Setup
DatabaseServer = $env:COMPUTERNAME
FarmAccount = $Global:SPDscIntegrationCredPool.Farm
Passphrase = $Global:SPDscFarmPassphrase
PsDscRunAsCredential = $Global:SPDscIntegrationCredPool.Setup
}
}
}
. $configName -ConfigurationData $global:SPDscIntegrationConfigData -OutputPath "TestDrive:\$configName"
Start-DscConfiguration -Wait -Force -Path "TestDrive:\$configName" -ComputerName "localhost"
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should be $true
(Test-DscConfiguration -ComputerName "localhost" -ReferenceConfiguration "TestDrive:\$configName\localhost.mof").InDesiredState | Should -Be $true
}
}

AfterEach {
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Force -Confirm:$false
}
Expand Down
Loading

0 comments on commit 7d1fe7f

Please sign in to comment.