gds-sso 12.1.0 → 13.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.
@@ -123,11 +123,29 @@ describe "Integration of client using GDS-SSO with signonotron" do
123
123
 
124
124
  expect(page).to have_content('restricted kablooie')
125
125
 
126
+ visit "http://localhost:4567/users/sign_out"
127
+
128
+ Timecop.travel(Time.now.utc + GDS::SSO::Config.auth_valid_for + 5.minutes) do
129
+ visit "http://#{@client_host}/restricted"
130
+ end
131
+
132
+ expect(page).to have_content("Sign in")
133
+ end
134
+
135
+ it "should accept signonotron's remembered authentication N hours after login" do
136
+ visit "http://#{@client_host}/restricted"
137
+ expect(page).to have_content("Sign in")
138
+ fill_in "Email", :with => "test@example-client.com"
139
+ fill_in "Passphrase", :with => "q1w2e3r4t5y6u7i8o9p0"
140
+ click_on "Sign in"
141
+
142
+ expect(page).to have_content('restricted kablooie')
143
+
126
144
  Timecop.travel(Time.now.utc + GDS::SSO::Config.auth_valid_for + 5.minutes) do
127
145
  visit "http://#{@client_host}/restricted"
128
146
  end
129
147
 
130
- expect(page.driver.request.referrer).to match(%r(\Ahttp://#{@client_host}/auth/gds/callback))
148
+ expect(page).to have_content("restricted kablooie")
131
149
  end
132
150
 
133
151
 
@@ -144,7 +162,7 @@ describe "Integration of client using GDS-SSO with signonotron" do
144
162
  visit "http://#{@client_host}/restricted"
145
163
  end
146
164
 
147
- expect(page.driver.request.referrer).to match(%r(\Ahttp://#{@client_host}/restricted))
165
+ expect(page).to have_content("restricted kablooie")
148
166
  end
149
167
  end
150
168
  end
data/spec/spec_helper.rb CHANGED
@@ -15,8 +15,9 @@ require 'capybara/mechanize'
15
15
 
16
16
  include Warden::Test::Helpers
17
17
 
18
+ Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}
19
+
18
20
  RSpec.configure do |config|
19
- config.treat_symbols_as_metadata_keys_with_true_values = true
20
21
  config.run_all_when_everything_filtered = true
21
22
  config.filter_run :focus
22
23
 
@@ -25,6 +26,6 @@ RSpec.configure do |config|
25
26
  # the seed, which is printed after each run.
26
27
  # --seed 1234
27
28
  config.order = 'random'
28
- end
29
29
 
30
- Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}
30
+ config.include(BackportControllerTestParams) if Rails.version < '5'
31
+ end
@@ -0,0 +1,21 @@
1
+ module BackportControllerTestParams
2
+ def delete(*args)
3
+ action, rest = *args
4
+ super(action, rest[:params])
5
+ end
6
+
7
+ def get(*args)
8
+ action, rest = *args
9
+ super(action, rest[:params])
10
+ end
11
+
12
+ def post(*args)
13
+ action, rest = *args
14
+ super(action, rest[:params])
15
+ end
16
+
17
+ def put(*args)
18
+ action, rest = *args
19
+ super(action, rest[:params])
20
+ end
21
+ end
@@ -6,10 +6,12 @@ describe GDS::SSO::ApiAccess do
6
6
  ie7_accept_header = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, ' +
7
7
  'application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, ' +
8
8
  'application/x-ms-application, */*'
9
- expect(GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => ie7_accept_header)).to be_false
9
+ expect(GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => ie7_accept_header)).to be_falsey
10
10
  end
11
11
 
12
- it "should consider a json accept header to be an api call" do
13
- expect(GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => 'application/json')).to be_true
12
+ context "with a bearer token" do
13
+ it "it is considered an api call" do
14
+ expect(GDS::SSO::ApiAccess.api_call?('HTTP_AUTHORIZATION' => 'Bearer deadbeef12345678')).to be_truthy
15
+ end
14
16
  end
15
17
  end
@@ -4,16 +4,6 @@ require 'gds-sso/bearer_token'
4
4
  describe GDS::SSO::BearerToken do
5
5
  describe '.locate' do
6
6
  it 'creates a new user for a token' do
