test(ipam): cover deleting the default namespace with its name in the id field

Draft
OG
3h ago
+21-11

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_ipnamespace and test_delete_regular_ipnamespace now also send the namespace name in id, 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 NamespaceLookup enum (id, hfid, name-as-id) instead of the by_hfid boolean. The existing test IDs (by-id, by-hfid, by-id-user-branch, by-hfid-user-branch) do not change.
  • changelog/11633.fixed.md tells users that releases before this fix deleted the default namespace when a request sent its name as id.
  • Application code does not change. The fix reaches develop when stable is merged into it, because develop still has the old check in mutate_delete.

How to review

  • backend/tests/component/graphql/mutations/test_ipam.py: the case list and the _delete_ipnamespace helper.
  • 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