Skip to content

Commit

Permalink
keycloak: repair integration tests by removing jinja2 templating from…
Browse files Browse the repository at this point in the history
… conditionals (#9726) (#9727)

* fix: remove jinja2 templating from conditionals in keycloak_role module integration tests (#9726)

* fix: remove jinja2 templating in conditional in keycloak clientsecret info integration test (#9726)

This test needs a further fix; see #9744. Left for a future PR for now.

* fix: remove jinja2 templating in conditional in keycloak clientsecret regenerate integration test (#9726)

* chore: remove jinja2 templating in conditional in keycloak user federation integration test (#9726)

These instances of templating were not causing failures,
but this removes the warnings.

* chore: remove jinja2 templating in conditional in keycloak user rolemapping integration test (#9726)

These instances of templating were not causing failures,
but this removes the warnings.

* docs: add changelog fragment (#9726)

* docs: repair changelog fragment yaml (#9726)

* docs: actually repair changelog fragment yaml (#9726)

* chore: remove changelog fragment for test only pr (#9726)

(cherry picked from commit 910c57a)
  • Loading branch information
armkeh authored and patchback[bot] committed Feb 15, 2025
1 parent 52d6cc4 commit 2ced266
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
assert:
that:
- fetch_by_client_id_result.clientsecret_info.type == "secret"
- "{{ fetch_by_client_id_result.clientsecret_info.value | length }} >= 32"
- fetch_by_client_id_result.clientsecret_info.value | length >= 32

- name: Keycloak Client fetch clientsecret by id
community.general.keycloak_clientsecret_info: "{{ auth_args | combine(call_args) }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
assert:
that:
- regenerate_by_client_id.end_state.type == "secret"
- "{{ regenerate_by_client_id.end_state.value | length }} >= 32"
- regenerate_by_client_id.end_state.value | length >= 32

- name: Keycloak Client regenerate clientsecret by id
community.general.keycloak_clientsecret_regenerate: "{{ auth_args | combine(call_args) }}"
Expand All @@ -45,5 +45,5 @@
- name: Assert that client secret was regenerated
assert:
that:
- "{{ regenerate_by_id.end_state.value | length }} >= 32"
- regenerate_by_id.end_state.value | length >= 32
- regenerate_by_id.end_state.value != regenerate_by_client_id.end_state.value
18 changes: 9 additions & 9 deletions tests/integration/targets/keycloak_role/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
that:
- result is changed
- result.existing == {}
- result.end_state.name == "{{ role }}"
- result.end_state.containerId == "{{ realm }}"
- result.end_state.name == role
- result.end_state.containerId == realm

- name: Create existing realm role
community.general.keycloak_role:
Expand Down Expand Up @@ -89,8 +89,8 @@
assert:
that:
- result is changed
- result.existing.description == "{{ description_1 }}"
- result.end_state.description == "{{ description_2 }}"
- result.existing.description == description_1
- result.end_state.description == description_2

- name: Delete existing realm role
community.general.keycloak_role:
Expand Down Expand Up @@ -156,8 +156,8 @@
that:
- result is changed
- result.existing == {}
- result.end_state.name == "{{ role }}"
- result.end_state.containerId == "{{ client.end_state.id }}"
- result.end_state.name == role
- result.end_state.containerId == client.end_state.id

- name: Create existing client role
community.general.keycloak_role:
Expand Down Expand Up @@ -202,8 +202,8 @@
assert:
that:
- result is changed
- result.existing.description == "{{ description_1 }}"
- result.end_state.description == "{{ description_2 }}"
- result.existing.description == description_1
- result.end_state.description == description_2

- name: Delete existing client role
community.general.keycloak_role:
Expand Down Expand Up @@ -480,4 +480,4 @@
assert:
that:
- result is not changed
- result.end_state == {}
- result.end_state == {}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
that:
- result is changed
- result.existing == {}
- result.end_state.name == "{{ federation }}"
- result.end_state.name == federation

- name: Create new user federation in admin realm
community.general.keycloak_user_federation:
Expand Down Expand Up @@ -117,7 +117,7 @@
that:
- result is changed
- result.existing == {}
- result.end_state.name == "{{ federation }}"
- result.end_state.name == federation

- name: Update existing user federation (no change)
community.general.keycloak_user_federation:
Expand Down Expand Up @@ -170,9 +170,9 @@
that:
- result is not changed
- result.existing != {}
- result.existing.name == "{{ federation }}"
- result.existing.name == federation
- result.end_state != {}
- result.end_state.name == "{{ federation }}"
- result.end_state.name == federation

- name: Update existing user federation (no change, admin realm)
community.general.keycloak_user_federation:
Expand Down Expand Up @@ -225,9 +225,9 @@
that:
- result is not changed
- result.existing != {}
- result.existing.name == "{{ federation }}"
- result.existing.name == federation
- result.end_state != {}
- result.end_state.name == "{{ federation }}"
- result.end_state.name == federation

- name: Update existing user federation (with change)
community.general.keycloak_user_federation:
Expand Down Expand Up @@ -296,9 +296,9 @@
that:
- result is changed
- result.existing != {}
- result.existing.name == "{{ federation }}"
- result.existing.name == federation
- result.end_state != {}
- result.end_state.name == "{{ federation }}"
- result.end_state.name == federation

- name: Delete existing user federation
community.general.keycloak_user_federation:
Expand Down Expand Up @@ -411,7 +411,7 @@
that:
- result is changed
- result.existing == {}
- result.end_state.name == "{{ federation }}"
- result.end_state.name == federation

## no point in retesting this, just doing it to clean up introduced server changes
- name: Delete absent user federation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
assert:
that:
- result is changed
- result.end_state | selectattr("clientRole", "eq", false) | selectattr("name", "eq", "{{role}}") | list | count > 0
- result.end_state | selectattr("clientRole", "eq", false) | selectattr("name", "eq", role) | list | count > 0

- name: Unmap a realm role from client service account
vars:
Expand All @@ -74,8 +74,8 @@
that:
- result is changed
- (result.end_state | length) == (result.existing | length) - 1
- result.existing | selectattr("clientRole", "eq", false) | selectattr("name", "eq", "{{role}}") | list | count > 0
- result.end_state | selectattr("clientRole", "eq", false) | selectattr("name", "eq", "{{role}}") | list | count == 0
- result.existing | selectattr("clientRole", "eq", false) | selectattr("name", "eq", role) | list | count > 0
- result.end_state | selectattr("clientRole", "eq", false) | selectattr("name", "eq", role) | list | count == 0

- name: Delete existing realm role
community.general.keycloak_role:
Expand Down Expand Up @@ -118,7 +118,7 @@
assert:
that:
- result is changed
- result.end_state | selectattr("clientRole", "eq", true) | selectattr("name", "eq", "{{role}}") | list | count > 0
- result.end_state | selectattr("clientRole", "eq", true) | selectattr("name", "eq", role) | list | count > 0

- name: Unmap a client role from client service account
vars:
Expand All @@ -140,4 +140,4 @@
that:
- result is changed
- result.end_state == []
- result.existing | selectattr("clientRole", "eq", true) | selectattr("name", "eq", "{{role}}") | list | count > 0
- result.existing | selectattr("clientRole", "eq", true) | selectattr("name", "eq", role) | list | count > 0

0 comments on commit 2ced266

Please sign in to comment.