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
11 changes: 11 additions & 0 deletions package/Invoke-MailboxMessageReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
36 changes: 36 additions & 0 deletions tests/MailboxMessageReport.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(?<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 and request' {
It 'reads the delivered configuration and resolves the paths from the tool folder' {
$c = Import-MmrConfiguration
Expand Down
Loading