forked from microsoft/Microsoft365DSC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AADOnPremisePublishingProfileConnectorGroup resource
- Loading branch information
Showing
9 changed files
with
1,144 additions
and
0 deletions.
There are no files selected for viewing
455 changes: 455 additions & 0 deletions
455
...ources/MSFT_AADConnectorGroupApplicationProxy/MSFT_AADConnectorGroupApplicationProxy.psm1
Large diffs are not rendered by default.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
.../MSFT_AADConnectorGroupApplicationProxy/MSFT_AADConnectorGroupApplicationProxy.schema.mof
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,16 @@ | ||
|
||
[ClassVersion("1.0.0.0"), FriendlyName("AADConnectorGroupApplicationProxy")] | ||
class MSFT_AADConnectorGroupApplicationProxy : OMI_BaseResource | ||
{ | ||
[Write, Description("The name associated with the connectorGroup.")] String Name; | ||
[Write, Description("The region the connectorGroup is assigned to and will optimize traffic for. This region can only be set if no connectors or applications are assigned to the connectorGroup. The possible values are: nam (for North America), eur (for Europe), aus (for Australia), asia (for Asia), ind (for India), and unknownFutureValue."), ValueMap{"nam","eur","aus","asia","ind","unknownFutureValue"}, Values{"nam","eur","aus","asia","ind","unknownFutureValue"}] String Region; | ||
[Key, Description("The unique identifier for an entity. Read-only.")] String Id; | ||
[Write, Description("Present ensures the policy exists, absent ensures it is removed."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure; | ||
[Write, Description("Credentials of the Admin"), EmbeddedInstance("MSFT_Credential")] string Credential; | ||
[Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId; | ||
[Write, Description("Id of the Azure Active Directory tenant used for authentication.")] String TenantId; | ||
[Write, Description("Secret of the Azure Active Directory tenant used for authentication."), EmbeddedInstance("MSFT_Credential")] String ApplicationSecret; | ||
[Write, Description("Thumbprint of the Azure Active Directory application's authentication certificate to use for authentication.")] String CertificateThumbprint; | ||
[Write, Description("Managed ID being used for authentication.")] Boolean ManagedIdentity; | ||
[Write, Description("Access token used for authentication.")] String AccessTokens[]; | ||
}; |
6 changes: 6 additions & 0 deletions
6
...s/Microsoft365DSC/DSCResources/MSFT_AADConnectorGroupApplicationProxy/readme.md
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,6 @@ | ||
|
||
# AADConnectorGroupApplicationProxy | ||
|
||
## Description | ||
|
||
Azure AD Connector Group Application Proxy |
33 changes: 33 additions & 0 deletions
33
Modules/Microsoft365DSC/DSCResources/MSFT_AADConnectorGroupApplicationProxy/settings.json
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,33 @@ | ||
{ | ||
"resourceName": "AADConnectorGroupApplicationProxy", | ||
"description": "This resource configures an Azure AD Connector Group Application Proxy.", | ||
"permissions": { | ||
"graph": { | ||
"delegated": { | ||
"read": [ | ||
{ | ||
"name": "Directory.ReadWrite.All" | ||
} | ||
], | ||
"update": [ | ||
{ | ||
"name": "Directory.ReadWrite.All" | ||
} | ||
] | ||
}, | ||
"application": { | ||
"read": [ | ||
{ | ||
"name": "Directory.ReadWrite.All" | ||
} | ||
], | ||
"update": [ | ||
{ | ||
"name": "Directory.ReadWrite.All" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
Modules/Microsoft365DSC/Examples/Resources/AADConnectorGroupApplicationProxy/1-Create.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,36 @@ | ||
<# | ||
This example is used to test new resources and showcase the usage of new resources being worked on. | ||
It is not meant to use as a production baseline. | ||
#> | ||
|
||
Configuration Example | ||
{ | ||
param( | ||
[Parameter()] | ||
[System.String] | ||
$ApplicationId, | ||
|
||
[Parameter()] | ||
[System.String] | ||
$TenantId, | ||
|
||
[Parameter()] | ||
[System.String] | ||
$CertificateThumbprint | ||
) | ||
Import-DscResource -ModuleName Microsoft365DSC | ||
|
||
node localhost | ||
{ | ||
AADConnectorGroupApplicationProxy "AADConnectorGroupApplicationProxy-testgroup" | ||
{ | ||
ApplicationId = $ApplicationId | ||
TenantId = $TenantId | ||
CertificateThumbprint = $CertificateThumbprint | ||
Ensure = "Present"; | ||
Id = "4984dcf7-d9e9-4663-90b4-5db09f92a669"; | ||
Name = "testgroup"; | ||
Region = "nam"; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Modules/Microsoft365DSC/Examples/Resources/AADConnectorGroupApplicationProxy/2-Update.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,35 @@ | ||
<# | ||
This example is used to test new resources and showcase the usage of new resources being worked on. | ||
It is not meant to use as a production baseline. | ||
#> | ||
|
||
Configuration Example | ||
{ | ||
param( | ||
[Parameter()] | ||
[System.String] | ||
$ApplicationId, | ||
|
||
[Parameter()] | ||
[System.String] | ||
$TenantId, | ||
|
||
[Parameter()] | ||
[System.String] | ||
$CertificateThumbprint | ||
) | ||
Import-DscResource -ModuleName Microsoft365DSC | ||
node localhost | ||
{ | ||
AADConnectorGroupApplicationProxy "AADConnectorGroupApplicationProxy-testgroup" | ||
{ | ||
ApplicationId = $ApplicationId | ||
TenantId = $TenantId | ||
CertificateThumbprint = $CertificateThumbprint | ||
Ensure = "Present"; | ||
Id = "4984dcf7-d9e9-4663-90b4-5db09f92a669"; | ||
Name = "testgroup-new"; | ||
Region = "nam"; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Modules/Microsoft365DSC/Examples/Resources/AADConnectorGroupApplicationProxy/3-Remove.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,34 @@ | ||
<# | ||
This example is used to test new resources and showcase the usage of new resources being worked on. | ||
It is not meant to use as a production baseline. | ||
#> | ||
|
||
Configuration Example | ||
{ | ||
param( | ||
[Parameter()] | ||
[System.String] | ||
$ApplicationId, | ||
|
||
[Parameter()] | ||
[System.String] | ||
$TenantId, | ||
|
||
[Parameter()] | ||
[System.String] | ||
$CertificateThumbprint | ||
) | ||
Import-DscResource -ModuleName Microsoft365DSC | ||
|
||
node localhost | ||
{ | ||
AADConnectorGroupApplicationProxy "AADConnectorGroupApplicationProxy-testgroup" | ||
{ | ||
ApplicationId = $ApplicationId | ||
TenantId = $TenantId | ||
CertificateThumbprint = $CertificateThumbprint | ||
Ensure = "Absent"; | ||
Id = "4984dcf7-d9e9-4663-90b4-5db09f92a669"; | ||
} | ||
} | ||
} |
198 changes: 198 additions & 0 deletions
198
Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADConnectorGroupApplicationProxy.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,198 @@ | ||
[CmdletBinding()] | ||
param( | ||
) | ||
$M365DSCTestFolder = Join-Path -Path $PSScriptRoot ` | ||
-ChildPath '..\..\Unit' ` | ||
-Resolve | ||
$CmdletModule = (Join-Path -Path $M365DSCTestFolder ` | ||
-ChildPath '\Stubs\Microsoft365.psm1' ` | ||
-Resolve) | ||
$GenericStubPath = (Join-Path -Path $M365DSCTestFolder ` | ||
-ChildPath '\Stubs\Generic.psm1' ` | ||
-Resolve) | ||
Import-Module -Name (Join-Path -Path $M365DSCTestFolder ` | ||
-ChildPath '\UnitTestHelper.psm1' ` | ||
-Resolve) | ||
|
||
$Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule ` | ||
-DscResource "AADConnectorGroupApplicationProxy" -GenericStubModule $GenericStubPath | ||
Describe -Name $Global:DscHelper.DescribeHeader -Fixture { | ||
InModuleScope -ModuleName $Global:DscHelper.ModuleName -ScriptBlock { | ||
Invoke-Command -ScriptBlock $Global:DscHelper.InitializeScript -NoNewScope | ||
BeforeAll { | ||
|
||
$secpasswd = ConvertTo-SecureString (New-Guid | Out-String) -AsPlainText -Force | ||
$Credential = New-Object System.Management.Automation.PSCredential ('[email protected]', $secpasswd) | ||
|
||
Mock -CommandName Confirm-M365DSCDependencies -MockWith { | ||
} | ||
|
||
Mock -CommandName Get-PSSession -MockWith { | ||
} | ||
|
||
Mock -CommandName Remove-PSSession -MockWith { | ||
} | ||
|
||
Mock -CommandName Update-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
} | ||
|
||
Mock -CommandName New-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
} | ||
|
||
Mock -CommandName Remove-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
} | ||
|
||
Mock -CommandName New-M365DSCConnection -MockWith { | ||
return "Credentials" | ||
} | ||
|
||
# Mock Write-Host to hide output during the tests | ||
Mock -CommandName Write-Host -MockWith { | ||
} | ||
$Script:exportedInstances =$null | ||
$Script:ExportMode = $false | ||
} | ||
# Test contexts | ||
Context -Name "The AADConnectorGroupApplicationProxy should exist but it DOES NOT" -Fixture { | ||
BeforeAll { | ||
$testParams = @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
Ensure = "Present" | ||
Credential = $Credential; | ||
} | ||
|
||
Mock -CommandName Get-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
return $null | ||
} | ||
} | ||
It 'Should return Values from the Get method' { | ||
(Get-TargetResource @testParams).Ensure | Should -Be 'Absent' | ||
} | ||
It 'Should return false from the Test method' { | ||
Test-TargetResource @testParams | Should -Be $false | ||
} | ||
It 'Should Create the group from the Set method' { | ||
Set-TargetResource @testParams | ||
Should -Invoke -CommandName New-MgBetaOnPremisePublishingProfileConnectorGroup -Exactly 1 | ||
} | ||
} | ||
|
||
Context -Name "The AADConnectorGroupApplicationProxy exists but it SHOULD NOT" -Fixture { | ||
BeforeAll { | ||
$testParams = @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
Ensure = "Absent" | ||
Credential = $Credential; | ||
} | ||
|
||
Mock -CommandName Get-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
return @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
} | ||
} | ||
} | ||
|
||
It 'Should return Values from the Get method' { | ||
(Get-TargetResource @testParams).Ensure | Should -Be 'Present' | ||
} | ||
|
||
It 'Should return true from the Test method' { | ||
Test-TargetResource @testParams | Should -Be $false | ||
} | ||
|
||
It 'Should Remove the group from the Set method' { | ||
Set-TargetResource @testParams | ||
Should -Invoke -CommandName Remove-MgBetaOnPremisePublishingProfileConnectorGroup -Exactly 1 | ||
} | ||
} | ||
Context -Name "The AADConnectorGroupApplicationProxy Exists and Values are already in the desired state" -Fixture { | ||
BeforeAll { | ||
$testParams = @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
Ensure = "Present" | ||
Credential = $Credential; | ||
} | ||
|
||
Mock -CommandName Get-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
return @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
It 'Should return true from the Test method' { | ||
Test-TargetResource @testParams | Should -Be $true | ||
} | ||
} | ||
|
||
Context -Name "The AADConnectorGroupApplicationProxy exists and values are NOT in the desired state" -Fixture { | ||
BeforeAll { | ||
$testParams = @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
Ensure = 'Present' | ||
Credential = $Credential; | ||
} | ||
|
||
Mock -CommandName Get-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
return @{ | ||
Id = "FakeStringValue" | ||
Name = "NewFakeStringValue" | ||
Region = "nam" | ||
} | ||
} | ||
} | ||
|
||
It 'Should return Values from the Get method' { | ||
(Get-TargetResource @testParams).Ensure | Should -Be 'Present' | ||
} | ||
|
||
It 'Should return false from the Test method' { | ||
Test-TargetResource @testParams | Should -Be $false | ||
} | ||
|
||
It 'Should call the Set method' { | ||
Set-TargetResource @testParams | ||
Should -Invoke -CommandName Update-MgBetaOnPremisePublishingProfileConnectorGroup -Exactly 1 | ||
} | ||
} | ||
|
||
Context -Name 'ReverseDSC Tests' -Fixture { | ||
BeforeAll { | ||
$Global:CurrentModeIsExport = $true | ||
$Global:PartialExportFileName = "$(New-Guid).partial.ps1" | ||
$testParams = @{ | ||
Credential = $Credential | ||
} | ||
|
||
Mock -CommandName Get-MgBetaOnPremisePublishingProfileConnectorGroup -MockWith { | ||
return @{ | ||
Id = "FakeStringValue" | ||
Name = "FakeStringValue" | ||
Region = "nam" | ||
|
||
} | ||
} | ||
} | ||
It 'Should Reverse Engineer resource from the Export method' { | ||
$result = Export-TargetResource @testParams | ||
$result | Should -Not -BeNullOrEmpty | ||
} | ||
} | ||
} | ||
} | ||
|
||
Invoke-Command -ScriptBlock $Global:DscHelper.CleanupScript -NoNewScope |
Oops, something went wrong.