test(ipam): cover deleting the default namespace with its name in the id field
This pull request was written by nisse, an AI agent, and opened with the GitHub account of the person who runs it. That person reviews it before marking it ready for review.
Why
Before #11583, a user who could delete namespaces could delete the default IP namespace by sending its name in the id field:
mutation { IpamNamespaceDelete(data: { id: "default" }) { ok } }
The old check compared the text in id with the UUID of the default namespace. find_object then looked up "default" with the default filter of IpamNamespace (name__value), found the default namespace and deleted it.
#11583 moved the check into _delete_obj, which compares the UUID of the node that the lookup returns, so stable already blocks this request. No test covered this request, and the changelog did not mention it.
Closes #11633
What changed
test_protected_default_ipnamespaceandtest_delete_regular_ipnamespacenow also send the namespace name inid, on the default branch and on a user branch. Deleting the default namespace this way must return HTTP 422 with "Cannot delete default IPAM namespace" and leave the namespace in place. Deleting another namespace this way must delete it.- The test cases use a
NamespaceLookupenum (id,hfid,name-as-id) instead of theby_hfidboolean. The existing test IDs (by-id,by-hfid,by-id-user-branch,by-hfid-user-branch) do not change. changelog/11633.fixed.mdtells users that releases before this fix deleted the default namespace when a request sent its name asid.- Application code does not change. The fix reaches
developwhenstableis merged into it, becausedevelopstill has the old check inmutate_delete.
How to review
backend/tests/component/graphql/mutations/test_ipam.py: the case list and the_delete_ipnamespacehelper.- The wording of the changelog fragment.
How to test
uv run pytest backend/tests/component/graphql/mutations/test_ipam.py -k ipnamespace
With the mutate_delete check from before #11583 put back temporarily, by-name-as-id and by-name-as-id-user-branch fail (ok: true). On this branch, all cases pass.
Checklist
- Tests added/updated
- Changelog entry added (
uv run towncrier create ...) - External docs updated (if user-facing or ops-facing change)
- Internal .md docs updated (internal knowledge and AI code tools knowledge)
- I have reviewed AI generated content
š¤ Generated with Claude Code
Jira: IFC-3635