ruby-ldapserver 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: abccbde672eeae57c5376073590192d391e524c9
4
+ data.tar.gz: 51a8549b288719b8740f8f9804ae68d1dac8785c
5
+ SHA512:
6
+ metadata.gz: 2a63a336eb6f1f79432459af9b847b86f4742c4e16dd7541569bf7dafbbcc8c2cb34183cae6cfcd4817f6bf4a3e1057d7b1bcb7f7fcaa5515ff5fd995bdd3cdb
7
+ data.tar.gz: 1d98bfe14ea67c0794ce696fd0f45b05d9b734bc672f7dbfa72b1ed3bd8bded79e18105c287b217a348fa4c066f270f72720fa8d0ecb321670cf6abd63663eb0
data/Rakefile CHANGED
@@ -1 +1,15 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |t|
5
+ t.test_files = FileList['test/*_test.rb']
6
+ end
7
+
8
+ begin
9
+ require 'rspec/core/rake_task'
10
+ RSpec::Core::RakeTask.new(:spec)
11
+ rescue LoadError
12
+ task :spec
13
+ end
14
+
15
+ task default: [:test, :spec]
@@ -11,7 +11,7 @@ $ ruby rbslapd1.rb
11
11
 
12
12
  In another window:
13
13
 
14
- $ ldapadd -H ldap://127.0.0.1:1389/
14
+ $ ldapadd -x -H ldap://127.0.0.1:1389/
15
15
  dn: dc=example,dc=com
16
16
  cn: Top object
17
17
 
@@ -28,9 +28,9 @@ mail: wilma@bedrock.org
28
28
 
29
29
  Try these queries:
30
30
 
31
- $ ldapsearch -H ldap://127.0.0.1:1389/ -b "" "(objectclass=*)"
32
- $ ldapsearch -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" -s base "(objectclass=*)"
33
- $ ldapsearch -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" "(mail=fred*)"
31
+ $ ldapsearch -x -H ldap://127.0.0.1:1389/ -b "" "(objectclass=*)"
32
+ $ ldapsearch -x -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" -s base "(objectclass=*)"
33
+ $ ldapsearch -x -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" "(mail=fred*)"
34
34
 
35
35
  If you terminate the server with Ctrl-C, its contents should be written
36
36
  to disk as a YAML file.
@@ -52,7 +52,7 @@ In rbslapd1.rb, uncomment
52
52
  and run mkcert.rb. Since this is a self-signed certificate, you'll have to
53
53
  turn off certificate verification in the client too. For example:
54
54
 
55
- $ env LDAPTLS_REQCERT="allow" ldapsearch -H ldaps://127.0.0.1:1389/
55
+ $ env LDAPTLS_REQCERT="allow" ldapsearch -x -H ldaps://127.0.0.1:1389/
56
56
 
57
57
  Making your own CA and installing its certificate in the client, or
58
58
  generating a Certificate Signing Request and sending it to a known CA, is
@@ -23,9 +23,9 @@ require 'resolv-replace' # ruby threading DNS client
23
23
  # work even if the bind occurs on a different client connection to the search.
24
24
  #
25
25
  # To test:
26
- # ldapsearch -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" "(uid=brian)"
26
+ # ldapsearch -x -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" "(uid=brian)"
27
27
  #
28
- # ldapsearch -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" \
28
+ # ldapsearch -x -H ldap://127.0.0.1:1389/ -b "dc=example,dc=com" \
29
29
  # -D "id=1,dc=example,dc=com" -W "(uid=brian)"
30
30
 
31
31
  $debug = true
