mirror of https://gitee.com/bigwinds/arangodb
first ldap tests
This commit is contained in:
parent
850097247d
commit
966ea503c2
|
@ -34,6 +34,8 @@ const optionsDocumentation = [
|
|||
|
||||
const pu = require('@arangodb/process-utils');
|
||||
const tu = require('@arangodb/test-utils');
|
||||
const request = require('@arangodb/request');
|
||||
const arango = require("@arangodb").arango;
|
||||
const fs = require('fs');
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
|
@ -54,27 +56,91 @@ const download = require('internal').download;
|
|||
|
||||
function ldap(options) {
|
||||
|
||||
print(`DAP FQDN is: ${options.ldapUrl}`);
|
||||
print(`DAP FQDN is: ${options.ldapUrl} ${options.caCertFilePath}`);
|
||||
|
||||
const confs = [{
|
||||
'server.authentication-system-only':false,
|
||||
'ldap.enabled':true,
|
||||
'ldap.server':options.ldapUrl,
|
||||
'ldap.basedn':'dc=example,dc=com',
|
||||
'ldap.search-filter': 'objectClass=simpleSecurityObject',
|
||||
'ldap.search-attribute': 'uid',
|
||||
'ldap.binddn': 'cn=admin,dc=example,dc=com',
|
||||
'ldap.bindpasswd': 'hallo',
|
||||
'ldap.permissions-attribute-name': 'description'
|
||||
const tests = [{
|
||||
conf: {
|
||||
'server.authentication': true,
|
||||
'server.authentication-system-only':false,
|
||||
'ldap.enabled':true,
|
||||
'ldap.server':options.ldapUrl,
|
||||
'ldap.port': 3890,
|
||||
'ldap.prefix': 'uid=',
|
||||
'ldap.suffix':',dc=example,dc=com',
|
||||
'ldap.search-filter': 'objectClass=simpleSecurityObject',
|
||||
'ldap.search-attribute': 'uid',
|
||||
'ldap.permissions-attribute-name': 'description'
|
||||
},
|
||||
user: {
|
||||
name: 'fermi',
|
||||
pass: 'password'
|
||||
},
|
||||
result:{
|
||||
statusCode: 200
|
||||
}
|
||||
},
|
||||
{
|
||||
'server.authentication-system-only':false,
|
||||
'ldap.enabled':true,
|
||||
'ldap.url':`ldap://${options.ldapUrl}/dc=example,dc=com?uid?sub`,
|
||||
'ldap.search-filter': 'objectClass=simpleSecurityObject',
|
||||
'ldap.binddn': 'cn=admin,dc=example,dc=com',
|
||||
'ldap.bindpasswd': 'hallo',
|
||||
'ldap.permissions-attribute-name': 'description'
|
||||
{
|
||||
conf: {
|
||||
'server.authentication': true,
|
||||
'server.authentication-system-only':false,
|
||||
'ldap.enabled':true,
|
||||
'ldap.server':options.ldapUrl,
|
||||
'ldap.port': 3890,
|
||||
'ldap.basedn':'dc=example,dc=com',
|
||||
'ldap.search-filter': 'objectClass=simpleSecurityObject',
|
||||
'ldap.search-attribute': 'uid',
|
||||
'ldap.binddn': 'cn=admin,dc=example,dc=com',
|
||||
'ldap.bindpasswd': 'hallo',
|
||||
'ldap.permissions-attribute-name': 'description'
|
||||
},
|
||||
user: {
|
||||
name: 'albert',
|
||||
pass: 'password'
|
||||
},
|
||||
result:{
|
||||
statusCode: 200
|
||||
}
|
||||
},
|
||||
{
|
||||
conf: {
|
||||
'server.authentication': true,
|
||||
'server.authentication-system-only':false,
|
||||
'ldap.enabled':true,
|
||||
'ldap.url':`ldap://${options.ldapUrl}:3890/dc=example,dc=com?uid?sub`,
|
||||
'ldap.search-filter': 'objectClass=simpleSecurityObject',
|
||||
'ldap.binddn': 'cn=admin,dc=example,dc=com',
|
||||
'ldap.bindpasswd': 'hallo',
|
||||
'ldap.permissions-attribute-name': 'description'
|
||||
},
|
||||
user: {
|
||||
name: 'fermi',
|
||||
pass: 'password'
|
||||
},
|
||||
result: {
|
||||
statusCode: 200
|
||||
}
|
||||
},
|
||||
{
|
||||
conf: {
|
||||
'server.authentication': true,
|
||||
'server.authentication-system-only':false,
|
||||
'ldap.enabled':true,
|
||||
'ldap.url':`ldap://${options.ldapUrl}:3890/dc=example,dc=com?uid?sub`,
|
||||
'ldap.search-filter': 'objectClass=simpleSecurityObject',
|
||||
'ldap.binddn': 'cn=admin,dc=example,dc=com',
|
||||
'ldap.bindpasswd': 'hallo',
|
||||
'ldap.permissions-attribute-name': 'description',
|
||||
'ldap.tls': true,
|
||||
'ldap.tls-cert-check-strategy': options.caCertFilePath
|
||||
|
||||
},
|
||||
user: {
|
||||
name: 'fermi',
|
||||
pass: 'password'
|
||||
},
|
||||
result: {
|
||||
statusCode: 200
|
||||
}
|
||||
}];
|
||||
|
||||
if (options.skipLdap === true) {
|
||||
|
@ -99,11 +165,14 @@ function ldap(options) {
|
|||
|
||||
print(CYAN + 'LDAP tests...' + RESET);
|
||||
|
||||
for(const conf of confs) {
|
||||
const adbInstance = pu.startInstance('tcp', options, confs[0], 'ldap');
|
||||
for(const t of tests) {
|
||||
const adbInstance = pu.startInstance('tcp', options, t.conf, 'ldap');
|
||||
const res = request.post({
|
||||
url:`${adbInstance.arangods[0].url}/_open/auth`,
|
||||
body: JSON.stringify({username: t.user.name, password: t.user.pass})
|
||||
});
|
||||
|
||||
|
||||
// try auth
|
||||
print(res.message, res.statusCode, t.result.statusCode === res.statusCode);
|
||||
|
||||
pu.shutdownInstance(adbInstance, options);
|
||||
}
|
||||
|
@ -120,6 +189,7 @@ exports.setup = function(testFns, defaultFns, opts, fnDocs, optionsDoc) {
|
|||
testFns['ldap'] = ldap;
|
||||
defaultFns.push('ldap');
|
||||
opts['ldapUrl'] = '127.0.0.1';
|
||||
opts['caCertFilePath'] = '~/ca_cert.pem';
|
||||
|
||||
for (var attrname in functionsDocumentation) { fnDocs[attrname] = functionsDocumentation[attrname]; }
|
||||
for (var i = 0; i < optionsDocumentation.length; i++) { optionsDoc.push(optionsDocumentation[i]); }
|
||||
|
|
Loading…
Reference in New Issue