diff --git a/docker/ci/postgres/authentik.sql.gz b/docker/ci/postgres/authentik.sql.gz index 3eed585b..c67ecc9f 100644 Binary files a/docker/ci/postgres/authentik.sql.gz and b/docker/ci/postgres/authentik.sql.gz differ diff --git a/docker/docker-compose.ci.mysql.yml b/docker/docker-compose.ci.mysql.yml index 435a30be..06ecdaa3 100644 --- a/docker/docker-compose.ci.mysql.yml +++ b/docker/docker-compose.ci.mysql.yml @@ -1,6 +1,10 @@ # WARNING: This is a CI docker-compose file used for building and testing of the entire app, it should not be used for production. services: + cypress: + environment: + CYPRESS_stack: 'mysql' + fullstack: environment: NPM_DB_DRIVER: 'mysql' diff --git a/docker/docker-compose.ci.postgres.yml b/docker/docker-compose.ci.postgres.yml index b0e9aac3..9124caac 100644 --- a/docker/docker-compose.ci.postgres.yml +++ b/docker/docker-compose.ci.postgres.yml @@ -1,6 +1,10 @@ # WARNING: This is a CI docker-compose file used for building and testing of the entire app, it should not be used for production. services: + cypress: + environment: + CYPRESS_stack: 'postgres' + fullstack: environment: NPM_DB_DRIVER: 'postgres' diff --git a/docker/docker-compose.ci.yml b/docker/docker-compose.ci.yml index 1482135c..e51453b6 100644 --- a/docker/docker-compose.ci.yml +++ b/docker/docker-compose.ci.yml @@ -83,6 +83,7 @@ services: dockerfile: test/cypress/Dockerfile environment: CYPRESS_baseUrl: 'http://fullstack:81' + CYPRESS_stack: 'sqlite' volumes: - 'cypress_logs:/results' - './dev/resolv.conf:/etc/resolv.conf:ro' diff --git a/test/cypress/e2e/api/Ldap.cy.js b/test/cypress/e2e/api/Ldap.cy.js new file mode 100644 index 00000000..62641ed5 --- /dev/null +++ b/test/cypress/e2e/api/Ldap.cy.js @@ -0,0 +1,71 @@ +/// + +const { curry } = require("lodash"); + +// WIP + +describe('LDAP with Authentik', () => { + let token; + if (Cypress.env('stack') === 'postgres') { + + before(() => { + cy.task('log', 'STACK IS: ' + Cypress.env('stack')); + + cy.resetUsers(); + cy.getToken().then((tok) => { + token = tok; + + cy.task('backendApiPut', { + token: token, + path: '/api/settings/ldap-auth', + data: { + value: { + host: 'authentik-ldap:3389', + base_dn: 'ou=users,DC=ldap,DC=goauthentik,DC=io', + user_dn: 'cn={{USERNAME}},ou=users,DC=ldap,DC=goauthentik,DC=io', + email_property: 'mail', + name_property: 'sn', + self_filter: '(&(cn={{USERNAME}})(ak-active=TRUE))', + auto_create_user: true + } + } + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{name}', data); + expect(data.result).to.have.property('id'); + expect(data.result.id).to.be.greaterThan(0); + }); + + cy.task('backendApiPut', { + token: token, + path: '/api/settings/auth-methods', + data: { + value: [ + 'local', + 'ldap' + ] + } + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{name}', data); + expect(data.result).to.have.property('id'); + expect(data.result.id).to.be.greaterThan(0); + }); + }); + }); + + it('Should log in with LDAP', function() { + cy.task('backendApiPost', { + token: token, + path: '/api/auth', + data: { + // Authentik LDAP creds: + type: 'ldap', + identity: 'cypress', + secret: 'fqXBfUYqHvYqiwBHWW7f' + } + }).then((data) => { + cy.validateSwaggerSchema('post', 200, '/auth', data); + expect(data.result).to.have.property('token'); + }); + }); + } +}); diff --git a/test/cypress/plugins/index.js b/test/cypress/plugins/index.js index e489ba78..c02c563d 100644 --- a/test/cypress/plugins/index.js +++ b/test/cypress/plugins/index.js @@ -1,4 +1,5 @@ const {SwaggerValidation} = require('@jc21/cypress-swagger-validation'); +const chalk = require('chalk'); module.exports = (on, config) => { // Replace swaggerFile config var wildcard @@ -11,7 +12,7 @@ module.exports = (on, config) => { on('task', require('./backendApi/task')(config)); on('task', { log(message) { - console.log(message); + console.log(chalk.cyan.bold('[') + chalk.blue.bold('LOG') + chalk.cyan.bold(']') + ' ' + chalk.red.bold(message)); return null; } });