gds-sso 9.3.0 → 9.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,20 +1,15 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
1
  # Yes, we really do want to turn off the test environment check here.
5
2
  # Bad things happen if we don't ;-)
6
3
  ENV['GDS_SSO_STRATEGY'] = 'real'
7
4
 
8
- Bundler.require :default
9
-
10
- require 'capybara/rspec'
5
+ require 'bundler/setup'
11
6
  require 'combustion'
7
+ require 'capybara/rspec'
12
8
 
13
9
  Combustion.initialize! :all
14
10
 
15
11
  require 'rspec/rails'
16
12
  require 'capybara/rails'
17
-
18
13
  require 'mechanize'
19
14
  require 'capybara/mechanize'
20
15
 
@@ -2,15 +2,14 @@ require 'spec_helper'
2
2
  require 'active_record'
3
3
 
4
4
  describe Warden::SessionSerializer do
5
- class User < ActiveRecord::Base
5
+ class SerializableUser
6
6
  include GDS::SSO::User
7
-
8
7
  end
9
8
 
10
9
  before :each do
11
10
  @old_user_model = GDS::SSO::Config.user_model
12
- GDS::SSO::Config.user_model = User
13
- @user = double("User", uid: 1234)
11
+ GDS::SSO::Config.user_model = SerializableUser
12
+ @user = double("SerializableUser", uid: 1234)
14
13
  @serializer = Warden::SessionSerializer.new(nil)
15
14
  end
16
15
  after :each do
@@ -36,7 +35,7 @@ describe Warden::SessionSerializer do
36
35
 
37
36
  describe "deserialize a user" do
38
37
  it "should return the user if the timestamp is current and a Time" do
39
- expect(User).to receive(:where).with(:uid => 1234, :remotely_signed_out => false).and_return(double(:first => :a_user))
38
+ expect(SerializableUser).to receive(:where).with(:uid => 1234, :remotely_signed_out => false).and_return(double(:first => :a_user))
40
39
 
41
40
  result = @serializer.deserialize [1234, Time.now.utc - GDS::SSO::Config.auth_valid_for + 3600]
42
41
 
@@ -44,7 +43,7 @@ describe Warden::SessionSerializer do
44
43
  end
45
44
 
46
45
  it "should return the user if the timestamp is current and is an ISO 8601 string" do
47
- expect(User).to receive(:where).with(:uid => 1234, :remotely_signed_out => false).and_return(double(:first => :a_user))
46
+ expect(SerializableUser).to receive(:where).with(:uid => 1234, :remotely_signed_out => false).and_return(double(:first => :a_user))
48
47
 
49
48
  result = @serializer.deserialize [1234, (Time.now.utc - GDS::SSO::Config.auth_valid_for + 3600).iso8601]
50
49
 
@@ -52,7 +51,7 @@ describe Warden::SessionSerializer do
52
51
  end
53
52
 
54
53
  it "should return nil if the timestamp is out of date" do
55
- expect(User).not_to receive(:where)
54
+ expect(SerializableUser).not_to receive(:where)
56
55
 
57
56
  result = @serializer.deserialize [1234, Time.now.utc - GDS::SSO::Config.auth_valid_for - 3600]
58
57
 
@@ -60,7 +59,7 @@ describe Warden::SessionSerializer do
60
59
  end
61
60
 
62
61
  it "should return nil for a user without a timestamp" do
63
- expect(User).not_to receive(:where)
62
+ expect(SerializableUser).not_to receive(:where)
64
63
 
65
64
  result = @serializer.deserialize 1234
66
65
 
@@ -68,7 +67,7 @@ describe Warden::SessionSerializer do
68
67
  end
69
68
 
70
69
  it "should return nil for a user with a badly formatted timestamp" do
71
- expect(User).not_to receive(:where)
70
+ expect(SerializableUser).not_to receive(:where)
72
71
 
73
72
  result = @serializer.deserialize [1234, 'this is not a timestamp']
74
73
 
@@ -1,5 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'gds-sso/user'
3
+ require 'gds-sso/lint/user_spec'
4
+
5
+ require 'ostruct'
3
6
 
4
7
  describe GDS::SSO::User do
5
8
  before :each do
