Hung-Wei Chiu | 6a075af | 2021-09-09 22:33:06 +0000 | [diff] [blame] | 1 | --- |
| 2 | # keycloak molecule/default/verify.yml |
| 3 | # |
| 4 | # SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org> |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | - name: Verify |
| 8 | hosts: all |
| 9 | tasks: |
Hung-Wei Chiu | 718cd26 | 2021-09-13 18:20:21 +0000 | [diff] [blame^] | 10 | - name: "Create Token for service Keycloak" |
| 11 | uri: |
| 12 | url: http://localhost:8080/auth/realms/master/protocol/openid-connect/token |
| 13 | method: POST |
| 14 | body_format: form-urlencoded |
| 15 | body: |
| 16 | username: "{{ keycloak_admin_username }}" |
| 17 | password: "{{ keycloak_admin_password }}" |
| 18 | grant_type: "password" |
| 19 | client_id: "admin-cli" |
| 20 | register: keycloak_token |
| 21 | |
| 22 | - name: "Get Client List" |
| 23 | uri: |
| 24 | url: http://localhost:8080/auth/admin/realms/master/clients |
| 25 | method: GET |
| 26 | headers: |
| 27 | Accept: "application/json" |
| 28 | Authorization: "Bearer {{ keycloak_token.json.access_token }}" |
| 29 | register: keycloak_userlist |
| 30 | |
| 31 | - name: Check if the Keycloak client json output contains our client |
| 32 | set_fact: |
| 33 | find: true |
| 34 | with_items: "{{ keycloak_userlist.json }}" |
| 35 | when: item.name == keycloak_client_settings[0].name |
| 36 | |
| 37 | - name: Fail if our client isn't installed correctly |
| 38 | assert: |
| 39 | that: |
| 40 | - find is defined |