From d5f38270b79b7bd8c00cf43b937921ef3d14333f Mon Sep 17 00:00:00 2001 From: Sophia Castellarin Date: Fri, 24 Jan 2025 12:23:37 -0800 Subject: [PATCH] Get conda-store token from login --- .github/workflows/test_local_integration.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_local_integration.yaml b/.github/workflows/test_local_integration.yaml index 786ea8b44..df1872a1b 100644 --- a/.github/workflows/test_local_integration.yaml +++ b/.github/workflows/test_local_integration.yaml @@ -172,12 +172,17 @@ jobs: # install conda-store-server python -m pip install conda-store/conda-store-server - - name: Get conda-store token from terraform state + - name: Get conda-store token id: conda-store-token + env: + KEYCLOAK_USERNAME: ${{ env.TEST_USERNAME }} + KEYCLOAK_PASSWORD: ${{ env.TEST_PASSWORD }} + CONDA_STORE_BASE_URL: https://${{ steps.init.outputs.domain }} working-directory: ${{ steps.init.outputs.directory }} run: | - kubectl get secret -n default tfstate-default-${{ steps.init.outputs.project }}-dev-07-kubernetes-services --template={{.data}} | cut -d ":" -f2 | cut -d "]" -f1 | base64 --decode | gzip -d --to-stdout > terraform_state - echo "CONDA_STORE_TOKEN=$(cat terraform_state | jq | grep conda-store-service-account | sed -n '2 p' | tr -s ' ' | sed "s/\"config.json\": \"//" | sed -e 's/\\\"/\"/g' -e 's/^.//g' -e 's/.$//g' | jq --raw-output '."service-tokens-mapping"."conda-store-service-account"')" | tee --append "${GITHUB_OUTPUT}" + LOGIN_URL=$(curl -c /tmp/nebari-session --insecure -Ls ${CONDA_STORE_BASE_URL}/conda-store/login/\?next= | grep auth/realms/nebari/login-actions/authenticate | grep -oP 'action="([^"]+)"') + curl -X POST --insecure -b /tmp/nebari-session -H "Content-Type: application/x-www-form-urlencoded" -vv --data '{"credentialId":"", "username": "${KEYCLOAK_USERNAME}", "password": "${KEYCLOAK_PASSWORD}"}' $LOGIN_URL + echo "CONDA_STORE_TOKEN=$(curl --insecure -L -X POST -b /tmp/conda-store-cookie ${CONDA_STORE_BASE_URL}/conda-store/api/v1/token | jq --raw-output .data.token)" >> "$GITHUB_OUTPUT" - name: Run conda-store-server user_journey tests env: