ncs_navigator_authority 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1,3 +1,3 @@
1
- rvm ree-1.8.7-2011.03
1
+ rvm ruby-1.9.3-p194
2
2
  rvm_gemset_create_on_use_flag=1
3
3
  rvm gemset use ncs_navigator_authority
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 = '1.0.0'
6
- package(:gemjar).with_gem(:file => _('ncs_navigator_authority-1.0.0.gem')).with_gem('jruby-openssl', '0.7.5')
5
+ project.version = '1.1.3'
6
+ package(:gemjar).with_gem(:file => _('ncs_navigator_authority-1.2.0.gem')).with_gem('jruby-openssl', '0.7.5')
7
7
  end
@@ -1,16 +1,21 @@
1
1
  require 'ncs_navigator/configuration'
2
2
  module NcsNavigator::Authorization::Core
3
3
  class Authority
4
- def initialize(config=nil)
5
- @logger = config.try(:logger) || Logger.new(STDERR)
4
+ attr_reader :logger
5
+ attr_reader :staff_portal_uri
6
+ attr_reader :staff_portal_user
7
+ attr_reader :staff_portal_password
8
+
9
+ def initialize(options = {})
10
+ @logger = options[:logger] || Logger.new($stderr)
11
+ @staff_portal_uri = options[:staff_portal_uri] || NcsNavigator.configuration.staff_portal_uri
12
+ @staff_portal_user = options[:staff_portal_user] || "psc_application"
13
+ @staff_portal_password = options[:staff_portal_password] || NcsNavigator.configuration.staff_portal['psc_user_password']
14
+
6
15
  @groups = {}
7
16
  @portal = :NCSNavigator
8
17
  end
9
18
 
10
- def logger
11
- @logger
12
- end
13
-
14
19
  def amplify!(user)
15
20
  base = user(user)
16
21
  return user unless base
@@ -61,10 +66,6 @@ module NcsNavigator::Authorization::Core
61
66
 
62
67
  private
63
68
 
64
- def staff_portal_uri
65
- NcsNavigator.configuration.staff_portal_uri
66
- end
67
-
68
69
  def get_connection(user)
69
70
  connection = staff_portal_client(create_authenticator(user)).connection
70
71
  end
@@ -78,7 +79,7 @@ module NcsNavigator::Authorization::Core
78
79
  end
79
80
 
80
81
  def machine_authenticator
81
- { :basic => ["psc_application", NcsNavigator.configuration.staff_portal['psc_user_password']] }
82
+ { :basic => [staff_portal_user, staff_portal_password] }
82
83
  end
83
84
 
84
85
  def load_group_memberships(portal, group_data)
@@ -3,7 +3,14 @@ require 'logger'
3
3
  module NcsNavigator::Authorization::Psc
4
4
  class Authority
5
5
  def initialize(ignored_config=nil)
6
- @logger = Logger.new("#{Java::JavaLang::System.getProperty('catalina.base')}/logs/ncs_navigator_authority.log")
6
+ @logdir = Java::JavaLang::System.getProperty('catalina.base')
7
+
8
+ @logger = if !@logdir
9
+ Logger.new($stderr).tap { |l| l.warn("catalina.base property not set; logging to standard error") }
10
+ else
11
+ Logger.new("#{@logdir}/logs/ncs_navigator_authority.log")
12
+ end
13
+
7
14
  @staff_portal_connection ||= staff_portal_client.connection
8
15
  end
9
16
 
@@ -1,12 +1,13 @@
1
1
  require 'faraday'
2
- require 'faraday_stack'
2
+ require 'faraday_middleware'
3
+
3
4
  module NcsNavigator::Authorization::StaffPortal
4
5
  class Connection < ::Faraday::Connection
5
6
  def initialize(url, options)
6
7
  super do |builder|
7
8
  builder.use *authentication_middleware(options[:authenticator])
8
9
  builder.request :json
9
- builder.use FaradayStack::ResponseJSON, :content_type => 'application/json'
10
+ builder.use FaradayMiddleware::ParseJson, :content_type => 'application/json'
10
11
  builder.adapter :net_http
11
12
  end
12
13
  end
@@ -30,4 +31,4 @@ module NcsNavigator::Authorization::StaffPortal
30
31
  end
31
32
  end
32
33
  end
33
- end
34
+ end
@@ -4,7 +4,7 @@ module NcsNavigator::Authorization::StaffPortal
4
4
  class HttpBasic
5
5
  def initialize(app, username, password)
6
6
  @app = app
7
- @header_value = "Basic #{Base64.encode64([username, password].join(':')).strip}"
7
+ @header_value = "Basic #{Base64.strict_encode64([username, password].join(':')).strip}"
8
8
  end
9
9
 
10
10
  def call(env)
@@ -1,5 +1,5 @@
1
1
  module NcsNavigator
2
2
  module Authorization
3
- VERSION = '1.1.1'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
@@ -21,12 +21,13 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'ncs_navigator_configuration', '~> 0.2'
22
22
  s.add_dependency 'aker', '~> 3.0'
23
23
  s.add_dependency 'faraday', '~> 0.7.5'
