Class: FakeLDAP::Server
- Inherits:
-
LDAP::Server
- Object
- LDAP::Server
- FakeLDAP::Server
- Defined in:
- lib/fakeldap.rb
Instance Method Summary collapse
- #add_user(user, pass) ⇒ Object
- #default_options ⇒ Object
- #find_users(basedn, filter) ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #valid_credentials?(user, pass) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
6 7 8 9 |
# File 'lib/fakeldap.rb', line 6 def initialize(={}) @users = {} super(.merge()) end |
Instance Method Details
#add_user(user, pass) ⇒ Object
11 12 13 |
# File 'lib/fakeldap.rb', line 11 def add_user(user, pass) @users[user] = pass end |
#default_options ⇒ Object
28 29 30 31 32 33 |
# File 'lib/fakeldap.rb', line 28 def { :operation_class => ::FakeLDAP::Operation, :operation_args => [self] } end |
#find_users(basedn, filter) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/fakeldap.rb', line 19 def find_users(basedn, filter) basedn_regex = /#{Regexp.escape(basedn)}$/ filter_regex = /^#{filter[1]}=#{filter[3]}$/ @users.keys.select { |dn| dn =~ basedn_regex && dn.split(",").grep(filter_regex).any? } end |
#valid_credentials?(user, pass) ⇒ Boolean
15 16 17 |
# File 'lib/fakeldap.rb', line 15 def valid_credentials?(user, pass) @users.has_key?(user) && @users[user] == pass end |