Skip to content

Rename RunUnitTests.ps1 RunPesterTests.ps1 to align with their purpose and Keep copy of ModifiedProviderSettingsExport to reference during development#1994

Open
tkol2022 wants to merge 5 commits intomainfrom
1989-rununittests-runpestertests-ambiguous-script-names
Open

Rename RunUnitTests.ps1 RunPesterTests.ps1 to align with their purpose and Keep copy of ModifiedProviderSettingsExport to reference during development#1994
tkol2022 wants to merge 5 commits intomainfrom
1989-rununittests-runpestertests-ambiguous-script-names

Conversation

@tkol2022
Copy link
Collaborator

@tkol2022 tkol2022 commented Feb 17, 2026

🗣 Description

Under the Better Coding Act of 2026 I chartered a quick mini-task to improve the names of the scripts RunUnitTests.ps1 and RunPesterTests.ps1. These scripts are now dubbed RunRegoUnitTests.ps1 and RunPowerShellUnitTests.ps1 so that developers have a better clue on what they are for. I also deleted a phantom script RunFunctionalTests.ps1 since nobody uses it. I moved RunPowerShellUnitTests.ps1 into the ./Testing folder since that script is meant for developer use and it makes sense to put developer scripts in a standard folder instead of deep inside the ScubaGear folder tree.

Closes #1989

Added 2/27/2026
Under the Scope Creep Renewal Act of 2026 I decided to add an important fix to the Products.Tests.ps1 file used by the functional test orchestrator whenever scenarios invoke the ScubaCached test type. This particular functional test type is used extensively by the Entra Id test plan and in smaller quantities in the Defender, EXO and PowerPlatform test plans.
The ScubaCached orchestration code had a defect where it deletes the ModifiedProviderSettingsExport file and this prevents a developer from seeing the file that a specific test scenario creates when developing test scenarios. To rectify this I added code that saves a copy of the ModifiedProviderSettingsExport file created by each test scenario right before the file gets deleted.

image

💭 Motivation and context

Under BCA2026 developers want to spend less time trying to figure out what a specific script is used for, particularly when the script is helpful and commonly used for unit testing their changes.

🧪 Testing Instructions

Use the sample code below to ensure that the scripts work. Execute these from the root ScubaGear folder.

.\Testing\RunRegoUnitTests.ps1 -p aad

.\Testing\RunPowerShellUnitTests.ps1

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • PR targets the correct parent branch (e.g., main or release-name) for merge.
  • Changes are limited to a single goal - eschew scope creep!
  • Changes are sized such that they do not touch excessive number of files.
  • All future TODOs are captured in issues, which are referenced in code comments.
  • These code changes follow the ScubaGear content style guide.
  • Related issues these changes resolve are linked preferably via closing keywords.
  • All relevant type-of-change labels added.
  • All relevant project fields are set.
  • All relevant repo and/or project documentation updated to reflect these changes.
  • Unit tests added/updated to cover PowerShell and Rego changes.
  • Functional tests added/updated to cover PowerShell and Rego changes.
  • All relevant functional tests passed.
  • All automated checks (e.g., linting, static analysis, unit/smoke tests) passed.

✅ Pre-merge checklist

  • PR passed smoke test check.

  • Feature branch has been rebased against changes from parent branch, as needed

    Use Rebase branch button below or use this reference to rebase from the command line.

  • Resolved all merge conflicts on branch

  • Notified merge coordinator that PR is ready for merge via comment mention

  • Demonstrate changes to the team for questions and comments.
    (Note: Only required for issues of size Medium or larger)

✅ Post-merge checklist

  • Feature branch deleted after merge to clean up repository.
  • Verified that all checks pass on parent branch (e.g., main or release-name) after merge.

@tkol2022 tkol2022 linked an issue Feb 17, 2026 that may be closed by this pull request
5 tasks
@tkol2022 tkol2022 self-assigned this Feb 17, 2026
@tkol2022 tkol2022 added the enhancement This issue or pull request will add new or improve existing functionality label Feb 17, 2026
@tkol2022 tkol2022 added this to the Plankton milestone Feb 17, 2026
Copy link
Collaborator

@dagarwal-ecs dagarwal-ecs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very small update, besides that it looks good

@FollyBeachGurl FollyBeachGurl requested review from DickTracyII and removed request for buidav February 24, 2026 19:46
Copy link
Collaborator

