Sha256: 2325f33b4348cd21212521b1ef4d4b695c5c8b31043486f49bf0007e47da65a8

Contents?: true

Size: 1.11 KB

Versions: 22

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'
require 'gds-sso/api_access'

class ApiAccessTest < Test::Unit::TestCase
  def test_internet_explorer_7_accept_header_is_not_considered_to_be_api_call
    ie7_accept_header = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, ' +
      'application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, ' +
      'application/x-ms-application, */*'
    refute GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => ie7_accept_header)
  end

  def test_application_json_accept_header_is_considered_to_be_api_call
    assert GDS::SSO::ApiAccess.api_call?('HTTP_ACCEPT' => 'application/json')
  end

  def test_request_with_authorization_header_is_oauth_api_call
    assert GDS::SSO::ApiAccess.oauth_api_call?('HTTP_AUTHORIZATION' => 'Bearer blahblahblah')
  end

  def test_request_with_http_basic_authorization_header_is_not_oauth_api_call
    refute GDS::SSO::ApiAccess.oauth_api_call?('HTTP_AUTHORIZATION' => 'Basic Some basic credentials')
  end

  def test_request_with_empty_authorization_header_is_not_oauth_api_call
    refute GDS::SSO::ApiAccess.oauth_api_call?('HTTP_AUTHORIZATION' => '')
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
gds-sso-9.2.1 test/api_access_test.rb
gds-sso-9.2.0 test/api_access_test.rb
gds-sso-9.1.2 test/api_access_test.rb
gds-sso-9.1.1 test/api_access_test.rb
gds-sso-9.1.0 test/api_access_test.rb
gds-sso-9.0.0 test/api_access_test.rb
gds-sso-8.0.0 test/api_access_test.rb
gds-sso-7.0.0 test/api_access_test.rb
gds-sso-6.0.0 test/api_access_test.rb
gds-sso-5.0.0 test/api_access_test.rb
gds-sso-4.0.0 test/api_access_test.rb
gds-sso-3.1.1 test/api_access_test.rb
gds-sso-3.1.0 test/api_access_test.rb
gds-sso-3.0.5 test/api_access_test.rb
gds-sso-3.0.4 test/api_access_test.rb
gds-sso-3.0.3 test/api_access_test.rb
gds-sso-3.0.2 test/api_access_test.rb
gds-sso-3.0.1 test/api_access_test.rb
gds-sso-3.0.0 test/api_access_test.rb
gds-sso-2.1.0 test/api_access_test.rb