mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-04-29 02:22:28 +00:00
Cypress test for LDAP
This commit is contained in:
parent
4d60876394
commit
c556b8acef
Binary file not shown.
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
71
test/cypress/e2e/api/Ldap.cy.js
Normal file
71
test/cypress/e2e/api/Ldap.cy.js
Normal file
@ -0,0 +1,71 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
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');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user