Run Cypress tests on Keycloak theme (#925)

This commit is contained in:
Jon Koops 2021-07-30 20:12:32 +02:00 committed by GitHub
parent fa93d57fa5
commit 2c80bf597e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 43 deletions

View file

@ -1,42 +1,39 @@
name: Cypress run name: Cypress
on: on:
push: push:
branches: [ master ] branches: [master]
pull_request: pull_request:
branches: [ master ] branches: [master]
jobs: jobs:
cypress-run: cypress-run:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
- name: Build Keycloak server
run: docker build --tag keycloak .
- name: Start Keycloak server
run: |
docker run --detach --publish 8080:8080 --env KEYCLOAK_USER=admin --env KEYCLOAK_PASSWORD=admin --name keycloak keycloak
sleep 10
- name: Configure Keycloak server
run: |
docker exec keycloak /opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin
docker exec keycloak /opt/jboss/keycloak/bin/kcadm.sh update realms/master -s "adminTheme=keycloak.v2"
- name: Setup Node
uses: actions/setup-node@v2 uses: actions/setup-node@v2
with: with:
node-version: ${{ matrix.node-version }} node-version: 16
check-latest: true check-latest: true
- run: npm ci - name: Install dependencies
- run: npm run build run: npm ci
- name: Run Keycloak - name: Run Cypress
run: ./start.mjs & sleep 40 run: CYPRESS_BASE_URL=http://localhost:8080/auth/admin/ CYPRESS_KEYCLOAK_SERVER=http://localhost:8080 npm run start:cypress-tests
- name: Run Admin Console
run: npx http-server ./build -P http://localhost:8180/ & sleep 30
- name: Admin Console client
run: ./import.mjs
- name: Cypress run
run: npm run start:cypress-tests
- name: Add Cypress videos artifacts - name: Add Cypress videos artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2

View file

@ -97,12 +97,13 @@ describe("Identity provider test", () => {
it("should create a oidc provider using discovery url", () => { it("should create a oidc provider using discovery url", () => {
const oidcProviderName = "oidc"; const oidcProviderName = "oidc";
const keycloakServer = Cypress.env("KEYCLOAK_SERVER");
createProviderPage createProviderPage
.clickCreateDropdown() .clickCreateDropdown()
.clickItem(oidcProviderName) .clickItem(oidcProviderName)
.fillDiscoveryUrl( .fillDiscoveryUrl(
"http://localhost:8180/auth/realms/master/.well-known/openid-configuration" `${keycloakServer}/auth/realms/master/.well-known/openid-configuration`
) )
.shouldBeSuccessful() .shouldBeSuccessful()
.fill("oidc", "123") .fill("oidc", "123")
@ -112,7 +113,7 @@ describe("Identity provider test", () => {
); );
createProviderPage.shouldHaveAuthorizationUrl( createProviderPage.shouldHaveAuthorizationUrl(
"http://localhost:8180/auth/realms/master/protocol/openid-connect/auth" `${keycloakServer}/auth/realms/master/protocol/openid-connect/auth`
); );
}); });

View file

@ -14,7 +14,12 @@
// *********************************************************** // ***********************************************************
// Import commands.js using ES2015 syntax: // Import commands.js using ES2015 syntax:
import './commands' import "./commands";
// Alternatively you can use CommonJS syntax: // Alternatively you can use CommonJS syntax:
// require('./commands') // require('./commands')
// Set Keycloak server to development path if not set.
if (!Cypress.env("KEYCLOAK_SERVER")) {
Cypress.env("KEYCLOAK_SERVER", "http://localhost:8180");
}

View file

@ -6,7 +6,7 @@ export default class AdminClient {
private client: KeycloakAdminClient; private client: KeycloakAdminClient;
constructor() { constructor() {
this.client = new KeycloakAdminClient({ this.client = new KeycloakAdminClient({
baseUrl: "http://localhost:8180/auth", baseUrl: `${Cypress.env("KEYCLOAK_SERVER")}/auth`,
realmName: "master", realmName: "master",
}); });
} }