authelia/server/test/mocks/ldap/ClientStub.ts
Clement Michaud 66449eedb0 Use username matcher instead of user dn in group filter
Previously, string "{0}" was replaced by the user dn in the groups_filter
attributes of the LDAP configuration.
However, if the groups children only have a memberUid attribute, one would
like to use the username instead of the user dn.

Since the user dn can be built from the username, "{0}" is now replaced
by the username instead of the user dn so that an LDAP relying on attribute
'memberUid' can be used.
2017-10-07 14:10:22 +02:00

46 lines
1.3 KiB
TypeScript

import BluebirdPromise = require("bluebird");
import { IClient, GroupsAndEmails } from "../../../src/lib/ldap/IClient";
import Sinon = require("sinon");
export class ClientStub implements IClient {
openStub: Sinon.SinonStub;
closeStub: Sinon.SinonStub;
searchUserDnStub: Sinon.SinonStub;
searchEmailsStub: Sinon.SinonStub;
searchGroupsStub: Sinon.SinonStub;
modifyPasswordStub: Sinon.SinonStub;
constructor() {
this.openStub = Sinon.stub();
this.closeStub = Sinon.stub();
this.searchUserDnStub = Sinon.stub();
this.searchEmailsStub = Sinon.stub();
this.searchGroupsStub = Sinon.stub();
this.modifyPasswordStub = Sinon.stub();
}
open(): BluebirdPromise<void> {
return this.openStub();
}
close(): BluebirdPromise<void> {
return this.closeStub();
}
searchUserDn(username: string): BluebirdPromise<string> {
return this.searchUserDnStub(username);
}
searchEmails(username: string): BluebirdPromise<string[]> {
return this.searchEmailsStub(username);
}
searchGroups(username: string): BluebirdPromise<string[]> {
return this.searchGroupsStub(username);
}
modifyPassword(username: string, newPassword: string): BluebirdPromise<void> {
return this.modifyPasswordStub(username, newPassword);
}
}