ucb_ldap 2.0.0.pre1 → 2.0.0.pre3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/CHANGELOG +137 -135
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/{README → README.md} +82 -80
  7. data/Rakefile +38 -20
  8. data/lib/ucb_ldap.rb +238 -204
  9. data/lib/{ucb_ldap_address.rb → ucb_ldap/address.rb} +106 -106
  10. data/lib/{ucb_ldap_affiliation.rb → ucb_ldap/affiliation.rb} +16 -16
  11. data/lib/{ucb_ldap_entry.rb → ucb_ldap/entry.rb} +455 -448
  12. data/lib/{ucb_ldap_person_job_appointment.rb → ucb_ldap/job_appointment.rb} +77 -79
  13. data/lib/{ucb_ldap_namespace.rb → ucb_ldap/namespace.rb} +40 -50
  14. data/lib/{ucb_ldap_org.rb → ucb_ldap/org.rb} +427 -429
  15. data/lib/{ucb_ldap_person.rb → ucb_ldap/person.rb} +157 -148
  16. data/lib/{person → ucb_ldap/person}/affiliation_methods.rb +23 -22
  17. data/lib/ucb_ldap/person/common_attributes.rb +63 -0
  18. data/lib/{ucb_ldap_schema.rb → ucb_ldap/schema.rb} +28 -28
  19. data/lib/{ucb_ldap_schema_attribute.rb → ucb_ldap/schema_attribute.rb} +152 -153
  20. data/lib/{ucb_ldap_service.rb → ucb_ldap/service.rb} +17 -19
  21. data/lib/{ucb_ldap_student_term.rb → ucb_ldap/student_term.rb} +29 -31
  22. data/lib/ucb_ldap/version.rb +3 -0
  23. data/spec/rails_binds.yml +9 -0
  24. data/spec/spec_helper.rb +43 -0
  25. data/spec/ucb_ldap/address_spec.rb +54 -0
  26. data/spec/ucb_ldap/affiliation_spec.rb +85 -0
  27. data/spec/ucb_ldap/entry_spec.rb +241 -0
  28. data/spec/ucb_ldap/job_appointment_spec.rb +65 -0
  29. data/spec/ucb_ldap/namespace_spec.rb +72 -0
  30. data/spec/ucb_ldap/org_spec.rb +217 -0
  31. data/spec/ucb_ldap/person_spec.rb +225 -0
  32. data/spec/ucb_ldap/schema_attribute_spec.rb +122 -0
  33. data/spec/ucb_ldap/schema_spec.rb +104 -0
  34. data/spec/ucb_ldap/service_spec.rb +127 -0
  35. data/spec/ucb_ldap/student_term_spec.rb +121 -0
  36. data/spec/ucb_ldap_spec.rb +182 -0
  37. data/ucb_ldap.gemspec +20 -27
  38. metadata +113 -64
  39. data/Manifest +0 -23
  40. data/TODO +0 -2
  41. data/lib/person/adv_con_person.rb +0 -0
  42. data/lib/person/generic_attributes.rb +0 -68
  43. data/lib/ucb_ldap_exceptions.rb +0 -27
  44. data/version.yml +0 -1
