feat(test): this plugin is now testable (#20)

See vatesfr/xo-web#1749
This commit is contained in:
badrAZ 2016-11-09 16:41:53 +01:00 committed by Julien Fontanet
parent cdf1a5fe47
commit 47991b7d1a

View File

@ -106,6 +106,21 @@ For Microsoft Active Directory, you can try one of the following filters:
required: ['uri', 'base']
}
export const testSchema = {
type: 'object',
properties: {
username: {
description: 'LDAP username',
type: 'string'
},
password: {
description: 'LDAP password',
type: 'string'
}
},
required: ['username', 'password']
}
// ===================================================================
class AuthLdap {
@ -163,6 +178,13 @@ class AuthLdap {
this._xo.unregisterAuthenticationProvider(this._authenticate)
}
test ({ username, password }) {
return this._authenticate({
username,
password
})
}
async _authenticate ({ username, password }, logger = noop) {
if (username === undefined || password === undefined) {
logger('require `username` and `password` to authenticate!')