# Generate WAF folder
$testFolderPaths=(Get-ChildItem -Filter 'e2e' -Directory -Recurse).FullName
foreach ($testFolderPath in $testFolderPaths) {
$wafFolderPath = Join-Path $testFolderPath 'waf-aligned'
if (-not (Test-Path $wafFolderPath)) {
# Duplicate 'max' test folder
$null = New-Item -Path $wafFolderPath -ItemType 'Directory' -Force
$maxFolderPath = Join-Path $testFolderPath 'max'
if (Test-Path $maxFolderPath) {
$null = Copy-Item -Path "$maxFolderPath/*" -Destination $wafFolderPath -Recurse
}
}
}
# Update serviceShort & metadata
$wafFolderPaths=(Get-ChildItem -Filter 'waf-aligned' -Directory -Recurse).FullName
foreach ($testFolderPath in $wafFolderPaths) {
$testContent = Get-Content (Join-Path $testFolderPath 'main.test.bicep') -Raw
$testContent = $testContent -replace "(param serviceShort string = '[a-zA-Z]+)max'", ("`$1{0}'" -f 'waf')
$testContent = $testContent -replace "metadata name = 'Using large parameter set'", "metadata name = 'WAF-aligned'"
$testContent = $testContent -replace "metadata description = 'This instance deploys the module with most of its features enabled.'", "metadata description = 'This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.'"
$null = Set-Content (Join-Path $testFolderPath 'main.test.bicep') -Value $testContent -Force -NoNewline
}