mirror of
https://github.com/ansible-middleware/keycloak.git
synced 2026-11-21 14:48:50 +00:00
AMW-653 Add quarkus_flags molecule scenario for untested flag toggles
This commit is contained in:
@@ -34,4 +34,4 @@ jobs:
|
|||||||
root_permission_varname: 'keycloak_install_requires_become'
|
root_permission_varname: 'keycloak_install_requires_become'
|
||||||
debug_verbosity: "${{ github.event.inputs.debug_verbosity }}"
|
debug_verbosity: "${{ github.event.inputs.debug_verbosity }}"
|
||||||
molecule_tests: >-
|
molecule_tests: >-
|
||||||
[ "sso_test", "quarkus", "quarkus_ha", "quarkus_ha_remote", "quarkus_ha_26.4_below", "default", "quarkus_devmode", "quarkus_upgrade", "keycloak_modules", "quarkus_relpath", "quarkus_nohost" ]
|
[ "sso_test", "quarkus", "quarkus_ha", "quarkus_ha_remote", "quarkus_ha_26.4_below", "default", "quarkus_devmode", "quarkus_upgrade", "keycloak_modules", "quarkus_relpath", "quarkus_nohost", "quarkus_flags" ]
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
keycloak_quarkus_proxy_mode: none
|
keycloak_quarkus_proxy_mode: none
|
||||||
keycloak_quarkus_java_home: /opt/openjdk/
|
keycloak_quarkus_java_home: /opt/openjdk/
|
||||||
keycloak_quarkus_java_heap_opts: "-Xms640m -Xmx640m"
|
keycloak_quarkus_java_heap_opts: "-Xms640m -Xmx640m"
|
||||||
|
keycloak_realm_client_public: false
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: keycloak_quarkus
|
- role: keycloak_quarkus
|
||||||
|
|||||||
@@ -19,6 +19,35 @@
|
|||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
|
- name: Verify token api call
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://localhost:8080/realms/master/protocol/openid-connect/token"
|
||||||
|
method: POST
|
||||||
|
body: "client_id=admin-cli&username=remembertochangeme&password=remembertochangeme&grant_type=password"
|
||||||
|
validate_certs: false
|
||||||
|
register: keycloak_auth_response
|
||||||
|
until: keycloak_auth_response.status == 200
|
||||||
|
retries: 2
|
||||||
|
delay: 2
|
||||||
|
|
||||||
|
- name: Get clients in TestRealm
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://localhost:8080/admin/realms/TestRealm/clients"
|
||||||
|
validate_certs: false
|
||||||
|
headers:
|
||||||
|
Authorization: "Bearer {{ keycloak_auth_response.json.access_token }}"
|
||||||
|
register: keycloak_clients
|
||||||
|
|
||||||
|
- name: Get TestClient details
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
test_client: "{{ (keycloak_clients.json | selectattr('clientId', '==', 'TestClient')) | first }}"
|
||||||
|
|
||||||
|
- name: Assert TestClient is confidential (not public)
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- test_client.publicClient == false
|
||||||
|
fail_msg: "TestClient should be confidential (publicClient=false) but got publicClient={{ test_client.publicClient }}"
|
||||||
|
|
||||||
- name: Set internal envvar
|
- name: Set internal envvar
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
hera_home: "{{ lookup('env', 'HERA_HOME') }}"
|
hera_home: "{{ lookup('env', 'HERA_HOME') }}"
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars_files:
|
||||||
|
- ../group_vars/all/vars.yml
|
||||||
|
vars:
|
||||||
|
keycloak_quarkus_show_deprecation_warnings: false
|
||||||
|
keycloak_quarkus_bootstrap_admin_password: "remembertochangeme"
|
||||||
|
keycloak_quarkus_bootstrap_admin_user: "remembertochangeme"
|
||||||
|
keycloak_quarkus_hostname: "http://localhost:8080"
|
||||||
|
keycloak_quarkus_log: file
|
||||||
|
keycloak_quarkus_start_dev: true
|
||||||
|
keycloak_quarkus_proxy_mode: none
|
||||||
|
keycloak_quarkus_offline_install: true
|
||||||
|
keycloak_quarkus_download_path: /tmp/keycloak/
|
||||||
|
keycloak_quarkus_java_heap_opts: "-Xms640m -Xmx640m"
|
||||||
|
keycloak_quarkus_metrics_enabled: true
|
||||||
|
keycloak_quarkus_transaction_xa_enabled: false
|
||||||
|
keycloak_quarkus_spi_sticky_session_encoder_infinispan_should_attach_route: false
|
||||||
|
keycloak_quarkus_java_opts_use_keycloak_defaults: false
|
||||||
|
keycloak_quarkus_validate_certs: false
|
||||||
|
keycloak_quarkus_health_enabled: false
|
||||||
|
keycloak_quarkus_restart_health_check: false
|
||||||
|
keycloak_quarkus_hostname_backchannel_dynamic: true
|
||||||
|
roles:
|
||||||
|
- role: keycloak_quarkus
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: instance
|
||||||
|
image: registry.access.redhat.com/ubi9/ubi-init:latest
|
||||||
|
pre_build_image: true
|
||||||
|
privileged: true
|
||||||
|
command: "/usr/sbin/init"
|
||||||
|
exposed_ports:
|
||||||
|
- "8080/tcp"
|
||||||
|
- "8443/tcp"
|
||||||
|
- "8009/tcp"
|
||||||
|
- "9000/tcp"
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
interpreter_python: auto_silent
|
||||||
|
ssh_connection:
|
||||||
|
pipelining: false
|
||||||
|
playbooks:
|
||||||
|
prepare: ../default/prepare.yml
|
||||||
|
inventory:
|
||||||
|
host_vars:
|
||||||
|
localhost:
|
||||||
|
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||||
|
env:
|
||||||
|
ANSIBLE_FORCE_COLOR: "true"
|
||||||
|
PROXY: "${PROXY}"
|
||||||
|
NO_PROXY: "${NO_PROXY}"
|
||||||
|
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
test_sequence:
|
||||||
|
- cleanup
|
||||||
|
- destroy
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
- side_effect
|
||||||
|
- verify
|
||||||
|
- cleanup
|
||||||
|
- destroy
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Populate service facts
|
||||||
|
ansible.builtin.service_facts:
|
||||||
|
|
||||||
|
- name: Check if keycloak service started
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts.services["keycloak.service"]["state"] == "running"
|
||||||
|
- ansible_facts.services["keycloak.service"]["status"] == "enabled"
|
||||||
|
|
||||||
|
- name: Read keycloak.conf
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: /opt/keycloak/keycloak-26.7.3/conf/keycloak.conf
|
||||||
|
register: keycloak_conf
|
||||||
|
|
||||||
|
- name: Verify toggled flags in keycloak.conf
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'metrics-enabled=true' in keycloak_conf_content"
|
||||||
|
- "'transaction-xa-enabled=false' in keycloak_conf_content"
|
||||||
|
- "'spi-sticky-session-encoder-infinispan-should-attach-route=false' in keycloak_conf_content"
|
||||||
|
- "'health-enabled=false' in keycloak_conf_content"
|
||||||
|
- "'hostname-backchannel-dynamic=true' in keycloak_conf_content"
|
||||||
|
vars:
|
||||||
|
keycloak_conf_content: "{{ keycloak_conf.content | b64decode }}"
|
||||||
|
|
||||||
|
- name: Read sysconfig
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: /etc/sysconfig/keycloak
|
||||||
|
register: keycloak_sysconfig
|
||||||
|
|
||||||
|
- name: Verify JAVA_OPTS is used instead of JAVA_OPTS_KC_HEAP
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'JAVA_OPTS=' in keycloak_sysconfig_content"
|
||||||
|
- "'JAVA_OPTS_KC_HEAP' not in keycloak_sysconfig_content"
|
||||||
|
vars:
|
||||||
|
keycloak_sysconfig_content: "{{ keycloak_sysconfig.content | b64decode }}"
|
||||||
|
|
||||||
|
- name: Fetch metrics endpoint
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://localhost:9000/metrics"
|
||||||
|
method: GET
|
||||||
|
validate_certs: false
|
||||||
|
register: metrics_response
|
||||||
|
until: metrics_response.status == 200
|
||||||
|
retries: 5
|
||||||
|
delay: 5
|
||||||
|
|
||||||
|
- name: Assert metrics endpoint is reachable
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- metrics_response.status == 200
|
||||||
|
fail_msg: "Metrics endpoint should be enabled but returned {{ metrics_response.status }}"
|
||||||
|
|
||||||
|
- name: Fetch health endpoint
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://localhost:9000/health"
|
||||||
|
method: GET
|
||||||
|
validate_certs: false
|
||||||
|
status_code: [200, 404]
|
||||||
|
register: health_response
|
||||||
|
|
||||||
|
- name: Assert health endpoint is disabled
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- health_response.status == 404
|
||||||
|
fail_msg: "Health endpoint should be disabled (404) but returned {{ health_response.status }}"
|
||||||
Reference in New Issue
Block a user