|
| 1 | +--- |
| 2 | +- name: pre-setup |
| 3 | + ngine_io.cloudstack.role: |
| 4 | + name: "testRole" |
| 5 | + register: testRole |
| 6 | +- name: verify pre-setup |
| 7 | + assert: |
| 8 | + that: |
| 9 | + - testRole is successful |
| 10 | + |
| 11 | +- name: setup |
| 12 | + ngine_io.cloudstack.role_permission: |
| 13 | + name: "fakeRolePerm" |
| 14 | + role: "{{ testRole.id }}" |
| 15 | + state: absent |
| 16 | + register: roleperm |
| 17 | +- name: verify setup |
| 18 | + assert: |
| 19 | + that: |
| 20 | + |
| 21 | +- name: setup2 |
| 22 | + ngine_io.cloudstack.role_permission: |
| 23 | + name: "fakeRolePerm2" |
| 24 | + role: "{{ testRole.id }}" |
| 25 | + state: absent |
| 26 | + register: roleperm2 |
| 27 | +- name: verify setup2 |
| 28 | + assert: |
| 29 | + that: |
| 30 | + - roleperm2 is successful |
| 31 | + |
| 32 | +- name: test fail if missing name |
| 33 | + ngine_io.cloudstack.role_permission: |
| 34 | + role: "{{ testRole.id }}" |
| 35 | + register: roleperm |
| 36 | + ignore_errors: true |
| 37 | +- name: verify results of fail if missing name |
| 38 | + assert: |
| 39 | + that: |
| 40 | + - roleperm is failed |
| 41 | + - 'roleperm.msg == "missing required arguments: name"' |
| 42 | + |
| 43 | +- name: test fail if missing role |
| 44 | + ngine_io.cloudstack.role_permission: |
| 45 | + name: "fakeRolePerm" |
| 46 | + register: roleperm |
| 47 | + ignore_errors: true |
| 48 | +- name: verify results of fail if missing role |
| 49 | + assert: |
| 50 | + that: |
| 51 | + - roleperm is failed |
| 52 | + - 'roleperm.msg == "missing required arguments: role"' |
| 53 | + |
| 54 | +- name: test fail if role does not exist |
| 55 | + ngine_io.cloudstack.role_permission: |
| 56 | + name: "fakeRolePerm" |
| 57 | + role: "testtest" |
| 58 | + register: roleperm |
| 59 | + ignore_errors: true |
| 60 | +- name: verify results of fail if role does not exist |
| 61 | + assert: |
| 62 | + that: |
| 63 | + - roleperm is failed |
| 64 | + - roleperm.msg == "Role 'testtest' not found" |
| 65 | + |
| 66 | +- name: test fail if state is incorrcect |
| 67 | + ngine_io.cloudstack.role_permission: |
| 68 | + state: badstate |
| 69 | + role: "{{ testRole.id }}" |
| 70 | + name: "fakeRolePerm" |
| 71 | + permission: allow |
| 72 | + register: roleperm |
| 73 | + ignore_errors: true |
| 74 | +- name: verify results of fail if state is incorrcect |
| 75 | + assert: |
| 76 | + that: |
| 77 | + - roleperm is failed |
| 78 | + - 'roleperm.msg == "value of state must be one of: present, absent, got: badstate"' |
| 79 | + |
| 80 | +- name: test create role permission in check mode |
| 81 | + ngine_io.cloudstack.role_permission: |
| 82 | + role: "{{ testRole.id }}" |
| 83 | + name: "fakeRolePerm" |
| 84 | + permission: allow |
| 85 | + description: "fakeRolePerm description" |
| 86 | + register: roleperm |
| 87 | + check_mode: yes |
| 88 | +- name: verify results of role permission in check mode |
| 89 | + assert: |
| 90 | + that: |
| 91 | + - roleperm is changed |
| 92 | + |
| 93 | +- name: test create role permission |
| 94 | + ngine_io.cloudstack.role_permission: |
| 95 | + role: "{{ testRole.id }}" |
| 96 | + name: "fakeRolePerm" |
| 97 | + permission: allow |
| 98 | + description: "fakeRolePerm description" |
| 99 | + register: roleperm |
| 100 | +- name: verify results of role permission |
| 101 | + assert: |
| 102 | + that: |
| 103 | + - roleperm is changed |
| 104 | + - roleperm.name == "fakeRolePerm" |
| 105 | + - roleperm.permission == "allow" |
| 106 | + - roleperm.description == "fakeRolePerm description" |
| 107 | + |
| 108 | +- name: test create role permission idempotency |
| 109 | + ngine_io.cloudstack.role_permission: |
| 110 | + role: "{{ testRole.id }}" |
| 111 | + name: "fakeRolePerm" |
| 112 | + permission: allow |
| 113 | + description: "fakeRolePerm description" |
| 114 | + register: roleperm |
| 115 | +- name: verify results of role permission idempotency |
| 116 | + assert: |
| 117 | + that: |
| 118 | + - roleperm is not changed |
| 119 | + - roleperm.name == "fakeRolePerm" |
| 120 | + - roleperm.permission == "allow" |
| 121 | + - roleperm.description == "fakeRolePerm description" |
| 122 | + |
| 123 | +- name: test update role permission in check_mode |
| 124 | + ngine_io.cloudstack.role_permission: |
| 125 | + role: "{{ testRole.id }}" |
| 126 | + name: "fakeRolePerm" |
| 127 | + permission: deny |
| 128 | + description: "fakeRolePerm description" |
| 129 | + register: roleperm |
| 130 | + check_mode: yes |
| 131 | +- name: verify results of update role permission in check mode |
| 132 | + assert: |
| 133 | + that: |
| 134 | + - roleperm is changed |
| 135 | + - roleperm.name == "fakeRolePerm" |
| 136 | + - roleperm.permission == "allow" |
| 137 | + - roleperm.description == "fakeRolePerm description" |
| 138 | + |
| 139 | +- name: test update role permission |
| 140 | + ngine_io.cloudstack.role_permission: |
| 141 | + role: "{{ testRole.id }}" |
| 142 | + name: "fakeRolePerm" |
| 143 | + permission: deny |
| 144 | + description: "fakeRolePerm description" |
| 145 | + register: roleperm |
| 146 | +- name: verify results of update role permission |
| 147 | + assert: |
| 148 | + that: |
| 149 | + - roleperm is changed |
| 150 | + - roleperm.name == "fakeRolePerm" |
| 151 | + - roleperm.permission == "deny" |
| 152 | + - roleperm.description == "fakeRolePerm description" |
| 153 | + |
| 154 | +- name: test update role permission idempotency |
| 155 | + ngine_io.cloudstack.role_permission: |
| 156 | + role: "{{ testRole.id }}" |
| 157 | + name: "fakeRolePerm" |
| 158 | + permission: deny |
| 159 | + description: "fakeRolePerm description" |
| 160 | + register: roleperm |
| 161 | +- name: verify results of update role permission idempotency |
| 162 | + assert: |
| 163 | + that: |
| 164 | + - roleperm is not changed |
| 165 | + - roleperm.name == "fakeRolePerm" |
| 166 | + - roleperm.permission == "deny" |
| 167 | + - roleperm.description == "fakeRolePerm description" |
| 168 | + |
| 169 | +- name: test create a second role permission |
| 170 | + ngine_io.cloudstack.role_permission: |
| 171 | + role: "{{ testRole.id }}" |
| 172 | + name: "fakeRolePerm2" |
| 173 | + permission: allow |
| 174 | + register: roleperm2 |
| 175 | +- name: verify results of create a second role permission |
| 176 | + assert: |
| 177 | + that: |
| 178 | + - roleperm2 is successful |
| 179 | + - roleperm2 is changed |
| 180 | + - roleperm2.name == "fakeRolePerm2" |
| 181 | + |
| 182 | +- name: test update rules order in check_mode |
| 183 | + ngine_io.cloudstack.role_permission: |
| 184 | + role: "{{ testRole.id }}" |
| 185 | + name: "fakeRolePerm" |
| 186 | + parent: "{{ roleperm2.id }}" |
| 187 | + register: roleperm |
| 188 | + check_mode: true |
| 189 | +- name: verify results of update rule order check mode |
| 190 | + assert: |
| 191 | + that: |
| 192 | + - roleperm is changed |
| 193 | + - roleperm.name == "fakeRolePerm" |
| 194 | + |
| 195 | +- name: test update rules order |
| 196 | + ngine_io.cloudstack.role_permission: |
| 197 | + role: "{{ testRole.id }}" |
| 198 | + name: "fakeRolePerm" |
| 199 | + parent: "{{ roleperm2.id }}" |
| 200 | + register: roleperm |
| 201 | +- name: verify results of update rule order |
| 202 | + assert: |
| 203 | + that: |
| 204 | + - roleperm is changed |
| 205 | + - roleperm.name == "fakeRolePerm" |
| 206 | + |
| 207 | +- name: test update rules order to the top of the list |
| 208 | + ngine_io.cloudstack.role_permission: |
| 209 | + role: "{{ testRole.id }}" |
| 210 | + name: "fakeRolePerm" |
| 211 | + parent: 0 |
| 212 | + register: roleperm |
| 213 | +- name: verify results of update rule order to the top of the list |
| 214 | + assert: |
| 215 | + that: |
| 216 | + - roleperm is changed |
| 217 | + - roleperm.name == "fakeRolePerm" |
| 218 | + |
| 219 | +- name: test update rules order with parent NAME |
| 220 | + ngine_io.cloudstack.role_permission: |
| 221 | + role: "{{ testRole.id }}" |
| 222 | + name: "fakeRolePerm" |
| 223 | + parent: "{{ roleperm2.name }}" |
| 224 | + register: roleperm |
| 225 | +- name: verify results of update rule order with parent NAME |
| 226 | + assert: |
| 227 | + that: |
| 228 | + - roleperm is changed |
| 229 | + - roleperm.name == "fakeRolePerm" |
| 230 | + |
| 231 | +- name: test fail if permission AND parent args are present |
| 232 | + ngine_io.cloudstack.role_permission: |
| 233 | + role: "{{ testRole.id }}" |
| 234 | + name: "fakeRolePerm" |
| 235 | + permission: allow |
| 236 | + parent: 0 |
| 237 | + register: roleperm |
| 238 | + ignore_errors: true |
| 239 | +- name: verify results of fail if permission AND parent args are present |
| 240 | + assert: |
| 241 | + that: |
| 242 | + - roleperm is failed |
| 243 | + - 'roleperm.msg == "parameters are mutually exclusive: permission|parent"' |
| 244 | + |
| 245 | +- name: test fail if parent does not exist |
| 246 | + ngine_io.cloudstack.role_permission: |
| 247 | + role: "{{ testRole.id }}" |
| 248 | + name: "fakeRolePerm" |
| 249 | + parent: "badParent" |
| 250 | + register: roleperm |
| 251 | + ignore_errors: true |
| 252 | +- name: verify results of fail if parent does not exist |
| 253 | + assert: |
| 254 | + that: |
| 255 | + - roleperm is failed |
| 256 | + - roleperm.msg == "Parent rule 'badParent' not found" |
| 257 | + |
| 258 | +- name: test remove role permission in check_mode |
| 259 | + ngine_io.cloudstack.role_permission: |
| 260 | + role: "{{ testRole.id }}" |
| 261 | + name: "fakeRolePerm" |
| 262 | + state: absent |
| 263 | + register: roleperm |
| 264 | + check_mode: true |
| 265 | +- name: verify results of rename role permission in check_mode |
| 266 | + assert: |
| 267 | + that: |
| 268 | + - roleperm is changed |
| 269 | + |
| 270 | +- name: test remove role permission |
| 271 | + ngine_io.cloudstack.role_permission: |
| 272 | + role: "{{ testRole.id }}" |
| 273 | + name: "fakeRolePerm" |
| 274 | + state: absent |
| 275 | + register: roleperm |
| 276 | +- name: verify results of remove role permission |
| 277 | + assert: |
| 278 | + that: |
| 279 | + - roleperm is changed |
| 280 | + |
| 281 | +- name: remove second role permission |
| 282 | + ngine_io.cloudstack.role_permission: |
| 283 | + role: "{{ testRole.id }}" |
| 284 | + name: "fakeRolePerm2" |
| 285 | + state: absent |
| 286 | + register: roleperm |
| 287 | +- name: verify results of remove second role permission |
| 288 | + assert: |
| 289 | + that: |
| 290 | + - roleperm is changed |
0 commit comments