@@ -0,0 +1,182 @@
1
+ require_relative "spec_helper"
2
+
3
+
4
+ describe "UCB::LDAP" do
5
+ before(:all) do
6
+ UCB::LDAP.clear_instance_variables
7
+ end
8
+
9
+ after(:all) do
10
+ UCB::LDAP.clear_instance_variables
11
+ UCB::LDAP.host = HOST_TEST
12
+ end
13
+
14
+ it "should define host constants" do
15
+ UCB::LDAP::HOST_PRODUCTION.should == 'nds.berkeley.edu'
16
+ UCB::LDAP::HOST_TEST.should == 'nds-test.berkeley.edu'
17
+ end
18
+
19
+ it "should default host to production" do
20
+ UCB::LDAP.host.should == UCB::LDAP::HOST_PRODUCTION
21
+ end
22
+
23
+ it "should allow host to be reset" do
24
+ UCB::LDAP.host = 'foo'
25
+ UCB::LDAP.host.should == 'foo'
26
+ end
27
+
28
+ it "should reconnect when host changes" do
29
+ UCB::LDAP.host = HOST_PRODUCTION
30
+ net_ldap1 = UCB::LDAP.net_ldap
31
+ net_ldap1.should equal(UCB::LDAP.net_ldap)
32
+
33
+ UCB::LDAP.host = HOST_TEST
34
+ net_ldap1.should_not equal(UCB::LDAP.net_ldap)
35
+ end
36
+
37
+ it "should raise BindFailedException given bad host name" do
38
+ UCB::LDAP.host = 'bogus'
39
+ lambda { UCB::LDAP.new_net_ldap }.should raise_error(BindFailedException)
40
+ end
41
+ end
42
+
43
+
44
+ describe "UCB::LDAP binding with rails" do
45
+ before do
46
+ UCB::LDAP.clear_instance_variables
47
+ end
48
+
49
+ after(:all) do
50
+ UCB::LDAP.clear_instance_variables
51
+ UCB::LDAP.host = HOST_TEST
52
+ end
53
+
54
+ it "bind_for_rails should authenticate with environment-specific bind" do
55
+ bind_file = "#{File.dirname(__FILE__)}/rails_binds.yml"
56
+ UCB::LDAP.should_receive(:authenticate).with('username_development', 'password_development')
57
+ UCB::LDAP.bind_for_rails(bind_file, 'development')
58
+
59
+ lambda { UCB::LDAP.bind_for_rails(bind_file, 'bogus') }.should raise_error
60
+ end
61
+
62
+ it "bind_for_rails should raise exception if bind file not found" do
63
+ missing_file = "#{File.dirname(__FILE__)}/missing.yml"
64
+ lambda { UCB::LDAP.bind_for_rails(missing_file, 'development') }.should raise_error # no error raised
65
+ end
66
+ end
67
+
68
+
69
+ describe "UCB::LDAP.new_net_ldap" do
70
+ before(:all) do
71
+ UCB::LDAP.clear_instance_variables
72
+ UCB::LDAP.host = HOST_TEST
73
+ @net_ldap = UCB::LDAP.new_net_ldap
74
+ end
75
+
76
+ after(:all) do
77
+ UCB::LDAP.clear_instance_variables
78
+ UCB::LDAP.host = HOST_TEST
79
+ end
80
+
81
+ it "should return Net:LDAP instance" do
82
+ @net_ldap.should be_instance_of(Net::LDAP)
83
+ end
84
+
85
+ it "should use host from UCB::LDAP.host" do
86
+ @net_ldap.host.should == HOST_TEST
87
+
88
+ @net_ldap = UCB::LDAP.new_net_ldap
89
+ @net_ldap.host.should equal(UCB::LDAP.host)
90
+ end
91
+
92
+ it "should use port 636" do
93
+ @net_ldap.port.should == 636
94
+ end
95
+
96
+ it "should use simple_tls encryption" do
97
+ @net_ldap.instance_variable_get(:@encryption).should == {:method => :simple_tls}
98
+ end
99
+
100
+ it "should use anonymous authorization" do
101
+ @net_ldap.instance_variable_get(:@auth).should == {:method => :anonymous}
102
+ end
103
+ end
104
+
105
+
106
+ describe "UCB::LDAP.net_ldap w/anonymous bind" do
107
+ it "should return a cached Net::LDAP instance" do
108
+ @net_ldap_1 = UCB::LDAP.net_ldap
109
+ @net_ldap_1.should be_instance_of(Net::LDAP)
110
+
111
+ @net_ldap_2 = UCB::LDAP.net_ldap
112
+ @net_ldap_2.should equal(@net_ldap_1)
113
+ end
114
+ end
115
+
116
+
117
+ describe "UCB::LDAP.authenticate" do
118
+ before(:all) do
119
+ UCB::LDAP.clear_instance_variables
120
+ UCB::LDAP.host = HOST_TEST
121
+ end
122
+
123
+ after(:all) do
124
+ UCB::LDAP.clear_instance_variables
125
+ UCB::LDAP.host = HOST_TEST
126
+ end
127
+
128
+ it "should raise BindFailedException with bad username/password" do
129
+ lambda { UCB::LDAP.authenticate("bogus", "bogus") }.should raise_error(BindFailedException)
130
+ end
131
+
132
+ it "should create new Net::LDAP instance" do
133
+ net_ldap = UCB::LDAP.net_ldap
134
+ org_bind()
135
+ UCB::LDAP.net_ldap.should_not equal(net_ldap)
136
+ end
137
+ end
138
+
139
+
140
+ describe "UCB::LDAP.clear_authentication" do
141
+ it "should remove authentication and revert to anonymous bind" do
142
+ org_bind
143
+ net_ldap1 = UCB::LDAP.net_ldap
144
+ net_ldap1.instance_variable_get(:@auth)[:method].should == :simple
145
+
146
+ UCB::LDAP.clear_authentication
147
+ UCB::LDAP.net_ldap.instance_variable_get(:@auth)[:method].should == :anonymous
148
+ net_ldap1.should_not equal(UCB::LDAP.net_ldap)
149
+ end
150
+ end
151
+
152
+
153
+ describe UCB::LDAP, "date/datetime parsing" do
154
+ before(:all) do
155
+ @local_date_string = '20010203000000'
156
+ end
157
+
158
+ it "parsing returns nil given nil" do
159
+ UCB::LDAP.local_date_parse(nil).should be_nil
160
+ UCB::LDAP.local_datetime_parse(nil).should be_nil
161
+ end
162
+
163
+ it "local_date_parse should take local DateTime and return local Date" do
164
+ UCB::LDAP.local_date_parse('20010203000000').to_s.should == '2001-02-03'
165
+ UCB::LDAP.local_date_parse('20010203235959').to_s.should == '2001-02-03'
166
+ end
167
+
168
+ it "local_date_parse should take UTC DateTime and return local Date" do
169
+ UCB::LDAP.local_date_parse('20010203080000Z').to_s.should == '2001-02-03'
170
+ UCB::LDAP.local_date_parse('20010203060000Z').to_s.should == '2001-02-02'
171
+ end
172
+
173
+ it "local_datetime_parse should take local DateTime and return local Date" do
174
+ UCB::LDAP.local_datetime_parse('20010203000000').to_s.should == '2001-02-03T00:00:00-08:00'
175
+ UCB::LDAP.local_datetime_parse('20010203235959').to_s.should == '2001-02-03T23:59:59-08:00'
176
+ end
177
+
178
+ it "local_datetime_parse should take UTC DateTime and return local Date" do
179
+ UCB::LDAP.local_datetime_parse('20010203080000Z').to_s.should == '2001-02-03T00:00:00-08:00'
180
+ UCB::LDAP.local_datetime_parse('20010203060000Z').to_s.should == '2001-02-02T22:00:00-08:00'
181
+ end
182
+ end
data/ucb_ldap.gemspec CHANGED
@@ -1,32 +1,25 @@
1
- # -*- encoding: utf-8 -*-
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'ucb_ldap/version'
2
4
 
