-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into nw_markdown_export
- Loading branch information
Showing
15 changed files
with
202 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/browser-tests/cypress/integration/enterprise/oidc.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const contextPath = process.env.QDB_HTTP_CONTEXT_WEB_CONSOLE || "" | ||
const baseUrl = `http://localhost:9999${contextPath}`; | ||
const settingsUrl = `${baseUrl}/settings`; | ||
|
||
const oidcProviderUrl = "http://localhost:9032"; | ||
const oidcAuthorizationCodeUrl = `${oidcProviderUrl}/authorization`; | ||
const oidcTokenUrl = `${oidcProviderUrl}/token`; | ||
|
||
const interceptSettings = (payload) => { | ||
cy.intercept({ method: "GET", url: settingsUrl }, payload).as( | ||
"settings" | ||
); | ||
}; | ||
|
||
const interceptAuthorizationCodeRequest = (redirectUrl) => { | ||
cy.intercept("GET", `${oidcAuthorizationCodeUrl}?**`, (req) => { | ||
req.redirect(redirectUrl); | ||
}).as('authorizationCode'); | ||
}; | ||
|
||
const interceptTokenRequest = (payload) => { | ||
cy.intercept({ method: "POST", url: oidcTokenUrl }, payload).as( | ||
"tokens" | ||
); | ||
}; | ||
|
||
describe("OIDC authentication", () => { | ||
before(() => { | ||
// setup SSO group mappings | ||
cy.loadConsoleAsAdminAndCreateSSOGroup("group1"); | ||
}); | ||
|
||
beforeEach(() => { | ||
// load login page | ||
interceptSettings({ | ||
"release.type": "EE", | ||
"release.version": "1.2.3", | ||
"acl.enabled": true, | ||
"acl.basic.auth.realm.enabled": false, | ||
"acl.oidc.enabled": true, | ||
"acl.oidc.client.id": "client1", | ||
"acl.oidc.authorization.endpoint": oidcAuthorizationCodeUrl, | ||
"acl.oidc.token.endpoint": oidcTokenUrl, | ||
"acl.oidc.pkce.required": true, | ||
"acl.oidc.state.required": false, | ||
"acl.oidc.groups.encoded.in.token": false, | ||
}); | ||
cy.visit(baseUrl); | ||
|
||
cy.wait("@settings"); | ||
cy.getByDataHook("auth-login").should("be.visible"); | ||
cy.getByDataHook("button-sso-login").should("be.visible"); | ||
cy.getEditor().should("not.exist"); | ||
}); | ||
|
||
it("should login via OIDC", () => { | ||
interceptAuthorizationCodeRequest(`${baseUrl}?code=abcdefgh`); | ||
cy.getByDataHook("button-sso-login").click(); | ||
cy.wait("@authorizationCode"); | ||
|
||
interceptTokenRequest({ | ||
"access_token": "gslpJtzmmi6RwaPSx0dYGD4tEkom", | ||
"refresh_token": "FUuAAqMp6LSTKmkUd5uZuodhiE4Kr6M7Eyv", | ||
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6I", | ||
"token_type": "Bearer", | ||
"expires_in": 300 | ||
}); | ||
cy.wait("@tokens"); | ||
cy.getEditor().should("be.visible"); | ||
|
||
cy.executeSQL("select current_user();"); | ||
cy.getGridRow(0).should("contain", "user1"); | ||
|
||
cy.logout(); | ||
}); | ||
|
||
it("should force authentication if token expired, and there is no refresh token", () => { | ||
interceptAuthorizationCodeRequest(`${baseUrl}?code=abcdefgh`); | ||
cy.getByDataHook("button-sso-login").click(); | ||
cy.wait("@authorizationCode"); | ||
|
||
interceptTokenRequest({ | ||
"access_token": "gslpJtzmmi6RwaPSx0dYGD4tEkom", | ||
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6I", | ||
"token_type": "Bearer", | ||
"expires_in": 0 | ||
}); | ||
cy.wait("@tokens"); | ||
cy.getEditor().should("be.visible"); | ||
|
||
cy.reload(); | ||
cy.getByDataHook("button-log-in").should("be.visible"); | ||
|
||
cy.getByDataHook("button-log-in").click() | ||
cy.getEditor().should("be.visible"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash -x | ||
|
||
# Run it from the 'ui' directory as: | ||
# ./run_ent_browser_tests.sh | ||
|
||
# Cleanup | ||
rm -rf packages/browser-tests/cypress/snapshots/* | ||
rm -rf tmp/dbroot | ||
rm -rf tmp/questdb-* | ||
|
||
# Clone questdb-enterprise | ||
git clone https://github.com/questdb/questdb-enterprise.git tmp/questdb-enterprise | ||
cd tmp/questdb-enterprise || exit 1 | ||
git submodule init | ||
git submodule update | ||
cd ../.. | ||
|
||
# Build server | ||
mvn clean package -e -f tmp/questdb-enterprise/pom.xml -DskipTests -P build-ent-binaries 2>&1 | ||
|
||
# Unpack server | ||
tar xzf tmp/questdb-enterprise/questdb-ent/target/questdb-enterprise-*-rt-*.tar.gz -C tmp/ | ||
mkdir tmp/dbroot | ||
|
||
# Build web console | ||
yarn install --immutable --immutable-cache | ||
yarn workspace @questdb/react-components run build | ||
yarn workspace @questdb/web-console run build | ||
|
||
# Start proxy | ||
node packages/web-console/serve-dist.js & | ||
PID1="$!" | ||
echo "Proxy started, PID=$PID1" | ||
|
||
# Switch dev mode on | ||
export QDB_DEV_MODE_ENABLED=true | ||
|
||
# OIDC config | ||
export QDB_ACL_OIDC_ENABLED=true | ||
export QDB_ACL_OIDC_TLS_ENABLED=false | ||
export QDB_ACL_OIDC_GROUPS_CLAIM=groups | ||
export QDB_ACL_OIDC_CLIENT_ID=clientId | ||
export QDB_ACL_OIDC_HOST=localhost | ||
export QDB_ACL_OIDC_PORT=9999 | ||
export QDB_ACL_OIDC_USERINFO_ENDPOINT=/userinfo | ||
|
||
# Running tests which assume authentication is off | ||
./tmp/questdb-*/bin/questdb.sh start -d tmp/dbroot | ||
yarn workspace browser-tests test:enterprise | ||
./tmp/questdb-*/bin/questdb.sh stop | ||
|
||
# Stop proxy | ||
kill -SIGTERM $PID1 |