Skip to content

Commit

Permalink
Merge pull request #4864 from NikCharlebois/Example-Revamp
Browse files Browse the repository at this point in the history
Example revamp
  • Loading branch information
NikCharlebois authored Jul 11, 2024
2 parents fa813e6 + 13bdcc5 commit 07ecd4e
Show file tree
Hide file tree
Showing 93 changed files with 1,345 additions and 644 deletions.
172 changes: 1 addition & 171 deletions .github/workflows/Global - Integration - AAD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Install Microsoft365DSC
- name: Copy Microsoft365DSC
shell: powershell
run: |
winrm quickconfig -force
$source = "./Modules/Microsoft365DSC/"
$destination = "C:\Program Files\WindowsPowerShell\Modules"
Copy-Item -Path $source -Recurse -Destination $destination -Container -Force
Update-M365DSCDependencies
- name: Configure Environment
shell: powershell
run: |
Set-ExecutionPolicy Unrestricted -Force
Get-ChildItem "C:\Program Files\WindowsPowerShell\Modules" -Recurse | Unblock-File
Set-M365DSCTelemetryOption -Enabled $false
Set-Item -Path WSMan:\localhost\MaxEnvelopeSizekb -Value 99999
- name: Generate {Create} Integration Tests from Examples
shell: powershell
run: |
Expand All @@ -46,66 +43,9 @@ jobs:
git push
$SHA = git rev-parse HEAD
echo "commitid=$SHA" >> $env:GITHUB_OUTPUT
- name: Run {Create} Integration Tests
shell: powershell
env:
INTEGRATION_USERNAME: ${{ secrets.INTEGRATION_USERNAME }}
INTEGRATION_PASSWORD: ${{ secrets.INTEGRATION_PASSWORD }}
run: |
$CredPassword = ConvertTo-SecureString $env:INTEGRATION_PASSWORD -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($env:INTEGRATION_USERNAME, $CredPassword)
try
{
& .\Tests\Integration\Microsoft365DSC\M365DSCIntegration.AAD.Create.Tests.ps1 -Credential $Credential
}
catch
{
throw $_
}
- name: Validating {Create} Integration Tests
shell: powershell
run: |
try
{
$Result = Test-DSCConfiguration -Detailed -Verbose -ErrorAction Stop
}
catch
{
throw $_
}
Write-Host ""
if ($Result.InDesiredState -eq $false)
{
Write-Host -Message "Resources below are not in the Desired State:"
foreach ($Resource in $Result.ResourcesNotInDesiredState)
{
Write-Host $Resource.InstanceName
}
throw "Could not validate that the Tenant is in the Desired State"
}
else
{
Write-Host "All resources in the Tenant are in the Desired State"
}
try
{
# Commenting out since this is very finnicky right now and its preventing other tests from running.
# The Get-DSCConfiguration cmdlet isn't providing much value added when failing and doesn't provide
# info about what parsing issues occured.
#$Result = Get-DSCConfiguration -Verbose -ErrorAction Stop
}
catch
{
throw $_
}
- name: Generate {Update} Integration Tests from Examples
shell: powershell
run: |
Import-Module './Tests/Integration/M365DSCTestEngine.psm1'
New-M365DSCIntegrationTest -Workload AAD -Step '2-Update'
- name: Commit {Update} Integration Tests
shell: powershell
Expand All @@ -118,66 +58,9 @@ jobs:
git push
$SHA = git rev-parse HEAD
echo "commitid=$SHA" >> $env:GITHUB_OUTPUT
- name: Run {Update} Integration Tests
shell: powershell
env:
INTEGRATION_USERNAME: ${{ secrets.INTEGRATION_USERNAME }}
INTEGRATION_PASSWORD: ${{ secrets.INTEGRATION_PASSWORD }}
run: |
$CredPassword = ConvertTo-SecureString $env:INTEGRATION_PASSWORD -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($env:INTEGRATION_USERNAME, $CredPassword)
try
{
& .\Tests\Integration\Microsoft365DSC\M365DSCIntegration.AAD.Update.Tests.ps1 -Credential $Credential
}
catch
{
throw $_
}
- name: Validating {Update} Integration Tests
shell: powershell
run: |
try
{
$Result = Test-DSCConfiguration -Detailed -Verbose -ErrorAction Stop
}
catch
{
throw $_
}
Write-Host ""
if ($Result.InDesiredState -eq $false)
{
Write-Host -Message "Resources below are not in the Desired State:"
foreach ($Resource in $Result.ResourcesNotInDesiredState)
{
Write-Host $Resource.InstanceName
}
throw "Could not validate that the Tenant is in the Desired State"
}
else
{
Write-Host "All resources in the Tenant are in the Desired State"
}
try
{
# Commenting out since this is very finnicky right now and its preventing other tests from running.
# The Get-DSCConfiguration cmdlet isn't providing much value added when failing and doesn't provide
# info about what parsing issues occured.
#$Result = Get-DSCConfiguration -Verbose -ErrorAction Stop
}
catch
{
throw $_
}
- name: Generate {Remove} Integration Tests from Examples
shell: powershell
run: |
Import-Module './Tests/Integration/M365DSCTestEngine.psm1'
New-M365DSCIntegrationTest -Workload AAD -Step '3-Remove'
- name: Commit {Remove} Integration Tests
shell: powershell
Expand All @@ -190,56 +73,3 @@ jobs:
git push
$SHA = git rev-parse HEAD
echo "commitid=$SHA" >> $env:GITHUB_OUTPUT
- name: Run {Remove} Integration Tests
shell: powershell
env:
INTEGRATION_USERNAME: ${{ secrets.INTEGRATION_USERNAME }}
INTEGRATION_PASSWORD: ${{ secrets.INTEGRATION_PASSWORD }}
run: |
$CredPassword = ConvertTo-SecureString $env:INTEGRATION_PASSWORD -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($env:INTEGRATION_USERNAME, $CredPassword)
try
{
& .\Tests\Integration\Microsoft365DSC\M365DSCIntegration.AAD.Remove.Tests.ps1 -Credential $Credential
}
catch
{
throw $_
}
- name: Validating {Remove} Integration Tests
shell: powershell
run: |
try
{
$Result = Test-DSCConfiguration -Detailed -Verbose -ErrorAction Stop
}
catch
{
throw $_
}
Write-Host ""
if ($Result.InDesiredState -eq $false)
{
Write-Host -Message "Resources below are not in the Desired State:"
foreach ($Resource in $Result.ResourcesNotInDesiredState)
{
Write-Host $Resource.InstanceName
}
throw "Could not validate that the Tenant is in the Desired State"
}
else
{
Write-Host "All resources in the Tenant are in the Desired State"
}
try
{
#$Result = Get-DSCConfiguration -Verbose -ErrorAction Stop
}
catch
{
throw $_
}
42 changes: 42 additions & 0 deletions .github/workflows/Scheduled - Generate Permission List.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Unit Tests
on: [push, pull_request]

