-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AdfsServerApplication: Add basic support for AdfsServerApplication (#74)
- Loading branch information
Showing
11 changed files
with
1,376 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<# | ||
.SYNOPSIS | ||
AdfsServerApplication DSC Resource Integration Test Configuration | ||
.NOTES | ||
The AdfsServerApplication resource has a dependency on an AdfsApplicationGroup resource | ||
#> | ||
|
||
#region HEADER | ||
# Integration Test Config Template Version: 1.2.1 | ||
#endregion | ||
|
||
$configFile = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, 'json') | ||
if (Test-Path -Path $configFile) | ||
{ | ||
$ConfigurationData = Get-Content -Path $configFile | ConvertFrom-Json | ||
} | ||
else | ||
{ | ||
$ConfigurationData = @{ | ||
AllNodes = @( | ||
@{ | ||
NodeName = 'localhost' | ||
CertificateFile = $env:DscPublicCertificatePath | ||
} | ||
) | ||
AdfsApplicationGroup = @{ | ||
Name = 'DscAppGroup1' | ||
Description = "This is the AppGroup1 Description" | ||
Ensure = 'Present' | ||
} | ||
AdfsServerApplication = @{ | ||
Name = 'DscServerApplication1' | ||
Description = 'This is the DscServerApplication1 Description' | ||
Identifier = '96ec073d-9200-4d74-aeb7-d5028d6efa4b' | ||
ADUserPrincipalName = 'CONTOSO\Svc.App1' | ||
RedirectUri = 'https://serverapp1.contoso.com' | ||
LogoutUri = 'https://serverapp1.contoso.com/logout' | ||
} | ||
} | ||
} | ||
|
||
Configuration MSFT_AdfsServerApplication_Init_Config | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Initialises the Integration test resources | ||
#> | ||
|
||
Import-DscResource -ModuleName 'AdfsDsc' | ||
|
||
node $AllNodes.NodeName | ||
{ | ||
AdfsApplicationGroup 'Integration_Test' | ||
{ | ||
Name = $ConfigurationData.AdfsApplicationGroup.Name | ||
Ensure = 'Absent' | ||
} | ||
} | ||
} | ||
|
||
Configuration MSFT_AdfsServerApplication_Config | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Manages an ADFS Application Group and AdfsServerApplication | ||
#> | ||
|
||
Import-DscResource -ModuleName 'AdfsDsc' | ||
|
||
node $AllNodes.NodeName | ||
{ | ||
AdfsApplicationGroup 'Integration_Test' | ||
{ | ||
Name = $ConfigurationData.AdfsApplicationGroup.Name | ||
Description = $ConfigurationData.AdfsApplicationGroup.Description | ||
} | ||
|
||
AdfsServerApplication 'Integration_Test' | ||
{ | ||
Name = $ConfigurationData.AdfsServerApplication.Name | ||
Description = $ConfigurationData.AdfsServerApplication.Description | ||
ApplicationGroupIdentifier = $ConfigurationData.AdfsApplicationGroup.Name | ||
Identifier = $ConfigurationData.AdfsServerApplication.Identifier | ||
ADUserPrincipalName = $ConfigurationData.AdfsServerApplication.ADUserPrincipalName | ||
RedirectUri = $ConfigurationData.AdfsServerApplication.RedirectUri | ||
LogoutUri = $ConfigurationData.AdfsServerApplication.LogoutUri | ||
} | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
Tests/Integration/MSFT_AdfsServerApplication.Integration.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<# | ||
.SYNOPSIS | ||
AdfsServerApplication DSC Resource Integration Tests | ||
.DESCRIPTION | ||
Verbose/Debug output can be set by running: | ||
Invoke-pester -Script @{Path='.\MSFT_AdfsServerApplication.Integration.Tests.ps1';Parameters=@{Verbose=$true;Debug=$true}} | ||
The AdfsServerApplication resource has a dependency on an AdfsApplicationGroup resource | ||
#> | ||
|
||
[CmdletBinding()] | ||
param() | ||
|
||
Set-StrictMode -Version 2.0 | ||
|
||
$script:dscModuleName = 'AdfsDsc' | ||
$script:dscResourceFriendlyName = 'AdfsServerApplication' | ||
$script:dscResourceName = "MSFT_$($script:dscResourceFriendlyName)" | ||
|
||
try | ||
{ | ||
Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' | ||
} | ||
catch [System.IO.FileNotFoundException] | ||
{ | ||
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' | ||
} | ||
|
||
$script:testEnvironment = Initialize-TestEnvironment ` | ||
-DSCModuleName $script:dscModuleName ` | ||
-DSCResourceName $script:dscResourceName ` | ||
-ResourceType 'Mof' ` | ||
-TestType 'Integration' | ||
|
||
try | ||
{ | ||
#region Integration Tests | ||
$configurationFile = Join-Path -Path $PSScriptRoot -ChildPath "$($script:dscResourceName).config.ps1" | ||
. $configurationFile | ||
|
||
Describe "$($script:dscResourceName)_Integration" { | ||
BeforeAll { | ||
$resourceId = "[$($script:dscResourceFriendlyName)]Integration_Test" | ||
} | ||
|
||
$startDscConfigurationParameters = @{ | ||
Path = $TestDrive | ||
ComputerName = 'localhost' | ||
Wait = $true | ||
Verbose = $true | ||
Force = $true | ||
Debug = $true | ||
ErrorAction = 'Stop' | ||
} | ||
|
||
$configurationName = "$($script:dscResourceName)_Init_Config" | ||
|
||
Context ('When using configuration {0}' -f $configurationName) { | ||
It 'Should compile and apply the MOF without throwing' { | ||
{ | ||
$configurationParameters = @{ | ||
OutputPath = $TestDrive | ||
ConfigurationData = $ConfigurationData | ||
} | ||
|
||
& $configurationName @configurationParameters | ||
|
||
Start-DscConfiguration @startDscConfigurationParameters | ||
} | Should -Not -Throw | ||
} | ||
|
||
It 'Should be able to call Get-DscConfiguration without throwing' { | ||
{ | ||
$script:currentConfiguration = Get-DscConfiguration -ErrorAction Stop | ||
} | Should -Not -Throw | ||
} | ||
|
||
It 'Should have ensured the resource is absent' { | ||
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { | ||
$_.ConfigurationName -eq $configurationName | ||
} | ||
$resourceCurrentState.Ensure | Should -Be 'Absent' | ||
} | ||
|
||
It 'Should return $true when Test-DscConfiguration is run' { | ||
Test-DscConfiguration | Should -Be 'True' | ||
} | ||
} | ||
|
||
$configurationName = "$($script:dscResourceName)_Config" | ||
|
||
Context ('When using configuration {0}' -f $configurationName) { | ||
It 'Should compile and apply the MOF without throwing' { | ||
{ | ||
$configurationParameters = @{ | ||
OutputPath = $TestDrive | ||
ConfigurationData = $ConfigurationData | ||
} | ||
|
||
& $configurationName @configurationParameters | ||
|
||
Start-DscConfiguration @startDscConfigurationParameters | ||
} | Should -Not -Throw | ||
} | ||
|
||
It 'Should be able to call Get-DscConfiguration without throwing' { | ||
{ | ||
$script:currentConfiguration = Get-DscConfiguration -ErrorAction Stop | ||
} | Should -Not -Throw | ||
} | ||
|
||
It 'Should have set the resource and all the parameters should match' { | ||
$resourceCurrentState = $script:currentConfiguration | Where-Object -FilterScript { | ||
$_.ConfigurationName -eq $configurationName ` | ||
-and $_.ResourceId -eq $resourceId | ||
} | ||
|
||
Foreach ($property in $ConfigurationData.AdfsServerApplication.Keys) | ||
{ | ||
$resourceCurrentState.$property | Should -Be $ConfigurationData.AdfsServerApplication.$property | ||
} | ||
} | ||
|
||
It 'Should return $true when Test-DscConfiguration is run' { | ||
Test-DscConfiguration | Should -Be 'True' | ||
} | ||
} | ||
} | ||
#endregion | ||
} | ||
finally | ||
{ | ||
Restore-TestEnvironment -TestEnvironment $script:testEnvironment | ||
} |
Oops, something went wrong.