ncs_navigator_authority 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
data/buildfile
CHANGED
@@ -2,6 +2,6 @@ require 'buildr/bnd'
|
|
2
2
|
require 'buildr-gemjar'
|
3
3
|
|
4
4
|
define 'ncs_navigator_authority_gems' do
|
5
|
-
project.version = '0.0
|
6
|
-
package(:gemjar).with_gem(:file => _('ncs_navigator_authority-0.0.
|
5
|
+
project.version = '1.0.0'
|
6
|
+
package(:gemjar).with_gem(:file => _('ncs_navigator_authority-1.0.0.gem')).with_gem('jruby-ossl', '0.7.5')
|
7
7
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'ncs_navigator/configuration'
|
2
|
+
require 'logger'
|
2
3
|
module NcsNavigator::Authorization::Psc
|
3
4
|
class Authority
|
4
5
|
def initialize(ignored_config=nil)
|
5
6
|
@staff_portal_connection ||= staff_portal_client.connection
|
7
|
+
@logger = Logger.new("#{Java::JavaLang::System.getProperty('catalina.base')}/logs/ncs_navigator_authority.log")
|
6
8
|
end
|
7
9
|
|
8
10
|
def get_user_by_username(username, role_detail_level)
|
@@ -29,8 +31,9 @@ module NcsNavigator::Authorization::Psc
|
|
29
31
|
|
30
32
|
def users_hash(users)
|
31
33
|
users_hash = []
|
34
|
+
return users_hash unless users
|
32
35
|
users.each do |u|
|
33
|
-
users_hash << user_hash(u)
|
36
|
+
users_hash << user_hash(u) if u["username"]
|
34
37
|
end
|
35
38
|
users_hash
|
36
39
|
end
|
@@ -65,7 +68,8 @@ module NcsNavigator::Authorization::Psc
|
|
65
68
|
end
|
66
69
|
|
67
70
|
def staff_portal_client
|
68
|
-
NcsNavigator::Authorization::StaffPortal::Client.new(NcsNavigator.configuration.staff_portal_uri,
|
71
|
+
NcsNavigator::Authorization::StaffPortal::Client.new(NcsNavigator.configuration.staff_portal_uri,
|
72
|
+
:authenticator => create_authenticator)
|
69
73
|
end
|
70
74
|
|
71
75
|
def create_authenticator
|
@@ -73,12 +77,18 @@ module NcsNavigator::Authorization::Psc
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def get_staff(url)
|
76
|
-
|
77
|
-
|
78
|
-
response.
|
79
|
-
|
80
|
-
|
80
|
+
staff = nil
|
81
|
+
begin
|
82
|
+
response = @staff_portal_connection.get url
|
83
|
+
if response.status == 200
|
84
|
+
staff = response.body
|
85
|
+
else
|
86
|
+
@logger.warn("#{Time.now}: Staff Portal Response: #{response.body}")
|
87
|
+
end
|
88
|
+
rescue => e
|
89
|
+
@logger.error("#{Time.now} : Staff Portal: #{e.class} #{e.backtrace.join("\n")}")
|
81
90
|
end
|
91
|
+
staff
|
82
92
|
end
|
83
93
|
|
84
94
|
def get_user_by_username_or_id(staff)
|
@@ -190,4 +200,4 @@ module NcsNavigator::Authorization::Psc
|
|
190
200
|
end
|
191
201
|
end
|
192
202
|
|
193
|
-
end
|
203
|
+
end
|
@@ -131,6 +131,13 @@ describe NcsNavigator::Authorization::Psc::Authority do
|
|
131
131
|
end
|
132
132
|
@return_users.should be_empty
|
133
133
|
end
|
134
|
+
|
135
|
+
it "excludes the user with null username from list of users returning" do
|
136
|
+
VCR.use_cassette('staff_portal/psc/users_with_null_username') do
|
137
|
+
@return_users = @psc_authority.get_users_by_role(:subject_manager)
|
138
|
+
end
|
139
|
+
@return_users.count.should == 1
|
140
|
+
end
|
134
141
|
end
|
135
142
|
end
|
136
143
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncs_navigator_authority
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jalpa Patel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-09-06 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|