jobs:
# This workflow contains a single job called "build"
UnitTests:
# The type of runner that the job will run on
runs-on: windows-latest

permissions: write-all

# Only when run from the main repo
if: github.repository == 'microsoft/Microsoft365DSC'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Dependencies
shell: pwsh
run: |
Import-Module './Modules/M365DSCUtil.psm1' -Force;
Update-M365DSCModule
- name: Get Permissions List
shell: pwsh
run: |
Import-Module './Tests/TestHarness.psm1' -Force;
$permissions = Get-M365DSCAllGraphPermissionsList
$permission - join ',' | Out-File '.\Tests\QA\Graph.PermissionList.txt'
- name: Commit Permissions List
shell: powershell
run: |
git config --local user.email "[email protected]"
git config --local user.name "NikCharlebois"
git add D:/a/Microsoft365DSC/Microsoft365DSC/Tests/QA/*
git pull
git commit -m "Updated Graph Permissions List"
git push
$SHA = git rev-parse HEAD
echo "commitid=$SHA" >> $env:GITHUB_OUTPUT
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ It is not meant to use as a production baseline.
Configuration Example
{
param(
[Parameter(Mandatory = $true)]
[PSCredential]
$Credscredential
[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint
)
Import-DscResource -ModuleName Microsoft365DSC

Expand All @@ -21,7 +29,9 @@ Configuration Example
DisplayName = "displayName-value";
Ensure = "Present";
Id = "000000-0000-0000-0000-000000000000";
Credential = $Credscredential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ It is not meant to use as a production baseline.

Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[PSCredential]
$Credscredential
param(
[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint
)

Import-DscResource -ModuleName Microsoft365DSC
Expand All @@ -34,7 +41,9 @@ Configuration Example
}
}
)
Credential = $Credscredential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ It is not meant to use as a production baseline.

Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[PSCredential]
$Credscredential
param(
[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint
)

Import-DscResource -ModuleName Microsoft365DSC
Expand All @@ -35,7 +42,9 @@ Configuration Example
}
}
)
Credential = $Credscredential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ It is not meant to use as a production baseline.

Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[PSCredential]
$Credscredential
param(
[Parameter()]
[System.String]
$ApplicationId,

[Parameter()]
[System.String]
$TenantId,

[Parameter()]
[System.String]
$CertificateThumbprint
)

Import-DscResource -ModuleName Microsoft365DSC
Expand All @@ -20,7 +27,9 @@ Configuration Example
{
DisplayName = 'Test-Unit'
Ensure = 'Absent'
Credential = $Credscredential
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
}
}
Loading

0 comments on commit 07ecd4e

Please sign in to comment.