diff --git a/.github/workflows/build-test-containers.yaml b/.github/workflows/build-test-containers.yaml index 710b6a450..19620ff0a 100644 --- a/.github/workflows/build-test-containers.yaml +++ b/.github/workflows/build-test-containers.yaml @@ -22,6 +22,9 @@ jobs: - name: Build mysql-ssh-keyfile image run: | docker build -t dbgate/mysql-ssh-keyfile:latest e2e-tests/containers/mysql-ssh-keyfile + - name: Build dex image + run: | + docker build -t dbgate/dex:latest e2e-tests/containers/dex - name: Log in to GHCR uses: docker/login-action@v2 with: @@ -36,3 +39,7 @@ jobs: run: | docker tag dbgate/mysql-ssh-keyfile:latest ghcr.io/dbgate/mysql-ssh-keyfile:latest docker push ghcr.io/dbgate/mysql-ssh-keyfile:latest + - name: Push dex to GHCR + run: | + docker tag dbgate/dex:latest ghcr.io/dbgate/dex:latest + docker push ghcr.io/dbgate/dex:latest diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index f6ac413f0..428f143fa 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -94,3 +94,5 @@ jobs: image: 'ghcr.io/dbgate/mysql-ssh-login:latest' mysql-ssh-keyfile: image: 'ghcr.io/dbgate/mysql-ssh-keyfile:latest' + dex: + image: 'ghcr.io/dbgate/dex:latest' diff --git a/e2e-tests/containers/dex/Dockerfile b/e2e-tests/containers/dex/Dockerfile new file mode 100644 index 000000000..1b3129255 --- /dev/null +++ b/e2e-tests/containers/dex/Dockerfile @@ -0,0 +1,7 @@ +FROM dexidp/dex:v2.35.3 + +COPY ./dex-config.yaml /etc/dex/cfg/config.yaml + +EXPOSE 5556 + +CMD ["dex", "serve", "/etc/dex/cfg/config.yaml"] diff --git a/e2e-tests/containers/dex/dex-config.yaml b/e2e-tests/containers/dex/dex-config.yaml new file mode 100644 index 000000000..21360faf8 --- /dev/null +++ b/e2e-tests/containers/dex/dex-config.yaml @@ -0,0 +1,22 @@ +issuer: http://dex:5556/dex +storage: + type: memory +web: + http: 0.0.0.0:5556 + +oauth2: + skipApprovalScreen: true + +staticClients: + - id: my-app + redirectURIs: + - 'http://localhost:3000/callback' + name: 'My Test App' + secret: my-secret + +enablePasswordDB: true +staticPasswords: + - email: "test@example.com" + hash: "$2y$05$olu30d4lgn7r1/Xfe13N1.5dz0N9AVlKXUFIxXUYVkhiq8D6gwYGG" + username: "test" + userID: "1234" diff --git a/e2e-tests/cypress.config.js b/e2e-tests/cypress.config.js index 0e904d24d..b90aa0e96 100644 --- a/e2e-tests/cypress.config.js +++ b/e2e-tests/cypress.config.js @@ -22,6 +22,9 @@ module.exports = defineConfig({ case 'portal': serverProcess = exec('yarn start:portal:local'); break; + case 'oauth': + serverProcess = exec('yarn start:oauth:local'); + break; } await waitOn({ resources: ['http://localhost:3000'] }); diff --git a/e2e-tests/cypress/e2e/oauth.cy.js b/e2e-tests/cypress/e2e/oauth.cy.js new file mode 100644 index 000000000..b763306a5 --- /dev/null +++ b/e2e-tests/cypress/e2e/oauth.cy.js @@ -0,0 +1,14 @@ +describe('OAuth', () => { + it('OAuth login', () => { + cy.visit('http://localhost:3000'); + + // login on DEX + 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(); + cy.contains('performance_schema'); + }); +}); diff --git a/e2e-tests/env/oauth-ci/.env b/e2e-tests/env/oauth-ci/.env new file mode 100644 index 000000000..66d2307cc --- /dev/null +++ b/e2e-tests/env/oauth-ci/.env @@ -0,0 +1,15 @@ +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/dex/auth +OAUTH_TOKEN=http://dex/dex/token +OAUTH_CLIENT_ID=my-app +OAUTH_CLIENT_SECRET=my-secret +OAUTH_LOGIN_FIELD=username +OAUTH_SCOPE=openid \ No newline at end of file diff --git a/e2e-tests/env/oauth-local/.env b/e2e-tests/env/oauth-local/.env index b53c2031b..1033b9ed4 100644 --- a/e2e-tests/env/oauth-local/.env +++ b/e2e-tests/env/oauth-local/.env @@ -12,3 +12,4 @@ OAUTH_TOKEN=http://localhost:16009/dex/token OAUTH_CLIENT_ID=my-app OAUTH_CLIENT_SECRET=my-secret OAUTH_LOGIN_FIELD=username +OAUTH_SCOPE=openid \ No newline at end of file diff --git a/workflow-templates/build-test-containers.yaml b/workflow-templates/build-test-containers.yaml index 741880cc2..fc3068bcc 100644 --- a/workflow-templates/build-test-containers.yaml +++ b/workflow-templates/build-test-containers.yaml @@ -24,6 +24,10 @@ jobs: run: | docker build -t dbgate/mysql-ssh-keyfile:latest e2e-tests/containers/mysql-ssh-keyfile + - name: Build dex image + run: | + docker build -t dbgate/dex:latest e2e-tests/containers/dex + - name: Log in to GHCR uses: docker/login-action@v2 with: @@ -40,3 +44,8 @@ jobs: run: | docker tag dbgate/mysql-ssh-keyfile:latest ghcr.io/dbgate/mysql-ssh-keyfile:latest docker push ghcr.io/dbgate/mysql-ssh-keyfile:latest + + - name: Push dex to GHCR + run: | + docker tag dbgate/dex:latest ghcr.io/dbgate/dex:latest + docker push ghcr.io/dbgate/dex:latest diff --git a/workflow-templates/run-tests.yaml b/workflow-templates/run-tests.yaml index b8eeaeb74..a15f6b9be 100644 --- a/workflow-templates/run-tests.yaml +++ b/workflow-templates/run-tests.yaml @@ -116,3 +116,6 @@ jobs: mysql-ssh-keyfile: image: ghcr.io/dbgate/mysql-ssh-keyfile:latest + + dex: + image: ghcr.io/dbgate/dex:latest