ucb_ldap 2.0.0 → 3.0.0

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.
@@ -1,122 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
-
4
- describe "The UCB::LDAP::Schema::Attribute constructor" do
5
- it "should set name instance variable" do
6
- UCB::LDAP::Schema::Attribute.new("name" => "attr_name").name.should == "attr_name"
7
- end
8
-
9
- it "should set type instance variable" do
10
- UCB::LDAP::Schema::Attribute.new("syntax" => "string").type.should == "string"
11
- end
12
-
13
- it "should set description instance variable" do
14
- UCB::LDAP::Schema::Attribute.new("description" => "attr_descr").description.should == "attr_descr"
15
- end
16
-
17
- it "should aliases instance variable (empty and present)" do
18
- UCB::LDAP::Schema::Attribute.new({}).aliases.should == []
19
- UCB::LDAP::Schema::Attribute.new("aliases" => ["a", "b"]).aliases.should == ["a", "b"]
20
- end
21
-
22
- it "should set required instance variable" do
23
- UCB::LDAP::Schema::Attribute.new("required" => true).required?.should be_true
24
- UCB::LDAP::Schema::Attribute.new("required" => false).required?.should be_false
25
- end
26
-
27
- it "should set multi_valued instance variable" do
28
- UCB::LDAP::Schema::Attribute.new("multi" => true).multi_valued?.should be_true
29
- UCB::LDAP::Schema::Attribute.new("multi" => false).multi_valued?.should be_false
30
- end
31
- end
32
-
33
-
34
- describe "Schema::Attribute get_value() for multi_valued" do
35
- it "should return array when multi_valued" do
36
- Schema::Attribute.new("multi" => true, "syntax" => "string").get_value(%w{1 2}).should == %w{1 2}
37
- end
38
-
39
- it "should return empty array when multi_valued and no value" do
40
- Schema::Attribute.new("multi" => true, "syntax" => "string").get_value(nil).should == []
41
- end
42
- end
43
-
44
-
45
- describe "Schema::Attribute get_value() for not multi_valued" do
46
- it "should return scalar when not multi_valued" do
47
- Schema::Attribute.new("multi" => false, "syntax" => "string").get_value(%w{1}).should == "1"
48
- end
49
-
50
- it "should return nil when not multi_valued and no value" do
51
- Schema::Attribute.new("multi" => false).get_value(nil).should be_nil
52
- end
53
- end
54
-
55
-
56
- describe "Schema::Attribute get_value() for string" do
57
- it "returns string" do
58
- Schema::Attribute.new("syntax" => "string", "multi" => true).get_value(%w{1 2}).should == ["1", "2"]
59
- Schema::Attribute.new("syntax" => "string", "multi" => false).get_value(%w{1}).should == "1"
60
- end
61
- end
62
-
63
-
64
- describe "Schema::Attribute get_value() for integer" do
65
- it "returns integer" do
66
- Schema::Attribute.new("syntax" => "integer", "multi" => true).get_value(%w{1 2}).should == [1, 2]
67
- Schema::Attribute.new("syntax" => "integer", "multi" => false).get_value(%w{1}).should == 1
68
- end
69
- end
70
-
71
-
72
- describe "Schema::Attribute get_value() for boolean" do
73
- it "returns boolean" do
74
- Schema::Attribute.new("syntax" => "boolean").get_value(["true"]).should be_true
75
- Schema::Attribute.new("syntax" => "boolean").get_value(["1"]).should be_true
76
- Schema::Attribute.new("syntax" => "boolean").get_value(["false"]).should be_false
77
- Schema::Attribute.new("syntax" => "boolean").get_value([""]).should be_false
78
- Schema::Attribute.new("syntax" => "boolean").get_value(nil).should be_false
79
- end
80
- end
81
-
82
-
83
- describe "Schema::Attribute get_value() for timestamp" do
84
- it "returns Date" do
85
- schema_attribute = Schema::Attribute.new("syntax" => "timestamp")
86
- datetime = schema_attribute.get_value(["19980101123456Z"])
87
- datetime.class.should == DateTime
88
- datetime.to_s.should == "1998-01-01T04:34:56-08:00"
89
-
90
- schema_attribute.get_value(nil).should be_nil
91
- end
92
- end
93
-
94
-
95
- describe "Schema::Attribute ldap_value()" do
96
- before do
97
- @a = Schema::Attribute.new({})
98
- end
99
-
100
- it "should return an Array when given an Array" do
101
- @a.ldap_value(["foo"]).should == ["foo"]
102
- end
103
-
104
- it "should return an Array when given a scalar" do
105
- @a.ldap_value("foo").should == ["foo"]
106
- end
107
-
108
- it "should return Array of String regardless of input type" do
109
- @a.ldap_value(1).should == ["1"]
110
- @a.ldap_value([1, true, "three"]).should == ["1", "true", "three"]
111
- end
112
-
113
- it "should return nil when passed nil" do
114
- @a.ldap_value(nil).should be_nil
115
- end
116
-
117
- it "should remove leading/trailing spaces, any newlines" do
118
- @a.ldap_value(' foo').should == ['foo']
119
- @a.ldap_value('foo ').should == ['foo']
120
- @a.ldap_value("f\noo").should == ['foo']
121
- end
122
- end
@@ -1,104 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
-
4
- describe "UCB::LDAP::Schema" do
5
- before(:all) do
6
- @schema_yaml = IO.read(Schema::SCHEMA_FILE)
7
- end
8
-
9
- before(:each) do
10
- Schema.schema_hash = nil
11
- Schema.schema_file = nil
12
- Schema.schema_base_url = nil
13
- Schema.schema_content_path = nil
14
- end
15
-
16
- it "should define SCHEMA_URL" do
17
- Schema::SCHEMA_BASE_URL.class.should == String
18
- end
19
-
20
- it "schema_base_url() should default to SCHEMA_BASE_URL constant" do
21
- Schema.schema_base_url.should == Schema::SCHEMA_BASE_URL
22
- end
23
-
24
- it "schema_base_url() can be reset" do
25
- Schema.schema_base_url = "foo"
26
- Schema.schema_base_url.should == "foo"
27
- end
28
-
29
- it "schema_content_path() should default to SCHEMA_CONTENT_PATH constant" do
30
- Schema.schema_content_path.should == Schema::SCHEMA_CONTENT_PATH
31
- end
32
-
33
- it "schema_content_path() can be reset" do
34
- Schema.schema_content_path = "foo"
35
- Schema.schema_content_path.should == "foo"
36
- end
37
-
38
- it "should get schema yaml from url" do
39
- @yaml = Schema.yaml_from_url
40
- %w{person: org:}.each do |entity|
41
- @yaml.should include(entity)
42
- end
43
- end
44
-
45
- it "should load attributes from url" do
46
- Schema.schema_hash_i.should be_nil
47
- Schema.should_receive(:yaml_from_url).and_return(@schema_yaml)
48
- Schema.load_attributes_from_url
49
- verify_schema_hash
50
- end
51
-
52
- it "should define SCHEMA_FILE" do
53
- Schema::SCHEMA_FILE.class.should == String
54
- end
55
-
56
- it "schema_file() should default to SCHEMA_FILE constant" do
57
- Schema.schema_file.should == Schema::SCHEMA_FILE
58
- end
59
-
60
- it "schema_file() can be reset" do
61
- Schema.schema_file = "foo"
62
- Schema.schema_file.should == "foo"
63
- end
64
-
65
- it "should get schema yaml from file" do
66
- yaml = Schema.yaml_from_file
67
- verify_yaml(yaml)
68
- end
69
-
70
- it "should load attributes from file" do
71
- Schema.schema_hash_i.should be_nil
72
- Schema.load_attributes_from_file
73
- verify_schema_hash
74
- end
75
-
76
- it "should load_attributes from url if available" do
77
- Schema.schema_hash_i.should be_nil
78
- Schema.should_receive(:yaml_from_url).and_return(@schema_yaml)
79
- Schema.should_not_receive(:load_attributes_from_file)
80
- UCB::LDAP::Schema.load_attributes
81
- verify_schema_hash
82
- end
83
-
84
- it "should load_attributes from local file if url data not available" do
85
- Schema.schema_hash_i.should be_nil
86
- Schema.should_receive(:load_attributes_from_url).and_raise("schema unavailable from url")
87
- Schema.load_attributes
88
- verify_schema_hash
89
- end
90
-
91
- # Verify we have something that looks like the schema yaml file
92
- def verify_yaml(yaml)
93
- yaml.should be_instance_of(String)
94
- yaml.should have_at_least(40_000).characters
95
- %w{person: personAddress: syntax:}.each{|s| yaml.should include(s)}
96
- end
97
-
98
- # Verify schema_hash looks right
99
- def verify_schema_hash
100
- Schema.schema_hash_i.should be_instance_of(Hash)
101
- %w{person org}.each{|e| Schema.schema_hash.keys.should include(e)}
102
- end
103
-
104
- end
@@ -1,127 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
-
4
- describe UCB::LDAP::Service do
5
- before(:all) do
6
- service_bind
7
- @student_uid = "61065"
8
- @student = Person.find_by_uid(@student_uid)
9
- @dt_str = '20010203080000Z'
10
- @dt_exp = '2001-02-03T00:00:00-08:00'
11
- end
12
-
13
- after(:all) do
14
- UCB::LDAP.clear_authentication
15
- end
16
-
17
- it "find_by_uid(uid) should return terms" do
18
- Service.find_by_uid(@student_uid).class.should == Array
19
- end
20
-
21
- it "Person should find services" do
22
- @student.services.class.should == Array
23
- end
24
-
25
- it "should return eligible_by" do
26
- Service.new({}).eligible_by.should be_nil
27
- Service.new({:berkeleyEduPersonServiceEligibleBy => ['foo']}).eligible_by.should == 'foo'
28
- end
29
-
30
- it "should return eligible_date" do
31
- Service.new({}).eligible_date.should be_nil
32
- s = Service.new({:berkeleyEduPersonServiceEligibleDate => [@dt_str]})
33
- s.eligible_date.class.should == DateTime
34
- s.eligible_date.to_s.should == @dt_exp
35
- end
36
-
37
- it "should return ended_by" do
38
- Service.new({}).ended_by.should be_nil
39
- Service.new({:berkeleyEduPersonServiceEndBy => ['foo']}).ended_by.should == 'foo'
40
- end
41
-
42
- it "should return end_date" do
43
- Service.new({}).end_date.should be_nil
44
- s = Service.new({:berkeleyEduPersonServiceEndDate => [@dt_str]})
45
- s.end_date.class.should == DateTime
46
- s.end_date.to_s.should == @dt_exp
47
- end
48
-
49
- it "should return entered_by" do
50
- Service.new({}).entered_by.should be_nil
51
- Service.new({:berkeleyEduPersonServiceEnteredBy => ['foo']}).entered_by.should == 'foo'
52
- end
53
-
54
- it "should return entered_date" do
55
- Service.new({}).entered_date.should be_nil
56
- s = Service.new({:berkeleyEduPersonServiceEnteredDate => [@dt_str]})
57
- s.entered_date.class.should == DateTime
58
- s.entered_date.to_s.should == @dt_exp
59
- end
60
-
61
- it "should return level" do
62
- Service.new({}).level.should be_nil
63
- Service.new({:berkeleyEduPersonServiceLevel => ['42']}).level.should == 42
64
- end
65
-
66
- it "should return modified_by" do
67
- Service.new({}).modified_by.should be_nil
68
- Service.new({:berkeleyEduPersonServiceModifiedBy => ['foo']}).modified_by.should == 'foo'
69
- end
70
-
71
- it "should return modified_date" do
72
- Service.new({}).modified_date.should be_nil
73
- s = Service.new({:berkeleyEduPersonServiceModifiedDate => [@dt_str]})
74
- s.modified_date.class.should == DateTime
75
- s.modified_date.to_s.should == @dt_exp
76
- end
77
-
78
- it "should return naughty_bit" do
79
- Service.new({}).naughty_bit.should be_false
80
- Service.new({:berkeleyEduPersonServiceNaughtyBit => ['true']}).naughty_bit.should be_true
81
- end
82
-
83
- it "should return notified_by" do
84
- Service.new({}).notified_by.should be_nil
85
- Service.new({:berkeleyEduPersonServiceNotifyBy => ['foo']}).notified_by.should == 'foo'
86
- end
87
-
88
- it "should return notify_date" do
89
- Service.new({}).notify_date.should be_nil
90
- s = Service.new({:berkeleyEduPersonServiceNotifyDate => [@dt_str]})
91
- s.notify_date.class.should == DateTime
92
- s.notify_date.to_s.should == @dt_exp
93
- end
94
-
95
- it "should return stopped_by" do
96
- Service.new({}).stopped_by.should be_nil
97
- Service.new({:berkeleyEduPersonServiceStopBy => ['foo']}).stopped_by.should == 'foo'
98
- end
99
-
100
- it "should return stop_date" do
101
- Service.new({}).stop_date.should be_nil
102
- s = Service.new({:berkeleyEduPersonServiceStopDate => [@dt_str]})
103
- s.stop_date.class.should == DateTime
104
- s.stop_date.to_s.should == @dt_exp
105
- end
106
-
107
- it "should return value" do
108
- Service.new({}).value.should be_nil
109
- Service.new({:berkeleyEduPersonServiceValue => ['foo']}).value.should == 'foo'
110
- end
111
-
112
- it "should return service" do
113
- Service.new({}).service.should be_nil
114
- Service.new({:berkeleyEduService => ['foo']}).service.should == 'foo'
115
- end
116
-
117
- it "should return common_name" do
118
- Service.new({}).common_name.should == []
119
- Service.new({:cn => ['foo']}).common_name.should == ['foo']
120
- end
121
-
122
- it "should return description" do
123
- Service.new({}).description.should be_nil
124
- Service.new({:description => ['foo']}).description.should == 'foo'
125
- end
126
- end
127
-
@@ -1,121 +0,0 @@
1
- require_relative "../spec_helper"
2
-
3
- describe "UCB::LDAP::StudentTerm" do
4
- before(:all) do
5
- job_appointment_bind
6
- @student_uid = "191501"
7
- @student = Person.find_by_uid(@student_uid)
8
- @datetime_string = '20010203040506Z'
9
- @date_expected = '2001-02-03'
10
- @datetime_expected = '2001-02-02T20:05:06-08:00'
11
- end
12
-
13
- before(:each) do
14
- end
15
-
16
- after(:all) do
17
- UCB::LDAP.clear_authentication
18
- end
19
-
20
- it "find_by_uid(uid) should return terms" do
21
- StudentTerm.find_by_uid(@student_uid).class.should == Array
22
- end
23
-
24
- it "should be able to get terms from UCB::LDAP::Person instance" do
25
- @student.student_terms.class.should == Array
26
- end
27
-
28
- it "returns change_datetime" do
29
- StudentTerm.new({}).change_datetime.should be_nil
30
- StudentTerm.new({:berkeleyEduStuChangeDate => [@datetime_string]}).change_datetime.to_s.should == @datetime_expected
31
- end
32
-
33
- it "returns college_code" do
34
- StudentTerm.new({}).college_code.should be_nil
35
- StudentTerm.new({:berkeleyEduStuCollegeCode => ['foo']}).college_code.should == 'foo'
36
- end
37
-
38
- it "returns college_name" do
39
- StudentTerm.new({}).college_name.should be_nil
40
- StudentTerm.new({:berkeleyEduStuCollegeName => ['foo']}).college_name.should == 'foo'
41
- end
42
-
43
- it "returns level_code" do
44
- StudentTerm.new({}).level_code.should be_nil
45
- StudentTerm.new({:berkeleyEduStuEduLevelCode => ['foo']}).level_code.should == 'foo'
46
- end
47
-
48
-
49
- it "returns level_name" do
50
- StudentTerm.new({}).level_name.should be_nil
51
- StudentTerm.new({:berkeleyEduStuEduLevelName => ['foo']}).level_name.should == 'foo'
52
- end
53
-
54
-
55
- it "returns role_code" do
56
- StudentTerm.new({}).role_code.should be_nil
57
- StudentTerm.new({:berkeleyEduStuEduRoleCode => ['foo']}).role_code.should == 'foo'
58
- end
59
-
60
-
61
- it "returns role_name" do
62
- StudentTerm.new({}).role_name.should be_nil
63
- StudentTerm.new({:berkeleyEduStuEduRoleName => ['foo']}).role_name.should == 'foo'
64
- end
65
-
66
-
67
- it "returns major_code" do
68
- StudentTerm.new({}).major_code.should be_nil
69
- StudentTerm.new({:berkeleyEduStuMajorCode => ['foo']}).major_code.should == 'foo'
70
- end
71
-
72
-
73
- it "returns major_name" do
74
- StudentTerm.new({}).major_name.should be_nil
75
- StudentTerm.new({:berkeleyEduStuMajorName => ['foo']}).major_name.should == 'foo'
76
- end
77
-
78
-
79
- it "returns registration_status_code" do
80
- StudentTerm.new({}).registration_status_code.should be_nil
81
- StudentTerm.new({:berkeleyEduStuRegStatCode => ['foo']}).registration_status_code.should == 'foo'
82
- end
83
-
84
-
85
- it "returns registration_status_name" do
86
- StudentTerm.new({}).registration_status_name.should be_nil
87
- StudentTerm.new({:berkeleyEduStuRegStatName => ['foo']}).registration_status_name.should == 'foo'
88
- end
89
-
90
-
91
- it "returns term_code" do
92
- StudentTerm.new({}).term_code.should be_nil
93
- StudentTerm.new({:berkeleyEduStuTermCode => ['foo']}).term_code.should == 'foo'
94
- end
95
-
96
-
97
- it "returns term_name" do
98
- StudentTerm.new({}).term_name.should be_nil
99
- StudentTerm.new({:berkeleyEduStuTermName => ['foo']}).term_name.should == 'foo'
100
- end
101
-
102
-
103
- it "returns term_status" do
104
- StudentTerm.new({}).term_status.should be_nil
105
- StudentTerm.new({:berkeleyEduStuTermStatus => ['foo']}).term_status.should == 'foo'
106
- end
107
-
108
-
109
- it "returns term_year" do
110
- StudentTerm.new({}).term_year.should be_nil
111
- StudentTerm.new({:berkeleyEduStuTermYear => ['2000']}).term_year.should == 2000
112
- end
113
-
114
-
115
- it "returns under_graduate_code" do
116
- StudentTerm.new({}).under_graduate_code.should be_nil
117
- StudentTerm.new({:berkeleyEduStuUGCode => ['foo']}).under_graduate_code.should == 'foo'
118
- end
119
-
120
- end
121
-