gds-sso 9.2.1 → 9.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
- require 'gds-sso/api_access'
3
-
4
- class ApiAccessTest < Test::Unit::TestCase
5
- def test_internet_explorer_7_accept_header_is_not_considered_to_be_api_call
6
- ie7_accept_header = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, ' +
7
- 'application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, ' +
8
- 'application/x-ms-application, */*'
9
- refute GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => ie7_accept_header)
10
- end
11
-
12
- def test_application_json_accept_header_is_considered_to_be_api_call
13
- assert GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => 'application/json')
14
- end
15
-
16
- def test_request_with_authorization_header_is_oauth_api_call
17
- assert GDS::SSO::ApiAccess.oauth_api_call?('HTTP_AUTHORIZATION' => 'Bearer blahblahblah')
18
- end
19
-
20
- def test_request_with_http_basic_authorization_header_is_not_oauth_api_call
21
- refute GDS::SSO::ApiAccess.oauth_api_call?('HTTP_AUTHORIZATION' => 'Basic Some basic credentials')
22
- end
23
-
24
- def test_request_with_empty_authorization_header_is_not_oauth_api_call
25
- refute GDS::SSO::ApiAccess.oauth_api_call?('HTTP_AUTHORIZATION' => '')
26
- end
27
- end
@@ -1,58 +0,0 @@
1
- require_relative 'test_helper'
2
- require 'active_record'
3
-
4
- class SessionSerialisationTest < Test::Unit::TestCase
5
- class User < ActiveRecord::Base
6
- include GDS::SSO::User
7
-
8
- end
9
-
10
- def setup
11
- @old_user_model = GDS::SSO::Config.user_model
12
- GDS::SSO::Config.user_model = "SessionSerialisationTest::User"
13
- @user = stub("User", uid: 1234)
14
- @serializer = Warden::SessionSerializer.new(nil)
15
- end
16
- def teardown
17
- Timecop.return
18
- GDS::SSO::Config.user_model = @old_user_model
19
- end
20
-
21
- def test_serializing_a_user_returns_the_uid_and_a_timestamp
22
- Timecop.freeze
23
- result = @serializer.serialize(@user)
24
-
25
- assert_equal [1234, Time.now.utc], result
26
- end
27
-
28
- def test_serializing_a_user_without_a_uid_returns_nil
29
- @user.stubs(:uid).returns(nil)
30
- result = @serializer.serialize(@user)
31
-
32
- assert_equal nil, result
33
- end
34
-
35
- def test_deserializing_a_user_and_in_date_timestamp_returns_the_user
36
- User.expects(:where).with(:uid => 1234, :remotely_signed_out => false).returns(stub(:first => :a_user))
37
-
38
- result = @serializer.deserialize [1234, Time.now.utc - GDS::SSO::Config.auth_valid_for + 3600]
39
-
40
- assert_equal :a_user, result
41
- end
42
-
43
- def test_deserializing_a_user_and_out_of_date_timestamp_returns_nil
44
- User.expects(:where).never
45
-
46
- result = @serializer.deserialize [1234, Time.now.utc - GDS::SSO::Config.auth_valid_for - 3600]
47
-
48
- assert_equal nil, result
49
- end
50
-
51
- def test_deserializing_a_user_without_a_timestamp_returns_nil
52
- User.expects(:where).never
53
-
54
- result = @serializer.deserialize 1234
55
-
56
- assert_equal nil, result
57
- end
58
- end
data/test/test_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'bundler'
2
- require 'test/unit'
3
-
4
- Bundler.require :default, :development, :test
5
-
6
- require 'mocha/setup'
7
-
8
- require 'gds-sso'