24
- s.add_dependency 'faraday-stack', '~> 0.1.3'
24
+ s.add_dependency 'faraday_middleware'
25
25
 
26
26
  s.add_development_dependency 'rspec', '~> 2.6'
27
27
  s.add_development_dependency 'rake', '~> 0.9.2'
28
- s.add_development_dependency 'vcr'
28
+ s.add_development_dependency 'vcr', '~> 1.0'
29
29
  s.add_development_dependency 'fakeweb'
30
+ s.add_development_dependency 'ci_reporter'
30
31
 
31
32
  # specify any dependencies here; for example:
32
33
  # s.add_development_dependency "rspec"
@@ -1,15 +1,29 @@
1
1
  require 'spec_helper'
2
2
  require 'aker'
3
3
  require 'vcr'
4
- require 'faraday'
5
- require 'faraday_stack'
6
- describe NcsNavigator::Authorization::Core::Authority do
7
4
 
5
+ describe NcsNavigator::Authorization::Core::Authority do
8
6
  before do
9
7
  @ncs_navigator_authority = NcsNavigator::Authorization::Core::Authority.new
10
8
  @user = mock(:username => "lee", :cas_proxy_ticket => "PT-cas-ticket")
11
9
  end
12
10
 
11
+ describe '.initialize' do
12
+ it 'accepts a Staff Portal URI' do
13
+ a = NcsNavigator::Authorization::Core::Authority.new(:staff_portal_uri => URI('https://navops.example.edu'))
14
+
15
+ a.staff_portal_uri.should == URI('https://navops.example.edu')
16
+ end
17
+
18
+ it 'accepts Staff Portal credentials' do
19
+ a = NcsNavigator::Authorization::Core::Authority.new(:staff_portal_user => 'user',
20
+ :staff_portal_password => 'foobar')
21
+
22
+ a.staff_portal_user.should == 'user'
23
+ a.staff_portal_password.should == 'foobar'
24
+ end
25
+ end
26
+
13
27
  describe "user" do
14
28
  before do
15
29
  VCR.use_cassette('staff_portal/core/user') do
@@ -63,8 +77,7 @@ describe NcsNavigator::Authorization::Core::Authority do
63
77
 
64
78
  it "should use the configured logger if given" do
65
79
  logger = Logger.new("dummyfile.log")
66
- auth = NcsNavigator::Authorization::Core::Authority.new(
67
- mock(Aker::Configuration, :logger => logger))
80
+ auth = NcsNavigator::Authorization::Core::Authority.new(:logger => logger)
68
81
  auth.logger.should == logger
69
82
  end
70
83
 
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'aker'
3
3
  require 'vcr'
4
- require 'faraday'
5
- require 'faraday_stack'
6
4
 
7
5
  describe NcsNavigator::Authorization::Psc::Authority do
8
6
  before do
7
+ pending "These must be run in a Java Ruby environment" unless RUBY_PLATFORM =~ /java/
8
+
9
9
  @psc_authority = NcsNavigator::Authorization::Psc::Authority.new
10
10
  end
11
11
 
@@ -296,4 +296,4 @@ describe NcsNavigator::Authorization::Psc::Authority do
296
296
  end
297
297
 
298
298
  end
299
- end
299
+ end
@@ -7,11 +7,20 @@ describe NcsNavigator::Authorization::StaffPortal::HttpBasic do
7
7
 
8
8
  before { app.stub!(:call) }
9
9
  describe "token" do
10
- subject { NcsNavigator::Authorization::StaffPortal::HttpBasic.new(app, 'user', 'pwd') }
11
-
12
- it 'adds the appropriate Authorization header' do
13
- subject.call(env)
14
- headers['Authorization'].should == 'Basic dXNlcjpwd2Q='
10
+ describe "for shoter passwrod" do
11
+ subject { NcsNavigator::Authorization::StaffPortal::HttpBasic.new(app, 'user', 'pwd') }
12
+ it 'adds the appropriate Authorization header' do
13
+ subject.call(env)
14
+ headers['Authorization'].should == 'Basic dXNlcjpwd2Q='
15
+ end
16
+ end
17
+
18
+ describe "for longer passwrod" do
19
+ subject { NcsNavigator::Authorization::StaffPortal::HttpBasic.new(app, 'user', 'a' * 46) }
20
+ it 'adds the appropriate Authorization header' do
21
+ subject.call(env)
22
+ headers['Authorization'].should == 'Basic dXNlcjphYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh'
23
+ end
15
24
  end
16
25
  end
17
26
  end
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,8 @@ require 'ncs_navigator/authorization/staff_portal/client'
12
12
  require 'ncs_navigator/authorization/staff_portal/connection'
13
13
  require 'ncs_navigator/authorization/staff_portal/http_basic'
14
14
 
15
- require 'spec/support/vcr_setup.rb'
15
+ require File.expand_path('../support/vcr_setup', __FILE__)
16
+
16
17
  RSpec.configure do |config|
17
18
  # config.fixture_path = "/spec/fixtures"