3
- Gem::Specification.new do |s|
4
- s.name = "ucb_ldap"
5
- s.version = "2.0.0.pre1"
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ucb_ldap"
7
+ spec.version = UcbLdap::VERSION
8
+ spec.authors = ["Steven Hansen, Steve Downey"]
9
+ spec.email = %w{sahglie@gmail.com}
10
+ spec.description = %q{Convenience classes for interacing with UCB's LDAP directory}
11
+ spec.summary = %q{Convenience classes for interacing with UCB's LDAP directory}
12
+ spec.homepage = "https://github.com/sahglie/ucb-ldap"
13
+ spec.license = "MIT"
6
14
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Steven Hansen, Steve Downey, Lucas Rockwell"]
9
- s.date = "2012-04-24"
10
- s.description = "Convenience classes for interacing with UCB's LDAP directory"
11
- s.email = "runner@berkeley.edu"
12
- s.extra_rdoc_files = ["README", "lib/person/adv_con_person.rb", "lib/person/affiliation_methods.rb", "lib/person/generic_attributes.rb", "lib/ucb_ldap.rb", "lib/ucb_ldap_address.rb", "lib/ucb_ldap_affiliation.rb", "lib/ucb_ldap_entry.rb", "lib/ucb_ldap_exceptions.rb", "lib/ucb_ldap_namespace.rb", "lib/ucb_ldap_org.rb", "lib/ucb_ldap_person.rb", "lib/ucb_ldap_person_job_appointment.rb", "lib/ucb_ldap_schema.rb", "lib/ucb_ldap_schema_attribute.rb", "lib/ucb_ldap_service.rb", "lib/ucb_ldap_student_term.rb"]
13
- s.files = ["CHANGELOG", "Manifest", "README", "Rakefile", "TODO", "lib/person/adv_con_person.rb", "lib/person/affiliation_methods.rb", "lib/person/generic_attributes.rb", "lib/ucb_ldap.rb", "lib/ucb_ldap_address.rb", "lib/ucb_ldap_affiliation.rb", "lib/ucb_ldap_entry.rb", "lib/ucb_ldap_exceptions.rb", "lib/ucb_ldap_namespace.rb", "lib/ucb_ldap_org.rb", "lib/ucb_ldap_person.rb", "lib/ucb_ldap_person_job_appointment.rb", "lib/ucb_ldap_schema.rb", "lib/ucb_ldap_schema_attribute.rb", "lib/ucb_ldap_service.rb", "lib/ucb_ldap_student_term.rb", "schema/schema.yml", "version.yml", "ucb_ldap.gemspec"]
14
- s.homepage = "http://ucbrb.rubyforge.org/ucb_ldap"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ucb_ldap", "--main", "README"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = "ucbrb"
18
- s.rubygems_version = "1.8.15"
19
- s.summary = "Convenience classes for interacing with UCB's LDAP directory"
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
20
19
 
21
- if s.respond_to? :specification_version then
22
- s.specification_version = 3
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
23
23
 
24
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- s.add_runtime_dependency(%q<net-ldap>, ["= 0.2.2"])
26
- else
27
- s.add_dependency(%q<net-ldap>, ["= 0.2.2"])
28
- end
29
- else
30
- s.add_dependency(%q<net-ldap>, ["= 0.2.2"])
31
- end
24
+ spec.add_runtime_dependency "net-ldap", "0.2.2"
32
25
  end
metadata CHANGED
@@ -1,102 +1,151 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucb_ldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre1
5
- prerelease: 6
4
+ version: 2.0.0.pre3
6
5
  platform: ruby
7
6
  authors:
8
- - Steven Hansen, Steve Downey, Lucas Rockwell
7
+ - Steven Hansen, Steve Downey
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-24 00:00:00.000000000 Z
11
+ date: 2013-06-08 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
14
55
  - !ruby/object:Gem::Dependency
15
56
  name: net-ldap
16
- requirement: &2159990520 !ruby/object:Gem::Requirement
17
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
18
58
  requirements:
19
- - - =
59
+ - - '='
20
60
  - !ruby/object:Gem::Version
21
61
  version: 0.2.2
22
62
  type: :runtime
23
63
  prerelease: false
24
- version_requirements: *2159990520
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.2
25
69
  description: Convenience classes for interacing with UCB's LDAP directory
26
- email: runner@berkeley.edu
70
+ email:
71
+ - sahglie@gmail.com
27
72
  executables: []
28
73
  extensions: []
29
- extra_rdoc_files:
30
- - README
31
- - lib/person/adv_con_person.rb
32
- - lib/person/affiliation_methods.rb
33
- - lib/person/generic_attributes.rb
34
- - lib/ucb_ldap.rb
35
- - lib/ucb_ldap_address.rb
36
- - lib/ucb_ldap_affiliation.rb
37
- - lib/ucb_ldap_entry.rb
38
- - lib/ucb_ldap_exceptions.rb
39
- - lib/ucb_ldap_namespace.rb
40
- - lib/ucb_ldap_org.rb
41
- - lib/ucb_ldap_person.rb
42
- - lib/ucb_ldap_person_job_appointment.rb
43
- - lib/ucb_ldap_schema.rb
44
- - lib/ucb_ldap_schema_attribute.rb
45
- - lib/ucb_ldap_service.rb
46
- - lib/ucb_ldap_student_term.rb
74
+ extra_rdoc_files: []
47
75
  files:
76
+ - .gitignore
48
77
  - CHANGELOG
49
- - Manifest
50
- - README
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
51
81
  - Rakefile
52
- - TODO
53
- - lib/person/adv_con_person.rb
54
- - lib/person/affiliation_methods.rb
55
- - lib/person/generic_attributes.rb
56
82
  - lib/ucb_ldap.rb
57
- - lib/ucb_ldap_address.rb
58
- - lib/ucb_ldap_affiliation.rb
59
- - lib/ucb_ldap_entry.rb
60
- - lib/ucb_ldap_exceptions.rb
61
- - lib/ucb_ldap_namespace.rb
62
- - lib/ucb_ldap_org.rb
63
- - lib/ucb_ldap_person.rb
64
- - lib/ucb_ldap_person_job_appointment.rb
65
- - lib/ucb_ldap_schema.rb
66
- - lib/ucb_ldap_schema_attribute.rb
67
- - lib/ucb_ldap_service.rb
68
- - lib/ucb_ldap_student_term.rb
83
+ - lib/ucb_ldap/address.rb
84
+ - lib/ucb_ldap/affiliation.rb
85
+ - lib/ucb_ldap/entry.rb
86
+ - lib/ucb_ldap/job_appointment.rb
87
+ - lib/ucb_ldap/namespace.rb
88
+ - lib/ucb_ldap/org.rb
89
+ - lib/ucb_ldap/person.rb
90
+ - lib/ucb_ldap/person/affiliation_methods.rb
91
+ - lib/ucb_ldap/person/common_attributes.rb
92
+ - lib/ucb_ldap/schema.rb
93
+ - lib/ucb_ldap/schema_attribute.rb
94
+ - lib/ucb_ldap/service.rb
95
+ - lib/ucb_ldap/student_term.rb
96
+ - lib/ucb_ldap/version.rb
69
97
  - schema/schema.yml
70
- - version.yml
98
+ - spec/rails_binds.yml
99
+ - spec/spec_helper.rb
100
+ - spec/ucb_ldap/address_spec.rb
101
+ - spec/ucb_ldap/affiliation_spec.rb
102
+ - spec/ucb_ldap/entry_spec.rb
103
+ - spec/ucb_ldap/job_appointment_spec.rb
104
+ - spec/ucb_ldap/namespace_spec.rb
105
+ - spec/ucb_ldap/org_spec.rb
106
+ - spec/ucb_ldap/person_spec.rb
107
+ - spec/ucb_ldap/schema_attribute_spec.rb
108
+ - spec/ucb_ldap/schema_spec.rb
109
+ - spec/ucb_ldap/service_spec.rb
110
+ - spec/ucb_ldap/student_term_spec.rb
111
+ - spec/ucb_ldap_spec.rb
71
112
  - ucb_ldap.gemspec
72
- homepage: http://ucbrb.rubyforge.org/ucb_ldap
73
- licenses: []
113
+ homepage: https://github.com/sahglie/ucb-ldap
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
74
117
  post_install_message:
75
- rdoc_options:
76
- - --line-numbers
77
- - --inline-source
78
- - --title
79
- - Ucb_ldap
80
- - --main
81
- - README
118
+ rdoc_options: []
82
119
  require_paths:
83
120
  - lib
84
121
  required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
122
  requirements:
87
- - - ! '>='
123
+ - - '>='
88
124
  - !ruby/object:Gem::Version
89
125
  version: '0'
90
126
  required_rubygems_version: !ruby/object:Gem::Requirement
91
- none: false
92
127
  requirements:
93
- - - ! '>='
128
+ - - '>'
94
129
  - !ruby/object:Gem::Version
95
- version: '1.2'
130
+ version: 1.3.1
96
131
  requirements: []
97
- rubyforge_project: ucbrb
98
- rubygems_version: 1.8.15
132
+ rubyforge_project:
133
+ rubygems_version: 2.0.2
99
134
  signing_key:
100
- specification_version: 3
135
+ specification_version: 4
101
136
  summary: Convenience classes for interacing with UCB's LDAP directory
102
- test_files: []
137
+ test_files:
138
+ - spec/rails_binds.yml
139
+ - spec/spec_helper.rb
140
+ - spec/ucb_ldap/address_spec.rb
141
+ - spec/ucb_ldap/affiliation_spec.rb
142
+ - spec/ucb_ldap/entry_spec.rb
143
+ - spec/ucb_ldap/job_appointment_spec.rb
144
+ - spec/ucb_ldap/namespace_spec.rb
145
+ - spec/ucb_ldap/org_spec.rb
146
+ - spec/ucb_ldap/person_spec.rb
147
+ - spec/ucb_ldap/schema_attribute_spec.rb
148
+ - spec/ucb_ldap/schema_spec.rb
149
+ - spec/ucb_ldap/service_spec.rb
150
+ - spec/ucb_ldap/student_term_spec.rb
151
+ - spec/ucb_ldap_spec.rb