@@ -16,4 +19,35 @@ describe GDS::SSO::User do
16
19
  expected = {'uid' => 'abcde', 'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk', "permissions" => [], "organisation_slug" => nil}
17
20
  expect(GDS::SSO::User.user_params_from_auth_hash(@auth_hash)).to eq(expected)
18
21
  end
22
+
23
+ context "making sure that the lint spec is valid" do
24
+ class TestUser < OpenStruct
25
+ include GDS::SSO::User
26
+
27
+ def self.where(opts)
28
+ []
29
+ end
30
+
31
+ def self.create!(options, scope = {})
32
+ new(options)
33
+ end
34
+
35
+ def update_attribute(key, value)
36
+ send("#{key}=".to_sym, value)
37
+ end
38
+
39
+ def update_attributes(options)
40
+ options.each do |key, value|
41
+ update_attribute(key, value)
42
+ end
43
+ end
44
+
45
+ def remotely_signed_out?
46
+ remotely_signed_out
47
+ end
48
+ end
49
+
50
+ let(:described_class) { TestUser }
51
+ it_behaves_like "a gds-sso user class"
52
+ end
19
53
  end
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: 9.3.0
4
+ version: 9.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-07-18 00:00:00.000000000 Z
13
+ date: 2014-09-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -211,7 +211,7 @@ dependencies:
211
211
  requirements:
212
212
  - - '='
213
213
  - !ruby/object:Gem::Version
214
- version: 0.5.1
214
+ version: 0.5.2
215
215
  type: :development
216
216
  prerelease: false
217
217
  version_requirements: !ruby/object:Gem::Requirement
@@ -219,7 +219,7 @@ dependencies:
219
219
  requirements:
220
220
  - - '='
221
221
  - !ruby/object:Gem::Version
222
- version: 0.5.1
222
+ version: 0.5.2
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: gem_publisher
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -243,7 +243,7 @@ dependencies:
243
243
  requirements:
244
244
  - - '='
245
245
  - !ruby/object:Gem::Version
246
- version: 1.3.6
246
+ version: 1.3.9
247
247
  type: :development
248
248
  prerelease: false
249
249
  version_requirements: !ruby/object:Gem::Requirement
@@ -251,7 +251,7 @@ dependencies:
251
251
  requirements:
252
252
  - - '='
253
253
  - !ruby/object:Gem::Version
254
- version: 1.3.6
254
+ version: 1.3.9
255
255
  - !ruby/object:Gem::Dependency
256
256
  name: timecop
257
257
  requirement: !ruby/object:Gem::Requirement
@@ -268,6 +268,22 @@ dependencies:
268
268
  - - '='
269
269
  - !ruby/object:Gem::Version
270
270
  version: 0.3.5
271
+ - !ruby/object:Gem::Dependency
272
+ name: wwtd
273
+ requirement: !ruby/object:Gem::Requirement
274
+ none: false
275
+ requirements:
276
+ - - ! '>='
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
279
+ type: :development
280
+ prerelease: false
281
+ version_requirements: !ruby/object:Gem::Requirement
282
+ none: false
283
+ requirements:
284
+ - - ! '>='
285
+ - !ruby/object:Gem::Version
286
+ version: '0'
271
287
  description: Client for GDS' OAuth 2-based SSO
272
288
  email:
273
289
  - matt@constituentparts.com
@@ -289,6 +305,7 @@ files:
289
305
  - lib/gds-sso/config.rb
290
306
  - lib/gds-sso/failure_app.rb
291
307
  - lib/gds-sso/warden_config.rb
308
+ - lib/gds-sso/lint/user_spec.rb
292
309
  - lib/gds-sso/user.rb
293
310
  - lib/gds-sso/api_access.rb
294
311
  - lib/gds-sso.rb
@@ -332,7 +349,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
332
349
  version: '0'
333
350
  segments:
334
351
  - 0
335
- hash: -273519884690560048
352
+ hash: 21293373726415033
336
353
  required_rubygems_version: !ruby/object:Gem::Requirement
337
354
  none: false
338
355
  requirements:
@@ -341,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
358
  version: '0'
342
359
  segments:
343
360
  - 0
344
- hash: -273519884690560048
361
+ hash: 21293373726415033
345
362
  requirements: []
346
363
  rubyforge_project: gds-sso
347
364
  rubygems_version: 1.8.23