Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/mq/tasks/broker_user_tests.yml

raw
1 - name: set test data
2 set_fact:
3 usernames:
4 - "test_user1"
5 - "test_user2"
6 - "test_user3"
7
8 - name: test1 - create user with default settings
9 mq_user:
10 broker_id: "{{ broker_id }}"
11 username: "{{ usernames[0] }}"
12 register: result
13 - name: test1 - verify
14 assert:
15 fail_msg: test1 failed
16 that:
17 - result.changed | bool
18 - result.user['username'] == usernames[0]
19 - not (result.user['pending']['console_access'] | bool)
20 - result.user['pending']['groups'] | length == 0
21 when: not ansible_check_mode
22 - name: test2 - create user with console access and group list
23 mq_user:
24 state: present
25 broker_id: "{{ broker_id }}"
26 username: "{{ usernames[1] }}"
27 console_access: true
28 groups: [ "g1", "g2" ]
29 register: result
30 - name: test2 - verify
31 assert:
32 fail_msg: test2 failed
33 that:
34 - result.changed | bool
35 - result.user['username'] == usernames[1]
36 - result.user['pending']['console_access'] | bool
37 - result.user['pending']['groups'] | length == 2
38 when: not ansible_check_mode
39 - name: test3 - create user with defined password
40 mq_user:
41 broker_id: "{{ broker_id }}"
42 username: "{{ usernames[2] }}"
43 password: "09234092jzxkjvjk23kn23qn5lk34"
44 register: result
45 - name: test3 - verify
46 assert:
47 fail_msg: test3 failed
48 that:
49 - result.changed | bool
50 - result.user['username'] == usernames[2]
51 - not (result.user['pending']['console_access'] | bool)
52 - result.user['pending']['groups'] | length == 0
53 when: not ansible_check_mode
54 - name: test4 - update user password - ignore mode
55 mq_user:
56 broker_id: "{{ broker_id }}"
57 username: "{{ usernames[2] }}"
58 password: "new_password_ignored"
59 register: result
60 - name: test4 - verify
61 assert:
62 fail_msg: test4 failed
63 that:
64 - not (result.changed | bool)
65 when: not ansible_check_mode
66 - name: test5 - update user password - force mode
67 mq_user:
68 broker_id: "{{ broker_id }}"
69 username: "{{ usernames[2] }}"
70 password: "new_Password_Accepted0815%"
71 allow_pw_update: true
72 register: result
73 - name: test5 - verify
74 assert:
75 fail_msg: test5 failed
76 that:
77 - result.changed | bool
78 when: not ansible_check_mode
79 - name: test6 - update console access - same value
80 mq_user:
81 broker_id: "{{ broker_id }}"
82 username: "{{ usernames[2] }}"
83 console_access: false
84 register: result
85 - name: test6 - verify
86 assert:
87 fail_msg: test6 failed
88 that:
89 - not (result.changed | bool)
90 when: not ansible_check_mode
91 - name: test7 - update console access - new value
92 mq_user:
93 broker_id: "{{ broker_id }}"
94 username: "{{ usernames[1] }}"
95 console_access: false
96 register: result
97 - name: test7 - verify
98 assert:
99 fail_msg: test7 failed
100 that:
101 - result.changed | bool
102 - not( result.user['pending']['console_access'] | bool )
103 - result.user['pending']['groups'] | length == 2
104 when: not ansible_check_mode
105 - name: test8 - update group list - same list but different order
106 mq_user:
107 broker_id: "{{ broker_id }}"
108 username: "{{ usernames[1] }}"
109 groups: [ "g2", "g1" ]
110 register: result
111 - name: test8 - verify
112 assert:
113 fail_msg: test8 failed
114 that:
115 - not (result.changed | bool)
116 when: not ansible_check_mode
117 - name: test9 - update group list - add element
118 mq_user:
119 broker_id: "{{ broker_id }}"
120 username: "{{ usernames[1] }}"
121 groups: [ "g2", "g1", "g3" ]
122 register: result
123 - name: test9 - verify
124 assert:
125 fail_msg: test9 failed
126 that:
127 - result.changed | bool
128 - result.user['pending']['groups'] | length == 3
129 when: not ansible_check_mode
130 - name: test10 - update group list - remove element
131 mq_user:
132 broker_id: "{{ broker_id }}"
133 username: "{{ usernames[1] }}"
134 groups: [ "g2", "g3" ]
135 register: result
136 - name: test10 - verify
137 assert:
138 fail_msg: test10 failed
139 that:
140 - result.changed | bool
141 - result.user['pending']['groups'] | length == 2
142 when: not ansible_check_mode
143 - name: test11 - update group list - set to empty list
144 mq_user:
145 broker_id: "{{ broker_id }}"
146 username: "{{ usernames[1] }}"
147 groups: []
148 register: result
149 - name: test11 - verify
150 assert:
151 fail_msg: test11 failed
152 that:
153 - result.changed | bool
154 - result.user['pending']['groups'] | length == 0
155 when: not ansible_check_mode
156 - name: delete all users
157 mq_user:
158 state: absent
159 broker_id: "{{ broker_id }}"
160 username: "{{ item }}"
161 loop: "{{ usernames | flatten(levels=1) }}"
162 - name: test13 - delete deleted user
163 mq_user:
164 state: absent
165 broker_id: "{{ broker_id }}"
166 username: "{{ usernames[1] }}"
167 register: result
168 - name: test13 - verify
169 assert:
170 fail_msg: test13 failed
171 that:
172 - not(result.changed | bool)
173 when: not ansible_check_mode