@dagarwal-ecs dagarwal-ecs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my end

@DickTracyII
Copy link
Collaborator

DickTracyII commented Feb 24, 2026

When I ran the .\RunPowerShellUnitTests.ps1. I got some failures. but I am sure this in not related to renaming of the script

image

tkol2022 and others added 4 commits February 25, 2026 10:16
…sterTests.ps1 to /PowerShell/ScubaGear/Testing/Unit/PowerShell/RunPowerShellUnitTests.ps1
…er. also remoed legacy unused script RunFunctionalTests.ps1
@tkol2022 tkol2022 force-pushed the 1989-rununittests-runpestertests-ambiguous-script-names branch from 81f719d to e020bca Compare February 25, 2026 15:16
Copy link
Collaborator

@DickTracyII DickTracyII left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ran through both scripts. I like the new names

@tkol2022 tkol2022 changed the title Rename RunUnitTests.ps1 and RunPesterTests.ps1 to help developers understand the purpose of the scripts Rename RunUnitTests.ps1 RunPesterTests.ps1 to align with their purpose and Keep copy of ModifiedProviderSettingsExport to reference during development Feb 27, 2026
@tkol2022
Copy link
Collaborator Author

@DickTracyII @dagarwal-ecs I am about to push the added enhancement to the functional test orchestrator and update the PR with new test instructions. I will do an official request for re-review when I finish.

…ifiedProviderSettingsExport.json so developers can reference it when creating functional test scenarios
@tkol2022
Copy link
Collaborator Author

Testing instructions for the enhancement that keeps a copy of ModifiedProviderSettingsExport.json

image
  • Once Pester finishes running the filtered test scenarios, make sure they Pass at the end of the Pester run. Then go to the output folder and sort the files by name. You should see multiple copies of ModifiedProviderSettingsExport.json with unique file names.
image
  • Ensure there are no unexpected errors during this process.

Examine the output of a single test scenario and verify that you can see the changes in the saved copy of the ModifiedProviderSettingsExport file.

  • Execute the functional tests but filter for the policy MS.AAD.3.3v2.
image
  • Go to the output folder and sort by file name. Open the copied ModifiedProviderSettingsExport json file that is first in the list.
image
  • Go to the authentication_method_feature_settings section in the JSON file and find the configuration for Id: MicrosoftAuthenticator.

  • Verify that MicrosoftAuthenticator is disabled.

image

This proves that the orchestrator saved a copy of the configuration created by the first test scenario "MS.AAD.3.3v2 Not-applicable case - MS Auth Disabled"

image

Expand to try out more test cases.

image
  • Try some of the test cases from Defender, EXO, PowerPlatform, SharePoint but Filter for the test scenarios that use ScubaCached in those test plans.
image

Final boss test

image

@tkol2022
Copy link
Collaborator Author

@DickTracyII @dagarwal-ecs I added a description of the new scope at the top of the issue to save you time looking at file diffs and I added custom test instructions to make your life easier. Feel free to do any tests outside of what I put there and I welcome any questions about the code or design. Thanks for your flexibility. Go for it.

@DickTracyII
Copy link
Collaborator

@tkol2022 I ran the functional tests like you stated except I include all AAD policies. I did get alot of runtime exceptions...not sure why but it did produce several MOdifiedProviderSettingsExport json files.

I'll run more tests next week.

image

@tkol2022
Copy link
Collaborator Author

tkol2022 commented Mar 9, 2026

@tkol2022 I ran the functional tests like you stated except I include all AAD policies. I did get alot of runtime exceptions...not sure why but it did produce several MOdifiedProviderSettingsExport json files.

I'll run more tests next week.

image

Thanks! Looks like the errors are on GCCHigh? Which specific test scenarios are failing so I can reproduce?

Did you get any errors on GCC, E5 or G3?

@dagarwal-ecs Did you get any errors?

@DickTracyII
Copy link
Collaborator

Yes the errors were on gcchigh but I think it was due to my PesterContianer configuration. I didn't receive the errors on any of the tenant after i rebuild my configurations; I had ``TenantDomainasTenantId`. I also specified `gcch` and not `gcchigh`

Copy link
Collaborator

@DickTracyII DickTracyII left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything tested out fine for GCCHIGH, G3, E5 and functional tests passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This issue or pull request will add new or improve existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RunUnitTests.ps1 and RunPesterTests.ps1 are ambiguous script names

3 participants