Skip to content

fix: fix E2E test drift caused by api_token#276

Merged
tamas-jozsa merged 1 commit intomainfrom
fix-e2e
Apr 15, 2026
Merged

fix: fix E2E test drift caused by api_token#276
tamas-jozsa merged 1 commit intomainfrom
fix-e2e

Conversation

@tamas-jozsa
Copy link
Copy Markdown
Collaborator

Summary

  • Fix E2E test drift caused by api_token permission_groups ordering mismatch between migrated config and v5 provider canonical ordering

Problem

The v5 Cloudflare provider returns permission_groups sorted alphabetically by ID, but the migrator preserved the original v4 ordering verbatim. This produced 4 unexempted drift changes in E2E tests where the plan showed permission group IDs swapped:

~ permission_groups[0].id = "82e64a83..." -> "c8fed203..."
~ permission_groups[1].id = "c8fed203..." -> "82e64a83..."

Affected resources: basic_token, multi_perms_token (any token with 2+ permission groups in a single policy).

Fix

Sort permission_groups IDs alphabetically in transformPermissionGroups() before building the v5 object list. This matches the v5 provider's canonical ordering and eliminates drift for all users, not just E2E tests.

Changes

  • internal/resources/api_token/v4_to_v5.go — Collect all permission group IDs first, sort.Strings(), then build objects
  • internal/resources/api_token/v4_to_v5_test.go — Update 2 test expected outputs
  • integration/v4_to_v5/testdata/api_token/expected/api_token.tf — Update 2 expected outputs

Testing

  • All unit tests pass (11/11 for api_token)
  • All integration tests pass (api_token + full suite)
  • Full go test ./... passes with zero failures

…ordering

The v5 provider returns permission_groups sorted alphabetically by ID,
but the migrator preserved the original v4 ordering. This caused drift
in E2E tests where the plan showed IDs swapped between what the config
specified and what the provider expected.
@tamas-jozsa tamas-jozsa merged commit 09c366a into main Apr 15, 2026
8 checks passed
@tamas-jozsa tamas-jozsa deleted the fix-e2e branch April 15, 2026 13:51
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