Skip to content

Commit 2c827d7

Browse files
Merge pull request #1437 from openshift-cherrypick-robot/cherry-pick-1418-to-18.0-fr6
[18.0-fr6] Test OIDC after adoption
2 parents b94775b + 40d38f3 commit 2c827d7

1 file changed

Lines changed: 31 additions & 13 deletions

File tree

tests/roles/keystone_adoption/tasks/main.yaml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,42 @@
194194
fi
195195
register: adoption_token_result
196196

197-
- name: Verify that pre-adoption OIDC token still works
197+
- name: Verify that OIDC federation still works
198198
when:
199199
- enable_federation | default(false) | bool
200-
- before_adoption_oidc_token is defined
201-
- before_adoption_oidc_token.stdout is defined
202-
ansible.builtin.shell:
203-
cmd: |
204-
{{ shell_header }}
205-
{{ oc_header }}
206-
207-
alias openstack="oc exec -t openstackclient -- env -u OS_CLOUD - OS_AUTH_URL={{ auth_url }} OS_AUTH_TYPE=v3oidcaccesstoken OS_ACCESS_TOKEN={{ before_adoption_oidc_token.stdout }} openstack"
208-
209-
${BASH_ALIASES[openstack]} token issue -f json
210-
register: adoption_oidc_token_result
200+
block:
201+
- name: Generate OIDC token after adoption
202+
ansible.builtin.shell: |
203+
{{ shell_header }}
204+
{{ oc_header }}
205+
206+
oc exec openstackclient -- bash -c "cat > /tmp/oidc_cloudrc" <<'EOF'
207+
unset OS_CLOUD
208+
export OS_CACERT=/home/cloud-admin/full-ca-list.crt
209+
export OS_PROJECT_NAME="{{ cifmw_federation_project_name }}"
210+
export OS_PROJECT_DOMAIN_NAME="{{ cifmw_federation_domain }}"
211+
export OS_AUTH_URL="{{ cifmw_federation_keystone_url }}/v3"
212+
export OS_IDENTITY_API_VERSION=3
213+
export OS_AUTH_PLUGIN=openid
214+
export OS_AUTH_TYPE=v3oidcpassword
215+
export OS_USERNAME="{{ cifmw_federation_keycloak_testuser1_username }}"
216+
export OS_PASSWORD="{{ cifmw_federation_keycloak_testuser1_password }}"
217+
export OS_IDENTITY_PROVIDER="{{ cifmw_federation_idp_name }}"
218+
export OS_CLIENT_ID="{{ cifmw_federation_keycloak_client_id }}"
219+
export OS_CLIENT_SECRET="{{ cifmw_federation_keycloak_client_secret }}"
220+
export OS_OPENID_SCOPE="openid profile email"
221+
export OS_PROTOCOL=openid
222+
export OS_ACCESS_TOKEN_TYPE=access_token
223+
export OS_DISCOVERY_ENDPOINT="{{ cifmw_federation_keycloak_url }}/auth/realms/{{ cifmw_federation_keycloak_realm }}/.well-known/openid-configuration"
224+
EOF
225+
226+
oc exec openstackclient -- bash -c "source /tmp/oidc_cloudrc && openstack token issue -f value -c id"
227+
register: oidc_token
228+
failed_when: oidc_token.rc != 0 or oidc_token.stdout == ""
211229

212230
- name: Print credentials test token
213231
ansible.builtin.debug:
214-
var: before_adoption_token
232+
var: oidc_token
215233

216234
- name: Verify that pre-adoption credential stills the same
217235
ansible.builtin.shell: |

0 commit comments

Comments
 (0)