Skip to content

New-DbaFirewallRule - Adapt the tests to a default instance on the default port - #10605

Open
andreasjordan wants to merge 1 commit into
developmentfrom
fix-newdbafirewallrule-default-instance
Open

New-DbaFirewallRule - Adapt the tests to a default instance on the default port#10605
andreasjordan wants to merge 1 commit into
developmentfrom
fix-newdbafirewallrule-default-instance

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Summary

The integration tests assumed InstanceSingle is a named instance. Run against a default instance on the default port they fail ten times, although the command behaves exactly as documented:

  • The Engine rule of a default instance is named SQL Server default instance, not SQL Server instance MSSQLSERVER.
  • A Browser rule is only created for a named instance or a static port other than 1433, because a default instance on 1433 is reachable without the Browser. So a default instance gets exactly one rule, and every count, index and Browser assertion missed.

Changes (tests only, both contexts the same way)

  • The expected Engine rule name and the expected minimum rule count are computed from the instance in BeforeAll.
  • A $browserExpected value is computed at discovery time next to the existing $isUsingDynamicPort probe, mirroring the condition of the command, and the Browser tests carry -Skip:(-not $browserExpected).
  • A negative counterpart test with -Skip:$browserExpected asserts that a default instance on the default port gets no Browser rule, so this shape is now covered instead of skipped over.
  • The counts use @() because a single result from Select-DefaultView does not answer .Count.

The named-instance assertions are unchanged in strictness and keep running on CI and the named-instance lab configurations.

Verified against both shapes: a clustered default instance on port 1433 (11 passed, Browser tests skipped, negative tests run) and a named instance (full Browser coverage), both warning-free.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…fault port

(do New-DbaFirewallRule)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant