From 3c36d7f5ce43554ac6e0909d3802ee62f9d76300 Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Tue, 15 Apr 2025 11:36:52 +0200 Subject: [PATCH 1/3] CI jinja2 templating problem: fix --- .../tasks/postgresql_membership_initial.yml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml b/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml index 8122f36f..852a6963 100644 --- a/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml +++ b/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml @@ -43,7 +43,7 @@ - result is changed - result.groups == ["{{ test_group1 }}"] - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\""] - - result.granted.{{ test_group1 }} == ["{{ test_user1 }}"] + - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}"] - result.state == "present" - result.target_roles == ["{{ test_user1 }}"] @@ -67,7 +67,7 @@ - result is not changed - result.groups == ["{{ test_group1 }}"] - result.queries == [] - - result.revoked.{{ test_group1 }} == [] + - result.revoked["{{ test_group1 }}"] == [] - result.state == "absent" - result.target_roles == ["{{ test_user1 }}"] ### End of test check_mode @@ -90,7 +90,7 @@ - result is changed - result.groups == ["{{ test_group1 }}"] - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\""] - - result.granted.{{ test_group1 }} == ["{{ test_user1 }}"] + - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}"] - result.state == "present" - result.target_roles == ["{{ test_user1 }}"] @@ -112,7 +112,7 @@ - result is not changed - result.groups == ["{{ test_group1 }}"] - result.queries == [] - - result.granted.{{ test_group1 }} == [] + - result.granted["{{ test_group1 }}"] == [] - result.state == "present" - result.target_roles == ["{{ test_user1 }}"] @@ -134,7 +134,7 @@ - result is changed - result.groups == ["{{ test_group1 }}"] - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\""] - - result.revoked.{{ test_group1 }} == ["{{ test_user1 }}"] + - result.revoked["{{ test_group1 }}"] == ["{{ test_user1 }}"] - result.state == "absent" - result.target_roles == ["{{ test_user1 }}"] @@ -156,7 +156,7 @@ - result is not changed - result.groups == ["{{ test_group1 }}"] - result.queries == [] - - result.revoked.{{ test_group1 }} == [] + - result.revoked["{{ test_group1 }}"] == [] - result.state == "absent" - result.target_roles == ["{{ test_user1 }}"] @@ -182,8 +182,8 @@ - result is changed - result.groups == ["{{ test_group1 }}", "{{ test_group2 }}"] - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group1 }}\" TO \"{{ test_user2 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user2 }}\""] - - result.granted.{{ test_group1 }} == ["{{ test_user1 }}", "{{ test_user2 }}"] - - result.granted.{{ test_group2 }} == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.granted["{{ test_group2 }}"] == ["{{ test_user1 }}", "{{ test_user2 }}"] - result.state == "present" - result.target_roles == ["{{ test_user1 }}", "{{ test_user2 }}"] @@ -209,8 +209,8 @@ - result is not changed - result.groups == ["{{ test_group1 }}", "{{ test_group2 }}"] - result.queries == [] - - result.granted.{{ test_group1 }} == [] - - result.granted.{{ test_group2 }} == [] + - result.granted["{{ test_group1 }}"] == [] + - result.granted["{{ test_group2 }}"] == [] - result.state == "present" - result.target_roles == ["{{ test_user1 }}", "{{ test_user2 }}"] @@ -232,7 +232,7 @@ - result is changed - result.groups == ["{{ test_group1 }}"] - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\""] - - result.revoked.{{ test_group1 }} == ["{{ test_user1 }}"] + - result.revoked["{{ test_group1 }}"] == ["{{ test_user1 }}"] - result.state == "absent" - result.target_roles == ["{{ test_user1 }}"] @@ -259,8 +259,8 @@ - result is changed - result.groups == ["{{ test_group1 }}", "{{ test_group2 }}"] - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\""] - - result.granted.{{ test_group1 }} == ["{{ test_user1 }}"] - - result.granted.{{ test_group2 }} == [] + - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}"] + - result.granted["{{ test_group2 }}"] == [] - result.state == "present" - result.target_roles == ["{{ test_user1 }}", "{{ test_user2 }}"] @@ -406,7 +406,7 @@ - assert: that: - result is changed - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group2 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group3 }}\" FROM \"{{ test_user1 }}\""], + - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group2 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group3 }}\" FROM \"{{ test_user1 }}\""] - result.revoked["group.with.dots"] == ["{{ test_user1 }}"] - result.revoked["group1"] == ["{{ test_user1 }}"] - result.revoked["group2"] == ["{{ test_user1 }}"] From c34396c37b59623fa10544ccbf712ad868a9babf Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Tue, 22 Apr 2025 11:00:17 +0200 Subject: [PATCH 2/3] Fix more tests --- .../postgresql_membership/defaults/main.yml | 6 - .../tasks/postgresql_membership_initial.yml | 351 +++++++++--------- .../tasks/postgresql_query_initial.yml | 2 +- .../tasks/postgresql_subscription_initial.yml | 4 +- .../tasks/postgresql_user_general.yml | 2 +- .../tasks/postgresql_user_obj_stat_info.yml | 78 ++-- 6 files changed, 214 insertions(+), 229 deletions(-) delete mode 100644 tests/integration/targets/postgresql_membership/defaults/main.yml diff --git a/tests/integration/targets/postgresql_membership/defaults/main.yml b/tests/integration/targets/postgresql_membership/defaults/main.yml deleted file mode 100644 index 7b1d49e4..00000000 --- a/tests/integration/targets/postgresql_membership/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -test_group1: group1 -test_group2: group2 -test_group3: group.with.dots -test_user1: user1 -test_user2: user.with.dots -dangerous_name: 'curious.anonymous"; SELECT * FROM information_schema.tables; --' diff --git a/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml b/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml index 852a6963..723d76b3 100644 --- a/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml +++ b/tests/integration/targets/postgresql_membership/tasks/postgresql_membership_initial.yml @@ -14,25 +14,25 @@ name: "{{ item }}" ignore_errors: true with_items: - - "{{ test_group1 }}" - - "{{ test_group2 }}" - - "{{ test_group3 }}" - - "{{ test_user1 }}" - - "{{ test_user2 }}" + - "group1" + - "group2" + - "group.with.dots" + - "user1" + - "user.with.dots" ################ # Do main tests: ### Test check_mode -# Grant test_group1 to test_user1 in check_mode: -- name: postgresql_membership - grant test_group1 to test_user1 in check_mode +# Grant group1 to user1 in check_mode: +- name: postgresql_membership - grant group1 to user1 in check_mode become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: present register: result ignore_errors: true @@ -41,22 +41,22 @@ - assert: that: - result is changed - - result.groups == ["{{ test_group1 }}"] - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\""] - - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}"] + - result.groups == ["group1"] + - result.queries == ["GRANT \"group1\" TO \"user1\""] + - result.granted["group1"] == ["user1"] - result.state == "present" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] -# Try to revoke test_group1 from test_user1 to check that +# Try to revoke group1 from user1 to check that # nothing actually changed in check_mode at the previous step: -- name: postgresql_membership - try to revoke test_group1 from test_user1 for checking check_mode +- name: postgresql_membership - try to revoke group1 from user1 for checking check_mode become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: absent register: result ignore_errors: true @@ -65,22 +65,22 @@ - assert: that: - result is not changed - - result.groups == ["{{ test_group1 }}"] + - result.groups == ["group1"] - result.queries == [] - - result.revoked["{{ test_group1 }}"] == [] + - result.revoked["group1"] == [] - result.state == "absent" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] ### End of test check_mode -# Grant test_group1 to test_user1: -- name: postgresql_membership - grant test_group1 to test_user1 +# Grant group1 to user1: +- name: postgresql_membership - grant group1 to user1 become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: present register: result ignore_errors: true @@ -88,21 +88,21 @@ - assert: that: - result is changed - - result.groups == ["{{ test_group1 }}"] - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\""] - - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}"] + - result.groups == ["group1"] + - result.queries == ["GRANT \"group1\" TO \"user1\""] + - result.granted["group1"] == ["user1"] - result.state == "present" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] -# Grant test_group1 to test_user1 again to check that nothing changes: -- name: postgresql_membership - grant test_group1 to test_user1 again +# Grant group1 to user1 again to check that nothing changes: +- name: postgresql_membership - grant group1 to user1 again become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: present register: result ignore_errors: true @@ -110,21 +110,21 @@ - assert: that: - result is not changed - - result.groups == ["{{ test_group1 }}"] + - result.groups == ["group1"] - result.queries == [] - - result.granted["{{ test_group1 }}"] == [] + - result.granted["group1"] == [] - result.state == "present" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] -# Revoke test_group1 from test_user1: -- name: postgresql_membership - revoke test_group1 from test_user1 +# Revoke group1 from user1: +- name: postgresql_membership - revoke group1 from user1 become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: absent register: result ignore_errors: true @@ -132,21 +132,21 @@ - assert: that: - result is changed - - result.groups == ["{{ test_group1 }}"] - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\""] - - result.revoked["{{ test_group1 }}"] == ["{{ test_user1 }}"] + - result.groups == ["group1"] + - result.queries == ["REVOKE \"group1\" FROM \"user1\""] + - result.revoked["group1"] == ["user1"] - result.state == "absent" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] -# Revoke test_group1 from test_user1 again to check that nothing changes: -- name: postgresql_membership - revoke test_group1 from test_user1 again +# Revoke group1 from user1 again to check that nothing changes: +- name: postgresql_membership - revoke group1 from user1 again become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: absent register: result ignore_errors: true @@ -154,13 +154,13 @@ - assert: that: - result is not changed - - result.groups == ["{{ test_group1 }}"] + - result.groups == ["group1"] - result.queries == [] - - result.revoked["{{ test_group1 }}"] == [] + - result.revoked["group1"] == [] - result.state == "absent" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] -# Grant test_group1 and test_group2 to test_user1 and test_user2: +# Grant group1 and group2 to user1 and user.with.dots: - name: postgresql_membership - grant two groups to two users become_user: "{{ pg_user }}" become: true @@ -168,11 +168,11 @@ login_user: "{{ pg_user }}" db: postgres group: - - "{{ test_group1 }}" - - "{{ test_group2 }}" + - "group1" + - "group2" user: - - "{{ test_user1 }}" - - "{{ test_user2 }}" + - "user1" + - "user.with.dots" state: present register: result ignore_errors: true @@ -180,14 +180,13 @@ - assert: that: - result is changed - - result.groups == ["{{ test_group1 }}", "{{ test_group2 }}"] - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group1 }}\" TO \"{{ test_user2 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user2 }}\""] - - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}", "{{ test_user2 }}"] - - result.granted["{{ test_group2 }}"] == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.groups == ["group1", "group2"] + - result.granted["group1"] == ["user1", "user.with.dots"] + - result.granted["group2"] == ["user1", "user.with.dots"] - result.state == "present" - - result.target_roles == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.target_roles == ["user1", "user.with.dots"] -# Grant test_group1 and test_group2 to test_user1 and test_user2 again to check that nothing changes: +# Grant group1 and group2 to user1 and user.with.dots again to check that nothing changes: - name: postgresql_membership - grant two groups to two users again become_user: "{{ pg_user }}" become: true @@ -195,11 +194,11 @@ login_user: "{{ pg_user }}" db: postgres group: - - "{{ test_group1 }}" - - "{{ test_group2 }}" + - "group1" + - "group2" user: - - "{{ test_user1 }}" - - "{{ test_user2 }}" + - "user1" + - "user.with.dots" state: present register: result ignore_errors: true @@ -207,22 +206,22 @@ - assert: that: - result is not changed - - result.groups == ["{{ test_group1 }}", "{{ test_group2 }}"] + - result.groups == ["group1", "group2"] - result.queries == [] - - result.granted["{{ test_group1 }}"] == [] - - result.granted["{{ test_group2 }}"] == [] + - result.granted["group1"] == [] + - result.granted["group2"] == [] - result.state == "present" - - result.target_roles == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.target_roles == ["user1", "user.with.dots"] -# Revoke only test_group1 from test_user1: +# Revoke only group1 from user1: - name: postgresql_membership - revoke one group from one user become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group1 }}" - user: "{{ test_user1 }}" + group: "group1" + user: "user1" state: absent register: result ignore_errors: true @@ -230,14 +229,14 @@ - assert: that: - result is changed - - result.groups == ["{{ test_group1 }}"] - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\""] - - result.revoked["{{ test_group1 }}"] == ["{{ test_user1 }}"] + - result.groups == ["group1"] + - result.queries == ["REVOKE \"group1\" FROM \"user1\""] + - result.revoked["group1"] == ["user1"] - result.state == "absent" - - result.target_roles == ["{{ test_user1 }}"] + - result.target_roles == ["user1"] -# Try to grant test_group1 and test_group2 to test_user1 and test_user2 again -# to check that nothing changes with test_user2: +# Try to grant group1 and group2 to user1 and user.with.dots again +# to check that nothing changes with user.with.dots: - name: postgresql_membership - grant two groups to two users again become_user: "{{ pg_user }}" become: true @@ -245,11 +244,11 @@ login_user: "{{ pg_user }}" db: postgres group: - - "{{ test_group1 }}" - - "{{ test_group2 }}" + - "group1" + - "group2" user: - - "{{ test_user1 }}" - - "{{ test_user2 }}" + - "user1" + - "user.with.dots" state: present register: result ignore_errors: true @@ -257,12 +256,12 @@ - assert: that: - result is changed - - result.groups == ["{{ test_group1 }}", "{{ test_group2 }}"] - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\""] - - result.granted["{{ test_group1 }}"] == ["{{ test_user1 }}"] - - result.granted["{{ test_group2 }}"] == [] + - result.groups == ["group1", "group2"] + - result.queries == ["GRANT \"group1\" TO \"user1\""] + - result.granted["group1"] == ["user1"] + - result.granted["group2"] == [] - result.state == "present" - - result.target_roles == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.target_roles == ["user1", "user.with.dots"] ##################### # Check fail_on_role: @@ -329,22 +328,22 @@ - result.target_roles == [] - result.state == 'absent' -# Grant test_group3 with a name containing dots to test_user1. -- name: postgresql_membership - grant test_group3 with dots to test_user1 +# Grant group.with.dots with a name containing dots to user1. +- name: postgresql_membership - grant group.with.dots with dots to user1 become_user: "{{ pg_user }}" become: true postgresql_membership: login_user: "{{ pg_user }}" db: postgres - group: "{{ test_group3 }}" - user: "{{ test_user1 }}" + group: "group.with.dots" + user: "user1" state: present register: result - assert: that: - result is changed - - result.queries == ["GRANT \"{{ test_group3 }}\" TO \"{{ test_user1 }}\""] + - result.queries == ["GRANT \"group.with.dots\" TO \"user1\""] ############################# # Check trust_input parameter @@ -356,9 +355,9 @@ login_user: "{{ pg_user }}" db: postgres group: - - "{{ test_group3}}" - - "{{ dangerous_name }}" - user: "{{ test_user1 }}" + - "group.with.dots" + - 'curious.anonymous"; SELECT * FROM information_schema.tables; --' + user: "user1" state: present trust_input: false register: result @@ -367,7 +366,7 @@ - assert: that: - result is failed - - result.msg == 'Passed input \'{{ dangerous_name }}\' is potentially dangerous' + - result.msg == 'Passed input \'curious.anonymous"; SELECT * FROM information_schema.tables; --\' is potentially dangerous' - name: postgresql_membership - try to use dangerous input, trust explicitly become_user: "{{ pg_user }}" @@ -376,9 +375,9 @@ login_user: "{{ pg_user }}" db: postgres group: - - "{{ test_group3}}" - - "{{ dangerous_name }}" - user: "{{ test_user1 }}" + - "group.with.dots" + - 'curious.anonymous"; SELECT * FROM information_schema.tables; --' + user: "user1" state: present trust_input: true register: result @@ -387,7 +386,7 @@ - assert: that: - result is failed - - result.msg == 'Role {{ dangerous_name }} does not exist' + - result.msg == 'Role curious.anonymous"; SELECT * FROM information_schema.tables; -- does not exist' ######################## # Tests for match method @@ -398,7 +397,7 @@ login_user: "{{ pg_user }}" db: postgres groups: [] - user: "{{ test_user1 }}" + user: "user1" state: exact register: result check_mode: true @@ -406,10 +405,9 @@ - assert: that: - result is changed - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group2 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group3 }}\" FROM \"{{ test_user1 }}\""] - - result.revoked["group.with.dots"] == ["{{ test_user1 }}"] - - result.revoked["group1"] == ["{{ test_user1 }}"] - - result.revoked["group2"] == ["{{ test_user1 }}"] + - result.revoked["group.with.dots"] == ["user1"] + - result.revoked["group1"] == ["user1"] + - result.revoked["group2"] == ["user1"] - result.granted == {} @@ -419,12 +417,12 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group1 }}', '{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group1', 'group2', 'group.with.dots'] - name: Revoke all groups from a role actual mode become_user: "{{ pg_user }}" @@ -433,17 +431,16 @@ login_user: "{{ pg_user }}" db: postgres groups: [] - user: "{{ test_user1 }}" + user: "user1" state: exact register: result - assert: that: - result is changed - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group2 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group3 }}\" FROM \"{{ test_user1 }}\""], - - result.revoked["group.with.dots"] == ["{{ test_user1 }}"] - - result.revoked["group1"] == ["{{ test_user1 }}"] - - result.revoked["group2"] == ["{{ test_user1 }}"] + - result.revoked["group.with.dots"] == ["user1"] + - result.revoked["group1"] == ["user1"] + - result.revoked["group2"] == ["user1"] - result.granted == {} @@ -453,7 +450,7 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: @@ -467,10 +464,10 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group1 }}" - - "{{ test_group2 }}" - - "{{ test_group3 }}" - user: "{{ test_user1 }}" + - "group1" + - "group2" + - "group.with.dots" + user: "user1" state: exact register: result check_mode: true @@ -478,10 +475,9 @@ - assert: that: - result is changed - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group3 }}\" TO \"{{ test_user1 }}\""], - - result.granted["group.with.dots"] == ["{{ test_user1 }}"] - - result.granted["group1"] == ["{{ test_user1 }}"] - - result.granted["group2"] == ["{{ test_user1 }}"] + - result.granted["group.with.dots"] == ["user1"] + - result.granted["group1"] == ["user1"] + - result.granted["group2"] == ["user1"] - result.revoked == {} @@ -491,7 +487,7 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: @@ -505,20 +501,19 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group1 }}" - - "{{ test_group2 }}" - - "{{ test_group3 }}" - user: "{{ test_user1 }}" + - "group1" + - "group2" + - "group.with.dots" + user: "user1" state: exact register: result - assert: that: - result is changed - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group3 }}\" TO \"{{ test_user1 }}\""], - - result.granted["group.with.dots"] == ["{{ test_user1 }}"] - - result.granted["group1"] == ["{{ test_user1 }}"] - - result.granted["group2"] == ["{{ test_user1 }}"] + - result.granted["group.with.dots"] == ["user1"] + - result.granted["group1"] == ["user1"] + - result.granted["group2"] == ["user1"] - result.revoked == {} @@ -528,12 +523,12 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group1 }}', '{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group1', 'group2', 'group.with.dots'] - name: Change groups 1 become_user: "{{ pg_user }}" @@ -542,17 +537,16 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group1 }}" - user: "{{ test_user1 }}" + - "group1" + user: "user1" state: exact register: result - assert: that: - result is changed - - result.queries == ["REVOKE \"{{ test_group2 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group3 }}\" FROM \"{{ test_user1 }}\""], - - result.revoked["group.with.dots"] == ["{{ test_user1 }}"] - - result.revoked["group2"] == ["{{ test_user1 }}"] + - result.revoked["group.with.dots"] == ["user1"] + - result.revoked["group2"] == ["user1"] - result.granted == {} @@ -562,12 +556,12 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group1 }}'] + - result.query_result.0.array == ['group1'] - name: Change groups 2 become_user: "{{ pg_user }}" @@ -576,19 +570,18 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group2 }}" - - "{{ test_group3 }}" - user: "{{ test_user1 }}" + - "group2" + - "group.with.dots" + user: "user1" state: exact register: result - assert: that: - result is changed - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\"", "GRANT \"{{ test_group2 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group3 }}\" TO \"{{ test_user1 }}\""], - - result.granted["group.with.dots"] == ["{{ test_user1 }}"] - - result.granted["group2"] == ["{{ test_user1 }}"] - - result.revoked["group1"] == ["{{ test_user1 }}"] + - result.granted["group.with.dots"] == ["user1"] + - result.granted["group2"] == ["user1"] + - result.revoked["group1"] == ["user1"] - name: Check result of prev task become_user: "{{ pg_user }}" @@ -596,12 +589,12 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group2', 'group.with.dots'] - name: Change groups 2 again become_user: "{{ pg_user }}" @@ -610,16 +603,16 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group2 }}" - - "{{ test_group3 }}" - user: "{{ test_user1 }}" + - "group2" + - "group.with.dots" + user: "user1" state: exact register: result - assert: that: - result is not changed - - result.queries == [], + - result.queries == [] - result.granted == {} - result.revoked == {} @@ -630,12 +623,12 @@ postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group2', 'group.with.dots'] - name: Change groups for two users become_user: "{{ pg_user }}" @@ -644,48 +637,47 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group1 }}" - - "{{ test_group2 }}" - - "{{ test_group3 }}" + - "group1" + - "group2" + - "group.with.dots" users: - - "{{ test_user1 }}" - - "{{ test_user2 }}" + - "user1" + - "user.with.dots" state: exact register: result - assert: that: - result is changed - - result.queries == ["GRANT \"{{ test_group1 }}\" TO \"{{ test_user1 }}\"", "GRANT \"{{ test_group3 }}\" TO \"{{ test_user2 }}\""], - - result.granted["group1"] == ["{{ test_user1 }}"] - - result.granted["group.with.dots"] == ["{{ test_user2 }}"] + - result.granted["group1"] == ["user1"] + - result.granted["group.with.dots"] == ["user.with.dots"] - result.revoked == {} -- name: Check result of prev task for {{ test_user1 }} +- name: Check result of prev task for user1 become_user: "{{ pg_user }}" become: true postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group1 }}', '{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group1', 'group2', 'group.with.dots'] -- name: Check result of prev task for {{ test_user2 }} +- name: Check result of prev task for user.with.dots become_user: "{{ pg_user }}" become: true postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user2 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user.with.dots'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group1 }}', '{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group1', 'group2', 'group.with.dots'] - name: Change groups for two users 2 become_user: "{{ pg_user }}" @@ -694,43 +686,42 @@ login_user: "{{ pg_user }}" db: postgres groups: - - "{{ test_group2 }}" - - "{{ test_group3 }}" + - "group2" + - "group.with.dots" users: - - "{{ test_user1 }}" - - "{{ test_user2 }}" + - "user1" + - "user.with.dots" state: exact register: result - assert: that: - result is changed - - result.queries == ["REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user1 }}\"", "REVOKE \"{{ test_group1 }}\" FROM \"{{ test_user2 }}\""], - - result.revoked["group1"] == ["{{ test_user1 }}", "{{ test_user2 }}"] + - result.revoked["group1"] == ["user1", "user.with.dots"] - result.granted == {} -- name: Check result of prev task for {{ test_user1 }} +- name: Check result of prev task for user1 become_user: "{{ pg_user }}" become: true postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user1 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user1'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group2', 'group.with.dots'] -- name: Check result of prev task for {{ test_user2 }} +- name: Check result of prev task for user.with.dots become_user: "{{ pg_user }}" become: true postgresql_query: login_user: "{{ pg_user }}" db: postgres - query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = '{{ test_user2 }}'" + query: "SELECT ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) FROM pg_catalog.pg_roles r WHERE r.rolname = 'user.with.dots'" register: result - assert: that: - - result.query_result.0.array == ['{{ test_group2 }}', '{{ test_group3 }}'] + - result.query_result.0.array == ['group2', 'group.with.dots'] diff --git a/tests/integration/targets/postgresql_query/tasks/postgresql_query_initial.yml b/tests/integration/targets/postgresql_query/tasks/postgresql_query_initial.yml index 898ee91c..6635e41c 100644 --- a/tests/integration/targets/postgresql_query/tasks/postgresql_query_initial.yml +++ b/tests/integration/targets/postgresql_query/tasks/postgresql_query_initial.yml @@ -575,7 +575,7 @@ - assert: that: - result.rowcount == 3 - - result.query_result == [{"?column?": 1}] + - result.query_result[0]["?column?"] == 1 - 'result.query_all_results == [[{"?column?": 1}], [{"?column?": 1}], [{"?column?": 1}]]' - result.execution_time_ms[0] > 0 - result.execution_time_ms[1] > 0 diff --git a/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml b/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml index 0aa192be..0a4601eb 100644 --- a/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml +++ b/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml @@ -58,7 +58,7 @@ - result.final_state.slotname == '{{ test_subscription }}' - result.final_state.conninfo.dbname == '{{ test_db }}' - result.final_state.conninfo.host == '127.0.0.1' - - result.final_state.conninfo.port == {{ primary_port }} + - result.final_state.conninfo.port == '{{ primary_port }}' - result.final_state.conninfo.user == '{{ replication_role }}' - result.final_state.conninfo.password == '{{ replication_pass }}' @@ -736,7 +736,7 @@ - result.name == '{{ test_subscription }}' - result.queries == [] - result.initial_state.conninfo == result.final_state.conninfo - - result.final_state.conninfo.connect_timeout == {{ conn_timeout }} + - result.final_state.conninfo.connect_timeout == '{{ conn_timeout }}' #################### # Test state refresh diff --git a/tests/integration/targets/postgresql_user/tasks/postgresql_user_general.yml b/tests/integration/targets/postgresql_user/tasks/postgresql_user_general.yml index 3fc6ccae..fd4439ae 100644 --- a/tests/integration/targets/postgresql_user/tasks/postgresql_user_general.yml +++ b/tests/integration/targets/postgresql_user/tasks/postgresql_user_general.yml @@ -963,7 +963,7 @@ - assert: that: - - result.msg == 'ERROR: cannot execute ALTER ROLE in a read-only transaction\n' + - "result.msg == 'ERROR: cannot execute ALTER ROLE in a read-only transaction\n' or result.msg == 'cannot execute ALTER ROLE in a read-only transaction'" - name: Set database as read-write <<: *task_parameters diff --git a/tests/integration/targets/postgresql_user_obj_stat_info/tasks/postgresql_user_obj_stat_info.yml b/tests/integration/targets/postgresql_user_obj_stat_info/tasks/postgresql_user_obj_stat_info.yml index fceee163..e4b71ebb 100644 --- a/tests/integration/targets/postgresql_user_obj_stat_info/tasks/postgresql_user_obj_stat_info.yml +++ b/tests/integration/targets/postgresql_user_obj_stat_info/tasks/postgresql_user_obj_stat_info.yml @@ -23,7 +23,7 @@ <<: *task_parameters postgresql_schema: <<: *pg_parameters - name: '{{ test_schema1 }}' + name: 'schema1' - name: Create test tables <<: *task_parameters @@ -33,26 +33,26 @@ columns: - id int loop: - - '{{ test_table1 }}' - - '{{ test_table2 }}' + - 'acme1' + - 'acme2' - name: Create test table in another schema <<: *task_parameters postgresql_table: <<: *pg_parameters - name: '{{ test_schema1 }}.{{ test_table3 }}' + name: 'schema1.acme3' - name: Create test indexes <<: *task_parameters postgresql_idx: <<: *pg_parameters name: '{{ item }}' - table: '{{ test_table1 }}' + table: 'acme1' columns: - id loop: - - '{{ test_idx1 }}' - - '{{ test_idx2 }}' + - 'idx1' + - 'idx2' - name: Set track_function (restart is required) <<: *task_parameters @@ -83,9 +83,9 @@ <<: *pg_parameters query: 'CREATE FUNCTION {{ item }}() RETURNS boolean AS $$ BEGIN RETURN 1; END; $$ LANGUAGE PLPGSQL' loop: - - '{{ test_func1 }}' - - '{{ test_func2 }}' - - '{{ test_schema1 }}.{{ test_func3 }}' + - 'func1' + - 'func2' + - 'schema1.func3' - name: Touch test functions <<: *task_parameters @@ -93,9 +93,9 @@ <<: *pg_parameters query: 'SELECT {{ item }}()' loop: - - '{{ test_func1 }}' - - '{{ test_func2 }}' - - '{{ test_schema1 }}.{{ test_func3 }}' + - 'func1' + - 'func2' + - 'schema1.func3' ####### # Tests @@ -109,14 +109,14 @@ - assert: that: - result is not changed - - result.tables.public.{{ test_table1 }}.size == 0 - - result.tables.public.{{ test_table1 }}.size == 0 - - result.tables.{{ test_schema1 }}.{{ test_table3 }}.size == 0 - - result.functions.public.{{ test_func1 }}.calls == 1 - - result.functions.public.{{ test_func2 }}.calls == 1 - - result.functions.{{ test_schema1 }}.{{ test_func3 }}.calls == 1 - - result.indexes.public.{{ test_idx1 }}.idx_scan == 0 - - result.indexes.public.{{ test_idx2 }}.idx_scan == 0 + - result.tables.public.acme1.size == 0 + - result.tables.public.acme1.size == 0 + - result.tables.schema1.acme3.size == 0 + - result.functions.public.func1.calls == 1 + - result.functions.public.func2.calls == 1 + - result.functions.schema1.func3.calls == 1 + - result.indexes.public.idx1.idx_scan == 0 + - result.indexes.public.idx2.idx_scan == 0 # 1. With filter - name: Collect stats with filter @@ -128,12 +128,12 @@ - assert: that: - result is not changed - - result.tables.public.{{ test_table1 }}.size == 0 - - result.tables.public.{{ test_table1 }}.size == 0 - - result.tables.{{ test_schema1 }}.{{ test_table3 }}.size == 0 + - result.tables.public.acme1.size == 0 + - result.tables.public.acme1.size == 0 + - result.tables.schema1.acme3.size == 0 - result.functions == {} - - result.indexes.public.{{ test_idx1 }}.idx_scan == 0 - - result.indexes.public.{{ test_idx2 }}.idx_scan == 0 + - result.indexes.public.idx1.idx_scan == 0 + - result.indexes.public.idx2.idx_scan == 0 # 2. With schema - name: Collect stats for objects in certain schema @@ -145,13 +145,13 @@ - assert: that: - result is not changed - - result.tables.public.{{ test_table1 }}.size == 0 - - result.tables.public.{{ test_table1 }}.size == 0 - - result.indexes.public.{{ test_idx1 }}.idx_scan == 0 - - result.indexes.public.{{ test_idx2 }}.idx_scan == 0 - - result.functions.public.{{ test_func1 }}.calls == 1 - - result.functions.public.{{ test_func2 }}.calls == 1 - - result.tables.{{ test_schema1 }} is not defined + - result.tables.public.acme1.size == 0 + - result.tables.public.acme1.size == 0 + - result.indexes.public.idx1.idx_scan == 0 + - result.indexes.public.idx2.idx_scan == 0 + - result.functions.public.func1.calls == 1 + - result.functions.public.func2.calls == 1 + - result.tables.schema1 is not defined # 3. With wrong schema @@ -188,7 +188,7 @@ <<: *task_parameters postgresql_schema: <<: *pg_parameters - name: '{{ test_schema1 }}' + name: 'schema1' state: absent cascade_drop: true @@ -199,8 +199,8 @@ name: '{{ item }}' state: absent loop: - - '{{ test_table1 }}' - - '{{ test_table2 }}' + - 'acme1' + - 'acme2' - name: Drop test functions <<: *task_parameters @@ -208,7 +208,7 @@ <<: *pg_parameters query: 'DROP FUNCTION {{ item }}()' loop: - - '{{ test_func1 }}' - - '{{ test_func2 }}' - - '{{ test_schema1 }}.{{ test_func3 }}' + - 'func1' + - 'func2' + - 'schema1.func3' ignore_errors: true From 1500d1f21c0c5eca0ebdc3682d598429eba251d7 Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Tue, 22 Apr 2025 13:05:27 +0200 Subject: [PATCH 3/3] Fix --- .../tasks/postgresql_subscription_initial.yml | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml b/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml index 0a4601eb..31a383b1 100644 --- a/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml +++ b/tests/integration/targets/postgresql_subscription/tasks/postgresql_subscription_initial.yml @@ -47,20 +47,20 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["CREATE SUBSCRIPTION test CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }}' PUBLICATION {{ test_pub }}", "COMMENT ON SUBSCRIPTION \"test\" IS 'Made by Ansible'"] - result.exists == true - result.initial_state == {} - - result.final_state.owner == '{{ pg_user }}' + - result.final_state.owner == pg_user - result.final_state.enabled == true - - result.final_state.publications == ["{{ test_pub }}"] + - result.final_state.publications[0] == test_pub - result.final_state.synccommit == true - - result.final_state.slotname == '{{ test_subscription }}' - - result.final_state.conninfo.dbname == '{{ test_db }}' + - result.final_state.slotname == test_subscription + - result.final_state.conninfo.dbname == test_db - result.final_state.conninfo.host == '127.0.0.1' - - result.final_state.conninfo.port == '{{ primary_port }}' - - result.final_state.conninfo.user == '{{ replication_role }}' - - result.final_state.conninfo.password == '{{ replication_pass }}' + - result.final_state.conninfo.port == primary_port + - result.final_state.conninfo.user == replication_role + - result.final_state.conninfo.password == replication_pass - name: Check <<: *task_parameters @@ -262,7 +262,7 @@ - assert: that: - - result.final_state.owner == '{{ test_role1 }}' + - result.final_state.owner == test_role1 - result.queries[1] == 'ALTER SUBSCRIPTION {{ test_subscription }} OWNER TO "{{ test_role1 }}"' - name: Try to set this owner again @@ -280,7 +280,7 @@ that: - result is not changed - result.initial_state == result.final_state - - result.final_state.owner == '{{ test_role1 }}' + - result.final_state.owner == test_role1 - name: Check <<: *task_parameters @@ -312,7 +312,7 @@ that: - result is changed - result.initial_state == result.final_state - - result.final_state.owner == '{{ test_role1 }}' + - result.final_state.owner == test_role1 - result.queries == ['ALTER SUBSCRIPTION {{ test_subscription }} OWNER TO "{{ test_role2 }}"'] - name: Check @@ -344,7 +344,7 @@ that: - result is changed - result.initial_state != result.final_state - - result.final_state.owner == '{{ test_role2 }}' + - result.final_state.owner == test_role2 - result.queries == ['ALTER SUBSCRIPTION {{ test_subscription }} OWNER TO "{{ test_role2 }}"'] - name: Check @@ -473,7 +473,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["CREATE SUBSCRIPTION test CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }}' PUBLICATION {{ test_pub }} WITH (enabled = false, synchronous_commit = false)"] - result.exists == true - result.final_state.enabled == false @@ -507,7 +507,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} ENABLE", "ALTER SUBSCRIPTION {{ test_subscription }} SET (synchronous_commit = true)"] - result.exists == true - result.final_state.enabled == true @@ -541,7 +541,7 @@ - assert: that: - result is not changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == [] - result.exists == true - result.final_state == result.initial_state @@ -601,7 +601,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.final_state.publications != result.initial_state.publications - result.final_state.publications == ['{{ test_pub }}', '{{ test_pub2 }}'] - result.queries == ['ALTER SUBSCRIPTION {{ test_subscription }} SET PUBLICATION {{ test_pub }}, {{ test_pub2 }}'] @@ -634,7 +634,7 @@ - assert: that: - result is not changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.final_state.publications == result.initial_state.publications - result.final_state.publications == ['{{ test_pub }}', '{{ test_pub2 }}'] - result.queries == [] @@ -676,7 +676,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}'"] - result.initial_state.conninfo == result.final_state.conninfo @@ -699,7 +699,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} CONNECTION 'host=127.0.0.1 port={{ primary_port }} user={{ replication_role }} password={{ replication_pass }} dbname={{ test_db }} connect_timeout={{ conn_timeout }}'"] - result.initial_state.conninfo != result.final_state.conninfo @@ -733,10 +733,10 @@ - assert: that: - result is not changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == [] - result.initial_state.conninfo == result.final_state.conninfo - - result.final_state.conninfo.connect_timeout == '{{ conn_timeout }}' + - result.final_state.conninfo.connect_timeout == conn_timeout #################### # Test state refresh @@ -754,7 +754,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} REFRESH PUBLICATION"] - name: Refresh @@ -768,7 +768,7 @@ - assert: that: - result is changed - - result.name == '{{ test_subscription }}' + - result.name == test_subscription - result.queries == ["ALTER SUBSCRIPTION {{ test_subscription }} REFRESH PUBLICATION"] ##########