7
- response = {
8
- user: {
9
- uid: 'asd',
10
- email: 'user@example.com',
11
- name: 'A Name',
12
- permissions: ['signin'],
13
- organisation_slug: 'hmrc',
14
- organisation_content_id: '67a2b78d-eee3-45b3-80e2-792e7f71cecc',
15
- }
16
- }
17
7
  response = double(body: {
18
8
  user: {
19
9
  uid: 'asd',
@@ -26,7 +26,7 @@ describe Warden::SessionSerializer do
26
26
  end
27
27
 
28
28
  it "should return nil if the user has no uid" do
29
- @user.stub(:uid).and_return(nil)
29
+ allow(@user).to receive(:uid).and_return(nil)
30
30
  result = @serializer.serialize(@user)
31
31
 
32
32
  expect(result).to be_nil
@@ -56,6 +56,10 @@ describe GDS::SSO::User do
56
56
  def remotely_signed_out?
57
57
  remotely_signed_out
58
58
  end
59
+
60
+ def disabled?
61
+ disabled
62
+ end
59
63
  end
60
64
 
61
65
  let(:described_class) { TestUser }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-sso
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.0
4
+ version: 13.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Patterson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-22 00:00:00.000000000 Z
12
+ date: 2016-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: 4.2.4
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.0
27
+ version: 4.2.4
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: warden
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -95,20 +95,6 @@ dependencies:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: 0.0.1
98
- - !ruby/object:Gem::Dependency
99
- name: rack-accept
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: 0.4.4
105
- type: :runtime
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: 0.4.4
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: multi_json
114
100
  requirement: !ruby/object:Gem::Requirement
@@ -143,56 +129,56 @@ dependencies:
143
129
  requirements:
144
130
  - - '='
145
131
  - !ruby/object:Gem::Version
146
- version: 1.1.2
132
+ version: 2.8.0
147
133
  type: :development
148
134
  prerelease: false
149
135
  version_requirements: !ruby/object:Gem::Requirement
150
136
  requirements:
151
137
  - - '='
152
138
  - !ruby/object:Gem::Version
153
- version: 1.1.2
139
+ version: 2.8.0
154
140
  - !ruby/object:Gem::Dependency
155
141
  name: rspec-rails
156
142
  requirement: !ruby/object:Gem::Requirement
157
143
  requirements:
158
144
  - - '='
159
145
  - !ruby/object:Gem::Version
160
- version: 2.14.1
146
+ version: 3.5.2
161
147
  type: :development
162
148
  prerelease: false
163
149
  version_requirements: !ruby/object:Gem::Requirement
164
150
  requirements:
165
151
  - - '='
166
152
  - !ruby/object:Gem::Version
167
- version: 2.14.1
153
+ version: 3.5.2
168
154
  - !ruby/object:Gem::Dependency
169
155
  name: capybara-mechanize
170
156
  requirement: !ruby/object:Gem::Requirement
171
157
  requirements:
172
158
  - - '='
173
159
  - !ruby/object:Gem::Version
174
- version: 0.3.0
160
+ version: 1.5.0
175
161
  type: :development
176
162
  prerelease: false
177
163
  version_requirements: !ruby/object:Gem::Requirement
178
164
  requirements:
179
165
  - - '='
180
166
  - !ruby/object:Gem::Version
181
- version: 0.3.0
167
+ version: 1.5.0
182
168
  - !ruby/object:Gem::Dependency
183
169
  name: combustion
184
170
  requirement: !ruby/object:Gem::Requirement
185
171
  requirements:
186
172
  - - '='
187
173
  - !ruby/object:Gem::Version
188
- version: 0.5.2
174
+ version: 0.5.4
189
175
  type: :development
190
176
  prerelease: false
191
177
  version_requirements: !ruby/object:Gem::Requirement
192
178
  requirements:
193
179
  - - '='
194
180
  - !ruby/object:Gem::Version
195
- version: 0.5.2
181
+ version: 0.5.4
196
182
  - !ruby/object:Gem::Dependency
197
183
  name: gem_publisher
198
184
  requirement: !ruby/object:Gem::Requirement
@@ -279,9 +265,9 @@ files:
279
265
  - spec/internal/public/favicon.ico
280
266
  - spec/requests/end_to_end_spec.rb
281
267
  - spec/spec_helper.rb
268
+ - spec/support/backport_controller_test_params.rb
282
269
  - spec/support/signonotron2_integration_helpers.rb
283
270
  - spec/support/timecop.rb
284
- - spec/tasks/signonotron_tasks.rake
285
271
  - spec/unit/api_access_spec.rb
286
272
  - spec/unit/bearer_token_spec.rb
287
273
  - spec/unit/session_serialisation_spec.rb
@@ -298,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
298
284
  requirements:
299
285
  - - ">="
300
286
  - !ruby/object:Gem::Version
301
- version: '0'
287
+ version: 2.2.2
302
288
  required_rubygems_version: !ruby/object:Gem::Requirement
303
289
  requirements:
304
290
  - - ">="
@@ -311,25 +297,25 @@ signing_key:
311
297
  specification_version: 4
312
298
  summary: Client for GDS' OAuth 2-based SSO
313
299
  test_files:
314
- - spec/controller/api_user_controller_spec.rb
315
- - spec/unit/user_spec.rb
316
- - spec/unit/api_access_spec.rb
317
- - spec/unit/session_serialisation_spec.rb
318
- - spec/unit/bearer_token_spec.rb
300
+ - spec/requests/end_to_end_spec.rb
319
301
  - spec/spec_helper.rb
320
- - spec/support/timecop.rb
302
+ - spec/support/backport_controller_test_params.rb
321
303
  - spec/support/signonotron2_integration_helpers.rb
322
- - spec/internal/app/controllers/example_controller.rb
323
- - spec/internal/app/controllers/application_controller.rb
304
+ - spec/support/timecop.rb
324
305
  - spec/internal/app/models/user.rb
325
- - spec/internal/log/test.log
326
- - spec/internal/public/favicon.ico
306
+ - spec/internal/app/controllers/application_controller.rb
307
+ - spec/internal/app/controllers/example_controller.rb
308
+ - spec/internal/config/routes.rb
327
309
  - spec/internal/config/initializers/gds-sso.rb
328
310
  - spec/internal/config/database.yml
329
- - spec/internal/config/routes.rb
330
311
  - spec/internal/db/schema.rb
331
312
  - spec/internal/db/combustion_test.sqlite
332
- - spec/requests/end_to_end_spec.rb
313
+ - spec/internal/public/favicon.ico
314
+ - spec/internal/log/test.log
315
+ - spec/controller/api_user_controller_spec.rb
316
+ - spec/unit/user_spec.rb
317
+ - spec/unit/bearer_token_spec.rb
318
+ - spec/unit/session_serialisation_spec.rb
319
+ - spec/unit/api_access_spec.rb
333
320
  - spec/fixtures/integration/signonotron2.sql
334
321
  - spec/fixtures/integration/authorize_api_users.sql
335
- - spec/tasks/signonotron_tasks.rake
@@ -1,65 +0,0 @@
1
- namespace :signonotron do
2
- desc "Start signonotron (for integration tests)"
3
- task :start => :stop do
4
-
5
- @app_to_launch = "signonotron2"
6
-
7
- puts "Launching: #{@app_to_launch}"
8
-
9
- gem_root = Pathname.new(File.dirname(__FILE__)) + '..' + '..'
10
- FileUtils.mkdir_p(gem_root + 'tmp')
11
- Dir.chdir gem_root + 'tmp' do
12
- if File.exist? @app_to_launch
13
- Dir.chdir @app_to_launch do
14
- puts `git clean -fdx`
15
- puts `git fetch origin`
16
- puts `git reset --hard origin/master`
17
- end
18
- else
19
- puts `git clone git@github.com:alphagov/#{@app_to_launch}`
20
- end
21
-
22
- if signon_commitish = ENV['SIGNON_COMMITISH']
23
- puts "Checking out non-master of signon: #{signon_commitish}"
24
- Dir.chdir(@app_to_launch) do
25
- system `git checkout #{signon_commitish}` || raise("Unable to checkout #{signon_commitish}")
26
- end
27
- end
28
- end
29
-
30
- Dir.chdir gem_root + 'tmp' + @app_to_launch do
31
- env_to_clear = %w(BUNDLE_GEMFILE BUNDLE_BIN_PATH RUBYOPT GEM_HOME GEM_PATH RBENV_VERSION)
32
-
33
- env_stuff = case `uname`.strip
34
- when "Darwin"
35
- env_to_clear.map { |e| "unset #{e}" }.join(" && ") + " && "
36
- else
37
- "/usr/bin/env " + env_to_clear.map { |e| "-u #{e}" }.join(" ")
38
- end
39
- env_stuff += " RAILS_ENV=test"
40
- if ENV.has_key?('ORIGINAL_PATH')
41
- env_stuff += " PATH=#{ENV.fetch('ORIGINAL_PATH')}"
42
- end
43
-
44
- puts "Running bundler"
45
- puts `#{env_stuff} bundle install --path=#{gem_root + 'tmp' + "#{@app_to_launch}_bundle"}`
46
- puts `#{env_stuff} bundle exec rake db:drop db:create db:schema:load`
47
-
48
- puts "Starting signonotron instance in the background"
49
- fork do
50
- Process.daemon(true)
51
- exec "#{env_stuff} bundle exec rails s -p 4567"
52
- end
53
- end
54
- end
55
-
56
- desc "Stop running signonotron (for integration tests)"
57
- task :stop do
58
- pid_output = `lsof -Fp -i :4567`.chomp
59
- if pid_output =~ /\Ap(\d+)\z/
60
- puts "Stopping running instance of Signonotron (pid #{$1})"
61
- Process.kill(:INT, $1.to_i)
62
- end
63
- end
64
- end
65
-