Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/Invoke-MessageTraceReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
Version : 1.1.0
Exit codes : 0 = success, 1 = failure, 2 = finished but incomplete (see the summary).
Documentation : docs\MessageTraceReport-Guide.md (or .html)

Disclaimer:
This Script is a Personal project.
It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft.

As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production.
#>
[CmdletBinding()]
param(
Expand Down
7 changes: 7 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ notepad .\config\MessageTraceReport.config.psd1 # TenantId, AppId, Certif
Project page, releases and change log: https://github.com/Nico77600/MessageTraceReport

License: [MIT](LICENSE). Third-party components: [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).

## Disclaimer

This Script is a Personal project.
It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft.

As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production.
36 changes: 36 additions & 0 deletions tests/MessageTraceReport.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,42 @@ AfterAll {
Remove-Item -LiteralPath $script:Work -Recurse -Force -ErrorAction SilentlyContinue
}

Describe 'Runtime disclaimer' {
BeforeAll {
$script:DisclaimerRepo = Split-Path $PSScriptRoot -Parent
$script:DisclaimerConfig = Get-Content (Join-Path $script:DisclaimerRepo '.github\ci.json') -Raw | ConvertFrom-Json
$script:DisclaimerRuntime = Join-Path $script:DisclaimerRepo $script:DisclaimerConfig.runtimeRoot
$script:DisclaimerPattern = '(?ms)^## Disclaimer[ \t]*\r?\n(?<Body>.*?)(?=^##[ \t]|\z)'
$rootReadme = [IO.File]::ReadAllText((Join-Path $script:DisclaimerRepo 'README.md'))
$matches = [regex]::Matches($rootReadme, $script:DisclaimerPattern)
if ($matches.Count -ne 1) { throw 'The root README must contain exactly one canonical disclaimer.' }
$script:CanonicalDisclaimer = $matches[0].Groups['Body'].Value.Trim().Replace("`r`n", "`n")
function ConvertTo-DisclaimerParagraphs([string]$Text) {
(($Text.Trim() -split '\r?\n[ \t]*\r?\n') | ForEach-Object { ($_ -replace '\s+', ' ').Trim() }) -join "`n`n"
}
}

It 'keeps the runtime README disclaimer identical to the canonical root section' {
$readme = [IO.File]::ReadAllText((Join-Path $script:DisclaimerRuntime 'README.md'))
$matches = [regex]::Matches($readme, $script:DisclaimerPattern)
$matches.Count | Should -Be 1
$matches[0].Groups['Body'].Value.Trim().Replace("`r`n", "`n") | Should -BeExactly $script:CanonicalDisclaimer
}

It 'keeps the public entry script disclaimer attached to its help with the same wording and paragraphs' {
$path = Join-Path $script:DisclaimerRuntime $script:DisclaimerConfig.packageEntry
$errors = $null
$ast = [Management.Automation.Language.Parser]::ParseFile($path, [ref]$null, [ref]$errors)
@($errors).Count | Should -Be 0
$help = $ast.GetHelpContent()
$help | Should -Not -BeNullOrEmpty
$notes = $help.Notes
[regex]::Matches($notes, '(?m)^[ \t]*Disclaimer:[ \t]*$').Count | Should -Be 1
$body = [regex]::Match($notes, '(?s)(?:^|\r?\n)[ \t]*Disclaimer:[ \t]*\r?\n(?<Body>.*)\z').Groups['Body'].Value
(ConvertTo-DisclaimerParagraphs $body) | Should -BeExactly (ConvertTo-DisclaimerParagraphs $script:CanonicalDisclaimer)
}
}

Describe 'Configuration' {
It 'reports every missing value of the delivered configuration at once' {
$path = Join-Path $script:Root 'config\MessageTraceReport.config.psd1'
Expand Down
Loading