@@ -0,0 +1,11 @@
1
+ CREATE TABLE logins (
2
+ login_id MEDIUMINT NOT NULL AUTO_INCREMENT,
3
+ login CHAR(30) NOT NULL,
4
+ passwd CHAR(30),
5
+ PRIMARY KEY (login_id)
6
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7
+
8
+ INSERT INTO logins(login, passwd) VALUES
9
+ ('brian', 'foobar'), ('caroline', 'boing');
10
+
11
+ SELECT * FROM logins;
@@ -108,7 +108,7 @@ class Server
108
108
 
109
109
  if @schema
110
110
  # normalize the attribute names
111
- @attributes = @attributes.collect { |a| @schema.find_attrtype(a).to_s }
111
+ @attributes = @attributes.map { |a| a == '*' ? a : @schema.find_attrtype(a).to_s }
112
112
  end
113
113
 
114
114
  sendall = @attributes == [] || @attributes.include?("*")
@@ -33,10 +33,10 @@ class Server
33
33
 
34
34
  def self.split_dn(dn)
35
35
  # convert \\ to \5c, \+ to \2b etc
36
- dn2 = dn.gsub(/\\([ #,+"\\<>;])/) { "\\%02x" % $1[0] }
36
+ dn.gsub!(/\\([ #,+"\\<>;])/) { |match| format "\\%02x", match[1].ord }
37
37
 
38
38
  # Now we know that \\ and \, do not exist, it's safe to split
39
- parts = dn2.split(/\s*[,;]\s*/)
39
+ parts = dn.split(/\s*[,;]\s*/)
40
40
 
41
41
  parts.collect do |part|
42
42
  res = {}
@@ -1,5 +1,5 @@
1
1
  module LDAP #:nodoc:
2
2
  class Server #:nodoc:
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
  end
5
5
  end
@@ -17,6 +17,10 @@ Gem::Specification.new do |s|
17
17
  s.summary = %q{A pure-Ruby framework for building LDAP servers}
18
18
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
19
 
20
+ s.required_ruby_version = '>= 1.9'
21
+
20
22
  s.add_development_dependency 'bundler', '~> 1.3'
21
23
  s.add_development_dependency 'rake', '~> 10.0'
24
+ s.add_development_dependency 'ruby-ldap', '~> 0.9.16'
25
+ s.add_development_dependency 'rspec', '~> 3.1'
22
26
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ require 'ldap/server/operation'
4
+
5
+ describe LDAP::Server::Operation do
6
+ let(:server) { double 'server' }
7
+ let(:connection) { double "connection", opt: { schema: schema, server: server } }
8
+ let(:message_id) { 337 }
9
+ subject(:operation) { LDAP::Server::Operation.new connection, message_id }
10
+
11
+ context 'on search' do
12
+ before do
13
+ operation.instance_variable_set :@attributes, attributes
14
+ operation.instance_variable_set :@rescount, 0
15
+ end
16
+
17
+ context 'with schema and wildcard attribute query' do
18
+ let(:schema) do
19
+ double('schema').tap do |schema|
20
+ allow(schema).to receive(:find_attrtype).and_return nil
21
+ allow(schema).to receive(:find_attrtype).with('attr')\
22
+ .and_return double 'attr', usage: nil
23
+ end
24
+ end
25
+ let(:attributes) { %w(*) }
26
+
27
+ describe '#send_SearchResultEntry' do
28
+ it 'correctly handles wildcard attribute' do
29
+ expect(connection).to receive(:write).twice do |message|
30
+ expect(message).to include 'val'
31
+ end
32
+
33
+ operation.send_SearchResultEntry 'o=foo', 'attr' => 'val'
34
+ operation.send_SearchResultEntry 'o=bar', 'attr' => 'val'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
File without changes
@@ -21,11 +21,11 @@ class TestLdapUtil < Test::Unit::TestCase
21
21
  LDAP::Server::Operation.split_dn("CN=Before\\0DAfter,O=Test,C=GB")
22
22
  )
23
23
  res = LDAP::Server::Operation.split_dn("SN=Lu\\C4\\8Di\\C4\\87")
24
- assert_equal([{"sn"=>"Lu\xc4\x8di\xc4\x87"}], res)
24
+ assert_equal([{ "sn" => "Lu\xc4\x8di\xc4\x87".force_encoding('ascii-8bit') }], res)
25
25
 
26
26
  # Just for fun, let's try parsing it as UTF8
27
- r = res[0]["sn"].scan(/./u)
28
- assert_equal(["L", "u", "\xc4\x8d", "i", "\xc4\x87"], r)
27
+ chars = res[0]["sn"].force_encoding('utf-8').scan(/./u)
28
+ assert_equal(["L", "u", "\xc4\x8d", "i", "\xc4\x87"], chars)
29
29
  end
30
30
 
31
31
  def test_join_dn
metadata CHANGED
@@ -1,48 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ldapserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
4
+ version: 0.5.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Candler
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-30 00:00:00.000000000 Z
11
+ date: 2015-02-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '10.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ruby-ldap
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.16
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.16
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
46
69
  description: ruby-ldapserver is a lightweight, pure-Ruby skeleton for implementing
47
70
  LDAP server applications.
48
71
  email: B.Candler@pobox.com
@@ -50,7 +73,7 @@ executables: []
50
73
  extensions: []
51
74
  extra_rdoc_files: []
52
75
  files:
53
- - .gitignore
76
+ - ".gitignore"
54
77
  - COPYING
55
78
  - ChangeLog
56
79
  - Gemfile
@@ -60,6 +83,7 @@ files:
60
83
  - examples/mkcert.rb
61
84
  - examples/rbslapd1.rb
62
85
  - examples/rbslapd2.rb
86
+ - examples/rbslapd2.sql
63
87
  - examples/rbslapd3.rb
64
88
  - examples/speedtest.rb
65
89
  - lib/ldap/server.rb
@@ -76,6 +100,8 @@ files:
76
100
  - lib/ldap/server/util.rb
77
101
  - lib/ldap/server/version.rb
78
102
  - ruby-ldapserver.gemspec
103
+ - spec/operation_spec.rb
104
+ - spec/spec_helper.rb
79
105
  - test/core.schema
80
106
  - test/encoding_test.rb
81
107
  - test/filter_test.rb
@@ -86,37 +112,32 @@ files:
86
112
  - test/util_test.rb
87
113
  homepage: https://github.com/inscitiv/ruby-ldapserver
88
114
  licenses: []
115
+ metadata: {}
89
116
  post_install_message:
90
117
  rdoc_options:
91
- - --main
118
+ - "--main"
92
119
  - README.txt
93
120
  require_paths:
94
121
  - lib
95
122
  required_ruby_version: !ruby/object:Gem::Requirement
96
- none: false
97
123
  requirements:
98
- - - ! '>='
124
+ - - ">="
99
125
  - !ruby/object:Gem::Version
100
- version: '0'
101
- segments:
102
- - 0
103
- hash: 3477786009555667718
126
+ version: '1.9'
104
127
  required_rubygems_version: !ruby/object:Gem::Requirement
105
- none: false
106
128
  requirements:
107
- - - ! '>='
129
+ - - ">="
108
130
  - !ruby/object:Gem::Version
109
131
  version: '0'
110
- segments:
111
- - 0
112
- hash: 3477786009555667718
113
132
  requirements: []
114
133
  rubyforge_project:
115
- rubygems_version: 1.8.25
134
+ rubygems_version: 2.4.4
116
135
  signing_key:
117
- specification_version: 3
136
+ specification_version: 4
118
137
  summary: A pure-Ruby framework for building LDAP servers
119
138
  test_files:
139
+ - spec/operation_spec.rb
140
+ - spec/spec_helper.rb
120
141
  - test/core.schema
121
142
  - test/encoding_test.rb
122
143
  - test/filter_test.rb