|
12 | 12 | - 'src/' |
13 | 13 |
|
14 | 14 | jobs: |
15 | | - test: |
16 | | - name: interop |
| 15 | + interop: |
17 | 16 | runs-on: ubuntu-latest |
18 | 17 | services: |
19 | 18 | postgres: |
@@ -148,3 +147,105 @@ jobs: |
148 | 147 | - name: Dump rust keystone log |
149 | 148 | if: failure() |
150 | 149 | run: cat rust.log |
| 150 | + |
| 151 | + federation: |
| 152 | + runs-on: ubuntu-latest |
| 153 | + services: |
| 154 | + postgres: |
| 155 | + image: postgres:17 |
| 156 | + env: |
| 157 | + POSTGRES_USER: keystone |
| 158 | + POSTGRES_PASSWORD: '1234' |
| 159 | + ports: |
| 160 | + - 5432:5432 |
| 161 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 162 | + keycloak: |
| 163 | + image: ghcr.io/gtema/keycloak-ci-service:26.2 |
| 164 | + env: |
| 165 | + KC_BOOTSTRAP_ADMIN_USERNAME: admin |
| 166 | + KC_BOOTSTRAP_ADMIN_PASSWORD: password |
| 167 | + ports: |
| 168 | + - 8082:8080 |
| 169 | + command: start-dev |
| 170 | + steps: |
| 171 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 172 | + |
| 173 | + - name: Enable cache |
| 174 | + uses: actions/cache@v4 |
| 175 | + with: |
| 176 | + path: | |
| 177 | + ~/.cache/pip |
| 178 | + ~/.cargo |
| 179 | + key: ${{ runner.os }}-integration |
| 180 | + |
| 181 | + - name: Rust Cache |
| 182 | + uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 |
| 183 | + |
| 184 | + - uses: actions/setup-python@v5 |
| 185 | + with: |
| 186 | + python-version: '3.12' |
| 187 | + |
| 188 | + - name: Install Rust |
| 189 | + uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1 # stable |
| 190 | + with: |
| 191 | + toolchain: stable |
| 192 | + |
| 193 | + - name: Install sea-orm-cli |
| 194 | + run: cargo install sea-orm-cli@1.1.0 |
| 195 | + |
| 196 | + - name: Install necessary python packages |
| 197 | + run: pip install keystone uwsgi psycopg2 |
| 198 | + |
| 199 | + - name: Install osc |
| 200 | + run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/gtema/openstack/releases/latest/download/openstack_cli-installer.sh | sh |
| 201 | + |
| 202 | + - name: Prepare keystone config file |
| 203 | + run: | |
| 204 | + mkdir -p etc |
| 205 | + echo "[database]" >> etc/keystone.conf |
| 206 | + echo "connection = postgresql://keystone:1234@127.0.0.1:5432/keystone" >> etc/keystone.conf |
| 207 | + echo "[fernet_receipts]" >> etc/keystone.conf |
| 208 | + echo "key_repository = $(pwd)/etc/fernet" >> etc/keystone.conf |
| 209 | + echo "[fernet_tokens]" >> etc/keystone.conf |
| 210 | + echo "key_repository = $(pwd)/etc/fernet" >> etc/keystone.conf |
| 211 | + cat etc/keystone.conf |
| 212 | +
|
| 213 | + - name: Init keystone |
| 214 | + env: |
| 215 | + OS_KEYSTONE_CONFIG_DIR: ${{ github.workspace }}/etc |
| 216 | + run: | |
| 217 | + mkdir -p etc/fernet |
| 218 | + keystone-manage --config-file etc/keystone.conf db_sync |
| 219 | + keystone-manage --config-file etc/keystone.conf fernet_setup |
| 220 | + keystone-manage --config-file etc/keystone.conf bootstrap --bootstrap-password password |
| 221 | +
|
| 222 | + - name: Apply DB changes |
| 223 | + env: |
| 224 | + DATABASE_URL: postgresql://keystone:1234@127.0.0.1:5432/keystone |
| 225 | + run: sea-orm-cli migrate up |
| 226 | + |
| 227 | + - name: Create client in keycloak |
| 228 | + env: |
| 229 | + KEYCLOAK_URL: "http://localhost:8082" |
| 230 | + REALM_NAME: "master" |
| 231 | + ADMIN_USERNAME: "admin" |
| 232 | + ADMIN_PASSWORD: "password" |
| 233 | + TOKEN_ENDPOINT: "http://localhost:8082/realms/master/protocol/openid-connect/token" |
| 234 | + CLIENT_ID: "keystone" |
| 235 | + CLIENT_SECRET: "keystone-secret" |
| 236 | + run: | |
| 237 | + # Get the access token |
| 238 | + ACCESS_TOKEN=$(curl -s -X POST \ |
| 239 | + -d "client_id=admin-cli" \ |
| 240 | + -d "username=${ADMIN_USERNAME}" \ |
| 241 | + -d "password=${ADMIN_PASSWORD}" \ |
| 242 | + -d "grant_type=password" \ |
| 243 | + "${KEYCLOAK_URL}/realms/${REALM_NAME}/protocol/openid-connect/token" | jq -r '.access_token') # Using 'jq -r .access_token' to parse the JSON and get the raw token |
| 244 | +
|
| 245 | + if [ -z "$ACCESS_TOKEN" ]; then |
| 246 | + echo "Failed to obtain access token. Check your Keycloak URL, credentials, and realm." |
| 247 | + exit 1 |
| 248 | + fi |
| 249 | +
|
| 250 | + # Create the client |
| 251 | + curl "${KEYCLOAK_URL}/realms/${REALM_NAME}/clients" -H "Authorization: Bearer ${ACCESS_TOKEN}" -X POST -H "Content-Type: application/json" -d '{"clientId":"{CLIENT_ID}", "secret": "${CLIENT_SECRET}", "redirectUris": ["http://localhost:8050/*"], "enabled":true}' |
0 commit comments