diff --git a/package/Invoke-MailboxMessageReport.ps1 b/package/Invoke-MailboxMessageReport.ps1 index aa1d0ca..08b2320 100644 --- a/package/Invoke-MailboxMessageReport.ps1 +++ b/package/Invoke-MailboxMessageReport.ps1 @@ -104,7 +104,18 @@ Exit codes : 0 = completed, 1 = failed, 2 = finished with warnings (a mailbox or a folder not read...). Documentation : docs\MailboxMessageReport-UserGuide.html (user guide: prerequisites, everyday commands) and docs\MailboxMessageReport-Guide.html (developer guide); sources: docs\*.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. + + The archive is read through an ID that Microsoft Graph gives (a beta endpoint) and opens, but that its + documentation does not describe for the archive: test it in your environment before production use. + The reports contain personal data (addresses, subjects): store and share them accordingly. #> + #Requires -Version 7.4 [CmdletBinding()] param( diff --git a/package/README.md b/package/README.md index 06ea58f..46d00b4 100644 --- a/package/README.md +++ b/package/README.md @@ -52,3 +52,12 @@ notepad .\config\MailboxMessageReport.config.psd1 # tenant, application Project page, releases and change log: https://github.com/Nico77600/MailboxMessageReport License: [MIT](LICENSE). + +## 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. + +The archive is read through an ID that Microsoft Graph gives (a beta endpoint) and opens, but that its documentation does not describe for the archive: test it in your environment before production use. The reports contain personal data (addresses, subjects): store and share them accordingly. diff --git a/tests/MailboxMessageReport.Tests.ps1 b/tests/MailboxMessageReport.Tests.ps1 index c6fa5e9..a8f6e09 100644 --- a/tests/MailboxMessageReport.Tests.ps1 +++ b/tests/MailboxMessageReport.Tests.ps1 @@ -100,6 +100,42 @@ BeforeAll { } } +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(?.*?)(?=^##[ \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(?.*)\z').Groups['Body'].Value + (ConvertTo-DisclaimerParagraphs $body) | Should -BeExactly (ConvertTo-DisclaimerParagraphs $script:CanonicalDisclaimer) + } +} + Describe 'Configuration and request' { It 'reads the delivered configuration and resolves the paths from the tool folder' { $c = Import-MmrConfiguration