18
- end
19
+ end
metadata CHANGED
@@ -1,154 +1,169 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ncs_navigator_authority
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jalpa Patel
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-11-26 00:00:00 -06:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: ncs_navigator_configuration
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 0
32
- - 2
33
- version: "0.2"
20
+ - !ruby/object:Gem::Version
21
+ version: '0.2'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: aker
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: aker
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
34
+ requirements:
42
35
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 7
45
- segments:
46
- - 3
47
- - 0
48
- version: "3.0"
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
49
38
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: faraday
53
39
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: faraday
48
+ requirement: !ruby/object:Gem::Requirement
55
49
  none: false
56
- requirements:
50
+ requirements:
57
51
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 9
60
- segments:
61
- - 0
62
- - 7
63
- - 5
52
+ - !ruby/object:Gem::Version
64
53
  version: 0.7.5
65
54
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: faraday-stack
69
55
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
71
57
  none: false
72
- requirements:
58
+ requirements:
73
59
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 29
76
- segments:
77
- - 0
78
- - 1
79
- - 3
80
- version: 0.1.3
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: faraday_middleware
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
81
70
  type: :runtime
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
71
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
87
73
  none: false
88
- requirements:
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
89
83
  - - ~>
90
- - !ruby/object:Gem::Version
91
- hash: 15
92
- segments:
93
- - 2
94
- - 6
95
- version: "2.6"
84
+ - !ruby/object:Gem::Version
85
+ version: '2.6'
96
86
  type: :development
97
- version_requirements: *id005
98
- - !ruby/object:Gem::Dependency
99
- name: rake
100
87
  prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.6'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
102
97
  none: false
103
- requirements:
98
+ requirements:
104
99
  - - ~>
105
- - !ruby/object:Gem::Version
106
- hash: 63
107
- segments:
108
- - 0
109
- - 9
110
- - 2
100
+ - !ruby/object:Gem::Version
111
101
  version: 0.9.2
112
102
  type: :development
113
- version_requirements: *id006
114
- - !ruby/object:Gem::Dependency
115
- name: vcr
116
103
  prerelease: false
117
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.2
110
+ - !ruby/object:Gem::Dependency
111
+ name: vcr
112
+ requirement: !ruby/object:Gem::Requirement
118
113
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
126
118
  type: :development
127
- version_requirements: *id007
128
- - !ruby/object:Gem::Dependency
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
126
+ - !ruby/object:Gem::Dependency
129
127
  name: fakeweb
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
130
135
  prerelease: false
131
- requirement: &id008 !ruby/object:Gem::Requirement
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: ci_reporter
144
+ requirement: !ruby/object:Gem::Requirement
132
145
  none: false
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- hash: 3
137
- segments:
138
- - 0
139
- version: "0"
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
140
150
  type: :development
141
- version_requirements: *id008
142
- description: This is a shared library which consume Staff Portal's authorization API and provides group membership information for the NcsNavigator portal and role authorization mapping for PSC.
143
- email:
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ description: This is a shared library which consume Staff Portal's authorization API
159
+ and provides group membership information for the NcsNavigator portal and role authorization
160
+ mapping for PSC.
161
+ email:
144
162
  - jalpa-patel@northwestern.edu
145
163
  executables: []
146
-
147
164
  extensions: []
148
-
149
165
  extra_rdoc_files: []
150
-
151
- files:
166
+ files:
152
167
  - .gitignore
153
168
  - .rvmrc
154
169
  - Gemfile
@@ -195,41 +210,31 @@ files:
195
210
  - spec/ncs_navigator/authorization/staff_portal/http_basic_spec.rb
196
211
  - spec/spec_helper.rb
197
212
  - spec/support/vcr_setup.rb
198
- has_rdoc: true
199
- homepage: ""
213
+ homepage: ''
200
214
  licenses: []
201
-
202
215
  post_install_message:
203
216
  rdoc_options: []
204
-
205
- require_paths:
217
+ require_paths:
206
218
  - lib
207
- required_ruby_version: !ruby/object:Gem::Requirement
219
+ required_ruby_version: !ruby/object:Gem::Requirement
208
220
  none: false
209
- requirements:
210
- - - ">="
211
- - !ruby/object:Gem::Version
212
- hash: 3
213
- segments:
214
- - 0
215
- version: "0"
216
- required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ! '>='
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
226
  none: false
218
- requirements:
219
- - - ">="
220
- - !ruby/object:Gem::Version
221
- hash: 3
222
- segments:
223
- - 0
224
- version: "0"
227
+ requirements:
228
+ - - ! '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
225
231
  requirements: []
226
-
227
232
  rubyforge_project: ncs_navigator_authority
228
- rubygems_version: 1.5.2
233
+ rubygems_version: 1.8.24
229
234
  signing_key:
230
235
  specification_version: 3
231
236
  summary: Authorization module for NCS Navigator
232
- test_files:
237
+ test_files:
233
238
  - spec/fixtures/.DS_Store
234
239
  - spec/fixtures/vcr_cassettes/staff_portal/core/unknown_user.yml
235
240
  - spec/fixtures/vcr_cassettes/staff_portal/core/user.yml