Run Cypress tests on Keycloak theme (#925)
This commit is contained in:
parent
fa93d57fa5
commit
2c80bf597e
4 changed files with 46 additions and 43 deletions
75
.github/workflows/cypress.yml
vendored
75
.github/workflows/cypress.yml
vendored
|
@ -1,53 +1,50 @@
|
||||||
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 }}
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- run: npm ci
|
- name: Build Keycloak server
|
||||||
- run: npm run build
|
run: docker build --tag keycloak .
|
||||||
|
|
||||||
- name: Run Keycloak
|
- name: Start Keycloak server
|
||||||
run: ./start.mjs & sleep 40
|
run: |
|
||||||
|
docker run --detach --publish 8080:8080 --env KEYCLOAK_USER=admin --env KEYCLOAK_PASSWORD=admin --name keycloak keycloak
|
||||||
|
sleep 10
|
||||||
|
|
||||||
- name: Run Admin Console
|
- name: Configure Keycloak server
|
||||||
run: npx http-server ./build -P http://localhost:8180/ & sleep 30
|
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: Admin Console client
|
- name: Setup Node
|
||||||
run: ./import.mjs
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
- name: Cypress run
|
- name: Install dependencies
|
||||||
run: npm run start:cypress-tests
|
run: npm ci
|
||||||
|
|
||||||
- name: Add Cypress videos artifacts
|
- name: Run Cypress
|
||||||
uses: actions/upload-artifact@v2
|
run: CYPRESS_BASE_URL=http://localhost:8080/auth/admin/ CYPRESS_KEYCLOAK_SERVER=http://localhost:8080 npm run start:cypress-tests
|
||||||
if: failure()
|
|
||||||
with:
|
|
||||||
name: cypress-videos
|
|
||||||
path: assets/videos
|
|
||||||
|
|
||||||
- name: Add Cypress screenshots artifacts
|
- name: Add Cypress videos artifacts
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: cypress-screenshots
|
name: cypress-videos
|
||||||
path: assets/screenshots
|
path: assets/videos
|
||||||
|
|
||||||
|
- name: Add Cypress screenshots artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
name: cypress-screenshots
|
||||||
|
path: assets/screenshots
|
||||||
|
|
|
@ -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`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
|
}
|
||||||
|
|
|
@ -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",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue