mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 21:26:00 +00:00
e2e test refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
issuer: http://dex:5556/dex
|
||||
issuer: http://localhost:16009/dex
|
||||
storage:
|
||||
type: memory
|
||||
web:
|
||||
|
||||
@@ -7,18 +7,12 @@ describe('Add connection', () => {
|
||||
});
|
||||
|
||||
it('adds connection', () => {
|
||||
const runOnCI = Cypress.env('runOnCI');
|
||||
|
||||
cy.visit('http://localhost:3000');
|
||||
// cy.get('[data-testid=ConnectionList_buttonNewConnection]').click();
|
||||
cy.get('[data-testid=ConnectionDriverFields_connectionType]').select('MySQL');
|
||||
cy.get('[data-testid=ConnectionDriverFields_user]').clear().type('root');
|
||||
cy.get('[data-testid=ConnectionDriverFields_password]').clear().type('Pwd2020Db');
|
||||
if (runOnCI) {
|
||||
cy.get('[data-testid=ConnectionDriverFields_server]').clear().type('mysql');
|
||||
} else {
|
||||
cy.get('[data-testid=ConnectionDriverFields_port]').clear().type('16004');
|
||||
}
|
||||
cy.get('[data-testid=ConnectionDriverFields_port]').clear().type('16004');
|
||||
cy.get('[data-testid=ConnectionDriverFields_displayName]').clear().type('test-mysql-1');
|
||||
|
||||
// test connection
|
||||
@@ -32,8 +26,6 @@ describe('Add connection', () => {
|
||||
});
|
||||
|
||||
it('SSH connection - user + password', () => {
|
||||
const runOnCI = Cypress.env('runOnCI');
|
||||
|
||||
cy.visit('http://localhost:3000');
|
||||
cy.contains('Connections');
|
||||
|
||||
@@ -52,19 +44,13 @@ describe('Add connection', () => {
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_useSshTunnel]').check();
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshLogin]').clear().type('root');
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshPassword]').clear().type('root');
|
||||
if (runOnCI) {
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshHost]').clear().type('mysql-ssh-login');
|
||||
} else {
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshPort]').clear().type('16006');
|
||||
}
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshPort]').clear().type('16006');
|
||||
cy.get('[data-testid=ConnectionTab_buttonSave]').click();
|
||||
cy.get('[data-testid=ConnectionTab_buttonConnect]').click();
|
||||
cy.contains('performance_schema');
|
||||
});
|
||||
|
||||
it('SSH connection - keyfile', () => {
|
||||
const runOnCI = Cypress.env('runOnCI');
|
||||
|
||||
cy.visit('http://localhost:3000');
|
||||
cy.contains('Connections');
|
||||
|
||||
@@ -87,30 +73,20 @@ describe('Add connection', () => {
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshKeyfile]')
|
||||
.clear()
|
||||
.type(path.join(Cypress.config('fileServerFolder'), 'cypress', 'e2e', 'mykey'));
|
||||
if (runOnCI) {
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshHost]').clear().type('mysql-ssh-keyfile');
|
||||
} else {
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshPort]').clear().type('16008');
|
||||
}
|
||||
cy.get('[data-testid=ConnectionSshTunnelFields_sshPort]').clear().type('16008');
|
||||
cy.get('[data-testid=ConnectionTab_buttonSave]').click();
|
||||
cy.get('[data-testid=ConnectionTab_buttonConnect]').click();
|
||||
cy.contains('performance_schema');
|
||||
});
|
||||
|
||||
it('ask password - mysql', () => {
|
||||
const runOnCI = Cypress.env('runOnCI');
|
||||
|
||||
cy.visit('http://localhost:3000');
|
||||
|
||||
|
||||
cy.get('[data-testid=ConnectionList_buttonNewConnection]').click();
|
||||
cy.get('[data-testid=ConnectionDriverFields_connectionType]').select('MySQL');
|
||||
cy.get('[data-testid=ConnectionDriverFields_user]').clear().type('root');
|
||||
cy.get('[data-testid=ConnectionDriverFields_password]').clear().type('Pwd2020Db');
|
||||
if (runOnCI) {
|
||||
cy.get('[data-testid=ConnectionDriverFields_server]').clear().type('mysql');
|
||||
} else {
|
||||
cy.get('[data-testid=ConnectionDriverFields_port]').clear().type('16004');
|
||||
}
|
||||
cy.get('[data-testid=ConnectionDriverFields_port]').clear().type('16004');
|
||||
cy.get('[data-testid=ConnectionDriverFields_displayName]').clear().type('test-mysql-2');
|
||||
cy.testid('ConnectionDriverFields_passwordMode').select('askPassword');
|
||||
|
||||
|
||||
@@ -2,20 +2,10 @@ describe('OAuth', () => {
|
||||
it('OAuth login', () => {
|
||||
cy.visit('http://localhost:3000');
|
||||
|
||||
const runOnCI = Cypress.env('runOnCI');
|
||||
|
||||
// login on DEX
|
||||
if (runOnCI) {
|
||||
cy.origin('http://dex:5556', () => {
|
||||
cy.get('#login').clear().type('test@example.com');
|
||||
cy.get('#password').clear().type('test');
|
||||
cy.get('#submit-login').click();
|
||||
});
|
||||
} else {
|
||||
cy.get('#login').clear().type('test@example.com');
|
||||
cy.get('#password').clear().type('test');
|
||||
cy.get('#submit-login').click();
|
||||
}
|
||||
cy.get('#login').clear().type('test@example.com');
|
||||
cy.get('#password').clear().type('test');
|
||||
cy.get('#submit-login').click();
|
||||
|
||||
// check DbGate connection
|
||||
cy.contains('MySql-connection').click();
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
issuer: http://localhost:16009/dex
|
||||
storage:
|
||||
type: memory
|
||||
web:
|
||||
http: 0.0.0.0:5556
|
||||
|
||||
oauth2:
|
||||
skipApprovalScreen: true
|
||||
|
||||
staticClients:
|
||||
- id: my-app
|
||||
redirectURIs:
|
||||
- 'http://localhost:3000/'
|
||||
name: 'My Test App'
|
||||
secret: my-secret
|
||||
|
||||
enablePasswordDB: true
|
||||
staticPasswords:
|
||||
- email: "test@example.com"
|
||||
hash: "$2y$10$JcmlXnV1y7.egUdKwYNbseOnqYVIGc323gtvvHh4ZuSPZB30veYZy"
|
||||
username: "test"
|
||||
userID: "1234"
|
||||
@@ -22,19 +22,16 @@ services:
|
||||
restart: always
|
||||
ports:
|
||||
- 16005:3306
|
||||
- 16006:22
|
||||
- "16006:22"
|
||||
|
||||
mysql-ssh-keyfile:
|
||||
build: containers/mysql-ssh-keyfile
|
||||
restart: always
|
||||
ports:
|
||||
- 16007:3306
|
||||
- 16008:22
|
||||
- "16008:22"
|
||||
|
||||
dex:
|
||||
image: dexidp/dex:v2.35.3
|
||||
build: containers/dex
|
||||
ports:
|
||||
- "16009:5556"
|
||||
volumes:
|
||||
- ./dex-config.yaml:/etc/dex/cfg/config.yaml
|
||||
command: ["dex", "serve", "/etc/dex/cfg/config.yaml"]
|
||||
|
||||
15
e2e-tests/env/oauth-ci/.env
vendored
15
e2e-tests/env/oauth-ci/.env
vendored
@@ -1,15 +0,0 @@
|
||||
CONNECTIONS=mysql
|
||||
|
||||
LABEL_mysql=MySql-connection
|
||||
SERVER_mysql=mysql
|
||||
USER_mysql=root
|
||||
PASSWORD_mysql=Pwd2020Db
|
||||
PORT_mysql=3306
|
||||
ENGINE_mysql=mysql@dbgate-plugin-mysql
|
||||
|
||||
OAUTH_AUTH=http://dex:5556/dex/auth
|
||||
OAUTH_TOKEN=http://dex:5556/dex/token
|
||||
OAUTH_CLIENT_ID=my-app
|
||||
OAUTH_CLIENT_SECRET=my-secret
|
||||
OAUTH_LOGIN_FIELD=username
|
||||
OAUTH_SCOPE=openid
|
||||
22
e2e-tests/env/portal-ci/.env
vendored
22
e2e-tests/env/portal-ci/.env
vendored
@@ -1,22 +0,0 @@
|
||||
CONNECTIONS=mysql,postgres,pgask
|
||||
|
||||
LABEL_mysql=MySql-connection
|
||||
SERVER_mysql=mysql
|
||||
USER_mysql=root
|
||||
PASSWORD_mysql=Pwd2020Db
|
||||
PORT_mysql=3306
|
||||
ENGINE_mysql=mysql@dbgate-plugin-mysql
|
||||
|
||||
LABEL_postgres=Postgres-connection
|
||||
SERVER_postgres=postgres
|
||||
USER_postgres=postgres
|
||||
PASSWORD_postgres=Pwd2020Db
|
||||
PORT_postgres=5432
|
||||
ENGINE_postgres=postgres@dbgate-plugin-postgres
|
||||
|
||||
LABEL_pgask=Postgres-ask-connection
|
||||
SERVER_pgask=postgres
|
||||
USER_pgask=postgres
|
||||
PORT_pgask=5432
|
||||
ENGINE_pgask=postgres@dbgate-plugin-postgres
|
||||
PASSWORD_MODE_pgask=askUser
|
||||
@@ -15,24 +15,15 @@
|
||||
"scripts": {
|
||||
"cy:open": "cypress open --config experimentalInteractiveRunEvents=true",
|
||||
|
||||
"cy:run:add-connection:local": "cypress run --spec cypress/e2e/add-connection.cy.js",
|
||||
"cy:run:add-connection:ci": "cypress run --env runOnCI=true --spec cypress/e2e/add-connection.cy.js",
|
||||
|
||||
"cy:run:portal:local": "cypress run --spec cypress/e2e/portal.cy.js",
|
||||
"cy:run:portal:ci": "cypress run --env runOnCI=true --spec cypress/e2e/portal.cy.js",
|
||||
|
||||
"cy:run:oauth:local": "cypress run --spec cypress/e2e/oauth.cy.js",
|
||||
"cy:run:oauth:ci": "cypress run --env runOnCI=true --spec cypress/e2e/oauth.cy.js",
|
||||
"cy:run:add-connection": "cypress run --spec cypress/e2e/add-connection.cy.js",
|
||||
"cy:run:portal": "cypress run --spec cypress/e2e/portal.cy.js",
|
||||
"cy:run:oauth": "cypress run --spec cypress/e2e/oauth.cy.js",
|
||||
|
||||
"start:add-connection": "cd .. && node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
"start:portal": "cd .. && env-cmd -f e2e-tests/env/portal/.env node e2e-tests/init/portal.js && env-cmd -f e2e-tests/env/portal/.env node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
"start:oauth": "cd .. && env-cmd -f e2e-tests/env/oauth/.env node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
|
||||
"start:portal:local": "cd .. && env-cmd -f e2e-tests/env/portal-local/.env node e2e-tests/init/portal.js && env-cmd -f e2e-tests/env/portal-local/.env node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
"start:portal:ci": "cd .. && env-cmd -f e2e-tests/env/portal-ci/.env node e2e-tests/init/portal.js && env-cmd -f e2e-tests/env/portal-ci/.env node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
|
||||
"start:oauth:local": "cd .. && env-cmd -f e2e-tests/env/oauth-local/.env node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
"start:oauth:ci": "cd .. && env-cmd -f e2e-tests/env/oauth-ci/.env node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
|
||||
"test:ci": "start-server-and-test start:add-connection http://localhost:3000 cy:run:add-connection:ci && start-server-and-test start:portal:ci http://localhost:3000 cy:run:portal:ci && start-server-and-test start:oauth:ci http://localhost:3000 cy:run:oauth:ci",
|
||||
"test:local": "start-server-and-test start:add-connection http://localhost:3000 cy:run:add-connection:local && start-server-and-test start:portal:local http://localhost:3000 cy:run:portal:local && start-server-and-test start:oauth:local http://localhost:3000 cy:run:oauth:local"
|
||||
"test": "start-server-and-test start:add-connection http://localhost:3000 cy:run:add-connection && start-server-and-test start:portal http://localhost:3000 cy:run:portal && start-server-and-test start:oauth http://localhost:3000 cy:run:oauth",
|
||||
"test:ci": "yarn test"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
- name: Run Cypress tests
|
||||
run: |
|
||||
cd e2e-tests
|
||||
yarn test:local
|
||||
yarn test:ci
|
||||
|
||||
- name: Integration tests
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user