oauth test WIP

This commit is contained in:
SPRINX0\prochazka
2025-01-08 15:05:14 +01:00
parent a3e8d64d4e
commit 01f3f44369
10 changed files with 83 additions and 0 deletions

View File

@@ -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

View File

@@ -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'

View File

@@ -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"]

View File

@@ -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"

View File

@@ -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'] });

View File

@@ -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');
});
});

15
e2e-tests/env/oauth-ci/.env vendored Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -116,3 +116,6 @@ jobs:
mysql-ssh-keyfile:
image: ghcr.io/dbgate/mysql-ssh-keyfile:latest
dex:
image: ghcr.io/dbgate/dex:latest