uaeds 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +1 -0
- data/lib/uaeds.rb +3 -0
- data/lib/uaeds/dsml.rb +55 -0
- data/lib/uaeds/dsml_person.rb +101 -0
- data/lib/uaeds/eds.rb +36 -0
- data/lib/uaeds/eds_dsml.rb +21 -0
- data/lib/uaeds/eds_json.rb +53 -0
- data/lib/uaeds/json_person.rb +101 -0
- data/lib/uaeds/version.rb +3 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/uaeds_spec.rb +167 -0
- data/uaeds.gemspec +28 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b849867af133bd9bb166313fc73662dbf25cf5ed
|
4
|
+
data.tar.gz: 2dfdb9cf4d56f46d74f2b14603bf3b92448b68cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e94e522bd19724a65c6d08206085e04c86bc646412c91ad26f3261446d8303b43c20d5cce85bd22c8d3fe987a4c6df7620ddc52cb913ff5707ef52dac6ab652b
|
7
|
+
data.tar.gz: 742f3c771eb701d90454ec4b0b119299deb730787b5adf018af15b62b8c78f91fdbc677c935e358f8c2cef268371bef1861195114c89ab8a9a1783446cd637ec
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
credential.in
|
19
|
+
test_cred.in
|
20
|
+
test_creds.in
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 dgsan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Uaeds
|
2
|
+
|
3
|
+
## About UA EDS
|
4
|
+
|
5
|
+
UA EDS is a gem that provides a wrapper to basic EDS DSML/JSON endpoint functionality as provided by the UA.
|
6
|
+
|
7
|
+
The code isn't the most beautiful and test coverage is mediocre, and it probably has one or 2 gotchas, but it works.
|
8
|
+
|
9
|
+
The tests mostly cover integration, not line by line units. It is perfectly possible to mock documents for unit testing by monkey patching in a method to set the local document to a particular value, but it hasn't been done. Consider it a todo.
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
You have a choice between `EdsDSML` and `EdsJSON`. The difference is that DSML requires access to the DSML API endpoint and abstracts an XML document to find properties, while JSON uses a JSON-providing endpoint and abstracts JSON parsed into a hash.
|
15
|
+
|
16
|
+
Either way, you need to provide an endpoint, EDS user, and access key for library to use.
|
17
|
+
```ruby
|
18
|
+
eds = EdsDSML.new("https://<endpoint>", <user>, <key>)
|
19
|
+
person = eds.person_by_netid(<netid>)
|
20
|
+
person.uaid
|
21
|
+
person.uid
|
22
|
+
person.name
|
23
|
+
# ...
|
24
|
+
|
25
|
+
```
|
26
|
+
Whether you choose JSON or DSML endpoints, it works pretty much the same way.
|
27
|
+
|
28
|
+
To get an unmapped attribute, use `.lookup_value('camelCaseValue')`, which should return `nil` for unvalued items.
|
29
|
+
|
30
|
+
If a document isn't found, rather than getting `nil` or an error back, all values on the retreived object should be `nil`. (Less than ideal.)
|
31
|
+
|
32
|
+
If using the JSON flavor, it's possible that a poorly formed request will grab multiple results and trigger an `ArgumentError: Argument is not a hash`. (Once again, currently less than ideal.)
|
33
|
+
|
34
|
+
|
35
|
+
## Testing
|
36
|
+
|
37
|
+
Currently, `bundle exec rspec spec` is the way to run tests. (No rake job yet.) It wil prompt for EDS user name, EDS key, DSML endpoint, JSON endpoint, and a 'NetID' for testing purposes.
|
38
|
+
|
39
|
+
If you feel lazy, it should work if you create a file `test_creds.in` formatted like:
|
40
|
+
```
|
41
|
+
<user>
|
42
|
+
<password>
|
43
|
+
<DSML endpoint>
|
44
|
+
<JSON endpoint>
|
45
|
+
<Test NetID>
|
46
|
+
```
|
47
|
+
and run `bundle exec rspec spec < test_creds.in`, though you might get some `stty: standard input: Inappropriate ioctl for device` messages.
|
48
|
+
|
49
|
+
The tests themselves are currently ugly - not a whole lot of experience with rspec yet.
|
50
|
+
|
51
|
+
## Installation
|
52
|
+
|
53
|
+
Add this line to your application's Gemfile:
|
54
|
+
|
55
|
+
gem 'uaeds'
|
56
|
+
|
57
|
+
And then execute:
|
58
|
+
|
59
|
+
$ bundle
|
60
|
+
|
61
|
+
Or install it yourself as:
|
62
|
+
|
63
|
+
$ gem install uaeds
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
1. Fork it
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/uaeds.rb
ADDED
data/lib/uaeds/dsml.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "uaeds/version"
|
2
|
+
|
3
|
+
module Uaeds
|
4
|
+
class DSML
|
5
|
+
def initialize(xml=nil)
|
6
|
+
raise ArgumentError, 'Argument is not numeric' unless xml
|
7
|
+
@xml = xml
|
8
|
+
@value_h = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_value(prop_name)
|
12
|
+
data = get_xml_attr(prop_name)
|
13
|
+
if data.length == 0
|
14
|
+
return nil
|
15
|
+
elsif data.length == 1
|
16
|
+
return data[0].content
|
17
|
+
else
|
18
|
+
values = []
|
19
|
+
data.each { |value| values.push(value.content) }
|
20
|
+
return values
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_values(prop_name)
|
25
|
+
data = get_xml_attr(prop_name)
|
26
|
+
if data.length == 0
|
27
|
+
return []
|
28
|
+
else
|
29
|
+
values = []
|
30
|
+
data.each { |value| content.push(value.content) }
|
31
|
+
return values
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def lookup_value(kv)
|
36
|
+
if(@value_h.key? kv)
|
37
|
+
return @value_h[kv]
|
38
|
+
else
|
39
|
+
val = get_value(kv)
|
40
|
+
if val.nil? || (val.length == 0)
|
41
|
+
@value_h[kv] = nil
|
42
|
+
else
|
43
|
+
@value_h[kv] = val
|
44
|
+
end
|
45
|
+
@value_h[kv]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def get_xml_attr(prop_name)
|
52
|
+
@xml.xpath("//dsml:attr[@name='#{prop_name}']/dsml:value")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'uaeds/dsml'
|
3
|
+
|
4
|
+
# Todo: use aliases...
|
5
|
+
|
6
|
+
module Uaeds
|
7
|
+
class DSMLPerson < DSML
|
8
|
+
def date_of_birth
|
9
|
+
if(@value_h.key? :dateOfBirth)
|
10
|
+
@value_h[:dateOfBirth]
|
11
|
+
else
|
12
|
+
dob = get_value(:dateOfBirth)
|
13
|
+
if dob.nil? || (dob.length == 0)
|
14
|
+
@value_h[:dateOfBirth] = nil
|
15
|
+
else
|
16
|
+
dob = Date.new(dob[0,4], dob[4,2], dob[6,2])
|
17
|
+
@value_h[:dateOfBirth] = dob
|
18
|
+
end
|
19
|
+
@value_h[:dateOfBirth]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def dob
|
24
|
+
date_of_birth
|
25
|
+
end
|
26
|
+
|
27
|
+
def netid
|
28
|
+
uid
|
29
|
+
end
|
30
|
+
|
31
|
+
def uid
|
32
|
+
lookup_value(:uid)
|
33
|
+
end
|
34
|
+
|
35
|
+
def uaid
|
36
|
+
lookup_value(:uaId)
|
37
|
+
end
|
38
|
+
|
39
|
+
def cat_card
|
40
|
+
iso_number
|
41
|
+
end
|
42
|
+
|
43
|
+
def iso_number
|
44
|
+
lookup_value(:isoNumber)
|
45
|
+
end
|
46
|
+
|
47
|
+
def employee_id
|
48
|
+
emplid
|
49
|
+
end
|
50
|
+
|
51
|
+
def emplid
|
52
|
+
lookup_value(:emplId)
|
53
|
+
end
|
54
|
+
|
55
|
+
def name
|
56
|
+
cn
|
57
|
+
end
|
58
|
+
|
59
|
+
def full_name
|
60
|
+
cn
|
61
|
+
end
|
62
|
+
|
63
|
+
def cn
|
64
|
+
lookup_value(:cn)
|
65
|
+
end
|
66
|
+
|
67
|
+
def person_type
|
68
|
+
edu_person_primary_affiliation
|
69
|
+
end
|
70
|
+
|
71
|
+
def edu_person_primary_affiliation
|
72
|
+
lookup_value(:eduPersonPrimaryAffiliation)
|
73
|
+
end
|
74
|
+
|
75
|
+
def title
|
76
|
+
employee_title
|
77
|
+
end
|
78
|
+
|
79
|
+
def employee_title
|
80
|
+
lookup_value(:employeeTitle)
|
81
|
+
end
|
82
|
+
|
83
|
+
def department
|
84
|
+
employee_primary_dept
|
85
|
+
end
|
86
|
+
|
87
|
+
def employee_primary_dept
|
88
|
+
lookup_value(:employeePrimaryDept)
|
89
|
+
end
|
90
|
+
|
91
|
+
def department_name
|
92
|
+
employee_primary_dept_name
|
93
|
+
end
|
94
|
+
|
95
|
+
def employee_primary_dept_name
|
96
|
+
lookup_value(:employeePrimaryDeptName)
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/lib/uaeds/eds.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Uaeds
|
4
|
+
class Eds
|
5
|
+
def initialize(url, user=nil, password=nil)
|
6
|
+
raise ArgumentError, "EDS URL required." unless (url && url.strip != "")
|
7
|
+
if(user && password)
|
8
|
+
@user = user
|
9
|
+
@password = password
|
10
|
+
end
|
11
|
+
@url = url
|
12
|
+
end
|
13
|
+
|
14
|
+
def person_by_uaid(uaid)
|
15
|
+
return open_person(uaid)
|
16
|
+
end
|
17
|
+
|
18
|
+
def person_by_netid(netid)
|
19
|
+
return open_person(netid)
|
20
|
+
end
|
21
|
+
|
22
|
+
def person_by_emplid(emplid)
|
23
|
+
return open_person(emplid)
|
24
|
+
end
|
25
|
+
|
26
|
+
def person(identifier)
|
27
|
+
return open_person(identifier)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def open_persion(idenfifier)
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'uaeds/version'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'uaeds/eds'
|
5
|
+
require 'uaeds/dsml_person'
|
6
|
+
|
7
|
+
module Uaeds
|
8
|
+
class EdsDSML < Eds
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def open_person(identifier)
|
13
|
+
# This might be improved with some more handling here and in DSML init.
|
14
|
+
if(@user && @password)
|
15
|
+
DSMLPerson.new(Nokogiri::XML(open(@url + "/people/#{identifier}", :http_basic_authentication=>[@user, @password])))
|
16
|
+
else
|
17
|
+
DSMLPerson.new(Nokogiri::XML(open(@url + "/people/#{identifier}")))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'uaeds/version'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'json'
|
4
|
+
require 'uaeds/eds'
|
5
|
+
require 'uaeds/json_person'
|
6
|
+
|
7
|
+
|
8
|
+
module Uaeds
|
9
|
+
class EdsJSON < Eds
|
10
|
+
|
11
|
+
def person_by_uaid(uaid)
|
12
|
+
return open_person('uaId', uaid)
|
13
|
+
end
|
14
|
+
|
15
|
+
def person_by_netid(netid)
|
16
|
+
return open_person('uid', netid)
|
17
|
+
end
|
18
|
+
|
19
|
+
def person_by_emplid(emplid)
|
20
|
+
return open_person('emplid', emplid)
|
21
|
+
end
|
22
|
+
|
23
|
+
def person(identifier)
|
24
|
+
return open_person(nil, identifier)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def open_person(attribute=nil, value)
|
30
|
+
raise ArgumentError, "value required." unless (value && value.strip != "")
|
31
|
+
if(attribute)
|
32
|
+
if(@user && @password)
|
33
|
+
JSONPerson.new(handle_stream(open(@url + "/#{value}/#{attribute}.json", :http_basic_authentication=>[@user, @password])))
|
34
|
+
else
|
35
|
+
JSONPerson.new(handle_stream(open(@url + "/#{value}/#{attribute}.json")))
|
36
|
+
end
|
37
|
+
else
|
38
|
+
if(@user && @password)
|
39
|
+
JSONPerson.new(handle_stream(open(@url + "/#{value}.json", :http_basic_authentication=>[@user, @password])))
|
40
|
+
else
|
41
|
+
JSONPerson.new(handle_stream(open(@url + "/#{value}.json")))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def handle_stream(stream)
|
47
|
+
string = stream.read()
|
48
|
+
stream.close()
|
49
|
+
JSON.parse(string)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'uaeds/dsml'
|
3
|
+
|
4
|
+
module Uaeds
|
5
|
+
class JSONPerson < DSML
|
6
|
+
def initialize(hash=nil)
|
7
|
+
raise ArgumentError, 'Argument is not a hash' unless (hash && hash.is_a?(Hash))
|
8
|
+
@value_h = hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def date_of_birth
|
12
|
+
lookup_value(:dateOfBirth)
|
13
|
+
end
|
14
|
+
|
15
|
+
def dob
|
16
|
+
date_of_birth
|
17
|
+
end
|
18
|
+
|
19
|
+
def netid
|
20
|
+
uid
|
21
|
+
end
|
22
|
+
|
23
|
+
def uid
|
24
|
+
lookup_value(:uid)
|
25
|
+
end
|
26
|
+
|
27
|
+
def uaid
|
28
|
+
lookup_value(:uaId)
|
29
|
+
end
|
30
|
+
|
31
|
+
def cat_card
|
32
|
+
iso_number
|
33
|
+
end
|
34
|
+
|
35
|
+
def iso_number
|
36
|
+
lookup_value(:isoNumber)
|
37
|
+
end
|
38
|
+
|
39
|
+
def employee_id
|
40
|
+
emplid
|
41
|
+
end
|
42
|
+
|
43
|
+
def emplid
|
44
|
+
lookup_value(:emplId)
|
45
|
+
end
|
46
|
+
|
47
|
+
def name
|
48
|
+
cn
|
49
|
+
end
|
50
|
+
|
51
|
+
def full_name
|
52
|
+
cn
|
53
|
+
end
|
54
|
+
|
55
|
+
def cn
|
56
|
+
lookup_value(:cn)
|
57
|
+
end
|
58
|
+
|
59
|
+
def person_type
|
60
|
+
edu_person_primary_affiliation
|
61
|
+
end
|
62
|
+
|
63
|
+
def edu_person_primary_affiliation
|
64
|
+
lookup_value(:eduPersonPrimaryAffiliation)
|
65
|
+
end
|
66
|
+
|
67
|
+
def title
|
68
|
+
employee_title
|
69
|
+
end
|
70
|
+
|
71
|
+
def employee_title
|
72
|
+
lookup_value(:employeeTitle)
|
73
|
+
end
|
74
|
+
|
75
|
+
def department
|
76
|
+
employee_primary_dept
|
77
|
+
end
|
78
|
+
|
79
|
+
def employee_primary_dept
|
80
|
+
lookup_value(:employeePrimaryDept)
|
81
|
+
end
|
82
|
+
|
83
|
+
def department_name
|
84
|
+
employee_primary_dept_name
|
85
|
+
end
|
86
|
+
|
87
|
+
def employee_primary_dept_name
|
88
|
+
lookup_value(:employeePrimaryDeptName)
|
89
|
+
end
|
90
|
+
|
91
|
+
def lookup_value(val)
|
92
|
+
k = val.to_s.downcase
|
93
|
+
if(@value_h.key? k)
|
94
|
+
@value_h[k]
|
95
|
+
else
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/spec/spec_helper.rb
ADDED
File without changes
|
data/spec/uaeds_spec.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'uaeds/eds_dsml'
|
2
|
+
require 'uaeds/eds_json'
|
3
|
+
require 'highline/import'
|
4
|
+
|
5
|
+
def color(a,b)
|
6
|
+
HighLine.color(a,b)
|
7
|
+
end
|
8
|
+
|
9
|
+
module Uaeds
|
10
|
+
|
11
|
+
describe EdsDSML, EdsJSON do
|
12
|
+
eds_user = nil
|
13
|
+
eds_key = nil
|
14
|
+
eds_dsml_ep = nil
|
15
|
+
eds_json_ep = nil
|
16
|
+
eds_0 = nil
|
17
|
+
eds_1 = nil
|
18
|
+
person_0 = nil
|
19
|
+
person_1 = nil
|
20
|
+
eds_test_user_netid = nil
|
21
|
+
|
22
|
+
describe 'Get access credentials for testing' do
|
23
|
+
info_color = [:yellow, :bold]
|
24
|
+
question_color = [:green]
|
25
|
+
error_color = [:red, :bold]
|
26
|
+
|
27
|
+
say(color("To test this library access to an EDS system is required.", info_color))
|
28
|
+
say(color("Please provide access credentials and endpoints for", info_color))
|
29
|
+
say(color("testing as prompted.\n", info_color))
|
30
|
+
|
31
|
+
eds_user = ask(color("EDS user name?", question_color)) do |input|
|
32
|
+
input.validate = /.+/
|
33
|
+
input.responses[:not_valid] = color("Please provide an EDS user name.", error_color)
|
34
|
+
input.responses[:ask_on_error] = ""
|
35
|
+
end
|
36
|
+
|
37
|
+
eds_key = ask(color("EDS key?", question_color)) do |input|
|
38
|
+
input.echo = "*"
|
39
|
+
input.validate = /.+/
|
40
|
+
input.responses[:not_valid] = color("Please provide an EDS key.", error_color)
|
41
|
+
input.responses[:ask_on_error] = ""
|
42
|
+
end
|
43
|
+
|
44
|
+
eds_dsml_ep = ask(color("DSML endpoint?", question_color)) do |input|
|
45
|
+
input.validate = /.+/
|
46
|
+
input.responses[:not_valid] = color("Please provide a DSML service endpoint.", error_color)
|
47
|
+
input.responses[:ask_on_error] = ""
|
48
|
+
end
|
49
|
+
|
50
|
+
eds_json_ep = ask(color("JSON endpoint?", question_color)) do |input|
|
51
|
+
input.validate = /.+/
|
52
|
+
input.responses[:not_valid] = color("Please provide a JSON service endpoint.", error_color)
|
53
|
+
input.responses[:ask_on_error] = ""
|
54
|
+
end
|
55
|
+
|
56
|
+
eds_test_user_netid = ask(color("Please provide a NetID for testing.", question_color)) do |input|
|
57
|
+
input.validate = /^\s*[a-zA-Z0-9]{3,16}\s*$/
|
58
|
+
input.responses[:not_valid] = color("Please provide a NetID for testing.", error_color)
|
59
|
+
input.responses[:ask_on_error] = ""
|
60
|
+
end
|
61
|
+
|
62
|
+
eds_user.strip!
|
63
|
+
eds_key.strip!
|
64
|
+
eds_dsml_ep.strip!
|
65
|
+
eds_json_ep.strip!
|
66
|
+
eds_test_user_netid.strip!
|
67
|
+
|
68
|
+
puts(color("\nStarting tests...\n++++++++++++++\n", [:blue, :bold]))
|
69
|
+
|
70
|
+
it 'Should have test credentials' do
|
71
|
+
expect(eds_user).not_to be_empty
|
72
|
+
expect(eds_key).not_to be_empty
|
73
|
+
expect(eds_dsml_ep).not_to be_empty
|
74
|
+
expect(eds_json_ep).not_to be_empty
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
describe 'EdsDSML and EdsJSON retrieve the same results' do
|
81
|
+
|
82
|
+
eds0 = EdsDSML.new("https://#{eds_dsml_ep}", eds_user, eds_key)
|
83
|
+
eds1 = EdsJSON.new("https://#{eds_json_ep}", eds_user, eds_key)
|
84
|
+
|
85
|
+
describe 'EdsDSML and EdsJSON should match when retrieved by NetId' do
|
86
|
+
|
87
|
+
person_0 = eds0.person_by_netid(eds_test_user_netid)
|
88
|
+
person_1 = eds1.person_by_netid(eds_test_user_netid)
|
89
|
+
|
90
|
+
it 'retrieved a DSML person' do
|
91
|
+
expect(person_0).to_not be_nil
|
92
|
+
expect(person_0).to be_an_instance_of(DSMLPerson)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'retrieved a JSON person' do
|
96
|
+
expect(person_1).to_not be_nil
|
97
|
+
expect(person_1).to be_an_instance_of(JSONPerson)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'has the sanem netid' do
|
101
|
+
expect(person_1.netid).to eq(person_0.netid)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'has the same name' do
|
105
|
+
expect(person_0.name).to eq(person_1.name)
|
106
|
+
end
|
107
|
+
it 'has the same uaid' do
|
108
|
+
expect(person_0.uaid).to eq(person_1.uaid)
|
109
|
+
end
|
110
|
+
it 'has the same emplid' do
|
111
|
+
# probably nil
|
112
|
+
expect(person_1.emplid).to eq(person_0.emplid)
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
describe 'EdsDSML and EdsJSON should match when retrieved by uaid' do
|
119
|
+
|
120
|
+
person_1 = eds1.person_by_uaid(person_0.uaid)
|
121
|
+
|
122
|
+
# Currently uiad's starting with a letter
|
123
|
+
# can not be retrieved by the DSML API.
|
124
|
+
# person_0 = eds0.person_by_uaid(person_1.uaid)
|
125
|
+
|
126
|
+
it 'has the same netid' do
|
127
|
+
expect(person_1.netid).to eq(person_0.netid)
|
128
|
+
end
|
129
|
+
it 'has the same name' do
|
130
|
+
expect(person_0.name).to eq(person_1.name)
|
131
|
+
end
|
132
|
+
it 'has the same uaid' do
|
133
|
+
expect(person_0.uaid).to eq(person_1.uaid)
|
134
|
+
end
|
135
|
+
it 'has the same emplid' do
|
136
|
+
expect(person_1.emplid).to eq(person_0.emplid)
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
describe 'EdsDSML and EdsJSON both retrieve the proper user' do
|
142
|
+
it 'has the correct NetIDs' do
|
143
|
+
expect(person_1.netid).to eq(eds_test_user_netid)
|
144
|
+
expect(person_0.netid).to eq(eds_test_user_netid)
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
describe 'EdsDSML and EdsJSON return nil for undefined attributes' do
|
150
|
+
it 'returns nil' do
|
151
|
+
expect(person_0.lookup_value('robotDinosaur')).to be_nil
|
152
|
+
expect(person_1.lookup_value('robotDinosaur')).to be_nil
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe 'EdsDSML returns nils for all values when blank entry is found' do
|
157
|
+
person_2 = eds0.person_by_uaid('T0T0T0T0T0T0T0T0T0T0T0T0')
|
158
|
+
it 'has nils' do
|
159
|
+
expect(person_2.netid).to be_nil
|
160
|
+
expect(person_2.uaid).to be_nil
|
161
|
+
expect(person_2.uid).to be_nil
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
data/uaeds.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uaeds/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "uaeds"
|
8
|
+
spec.version = Uaeds::VERSION
|
9
|
+
spec.authors = ["dgsan"]
|
10
|
+
spec.email = ["dgsan@gmx.com"]
|
11
|
+
spec.description = "Tool for working with UA's 'Enterprise Directory Service,' an XML-based (DSML) (or JSON-based) lookup service."
|
12
|
+
spec.summary = 'Tool for working with UA EDS'
|
13
|
+
spec.homepage = "https://github.com/dgsan/uaeds"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', "~> 1.3"
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec', "~> 2.6"
|
24
|
+
spec.add_development_dependency 'highline'
|
25
|
+
spec.add_runtime_dependency 'nokogiri'
|
26
|
+
spec.add_runtime_dependency 'json'
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uaeds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dgsan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
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: '2.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: json
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Tool for working with UA's 'Enterprise Directory Service,' an XML-based
|
98
|
+
(DSML) (or JSON-based) lookup service.
|
99
|
+
email:
|
100
|
+
- dgsan@gmx.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .rspec
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/uaeds.rb
|
112
|
+
- lib/uaeds/dsml.rb
|
113
|
+
- lib/uaeds/dsml_person.rb
|
114
|
+
- lib/uaeds/eds.rb
|
115
|
+
- lib/uaeds/eds_dsml.rb
|
116
|
+
- lib/uaeds/eds_json.rb
|
117
|
+
- lib/uaeds/json_person.rb
|
118
|
+
- lib/uaeds/version.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/uaeds_spec.rb
|
121
|
+
- uaeds.gemspec
|
122
|
+
homepage: https://github.com/dgsan/uaeds
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.0.7
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Tool for working with UA EDS
|
146
|
+
test_files:
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
- spec/uaeds_spec.rb
|