Sha256: 2adb91ff4e2079a4c8768f9479190c6f4309c1c81661de32a172cb1b7a865727

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

require_relative '../test_helper'

class AuthenticationIntegrationTest < ActionDispatch::IntegrationTest
  
  module TestLockPublicAuth
    def authenticate
      return redirect_to('/lockout')
    end
  end
  
  module TestUnlockPublicAuth
    def authenticate
      true
    end
  end
  
  def test_get_with_unauthorized_access
    assert_equal 'ComfortableMexicanSofa::HttpAuth', ComfortableMexicanSofa.config.admin_auth
    get '/admin/sites'
    assert_response :unauthorized
    get '/'
    assert_response :success
  end
  
  def test_get_with_authorized_access
    http_auth :get, '/admin/sites'
    assert_response :success
  end
  
  def test_get_with_changed_default_config
    assert_equal 'ComfortableMexicanSofa::HttpAuth', ComfortableMexicanSofa.config.admin_auth
    ComfortableMexicanSofa::HttpAuth.username = 'newuser'
    ComfortableMexicanSofa::HttpAuth.password = 'newpass'
    http_auth :get, '/admin/sites'
    assert_response :unauthorized
    http_auth :get, '/admin/sites', {}, 'newuser', 'newpass'
    assert_response :success
  end
  
  def test_get_public_with_custom_auth
    Cms::ContentController.send :include, TestLockPublicAuth
    get '/'
    assert_response :redirect
    assert_redirected_to '/lockout'
    # reset auth module
    Cms::ContentController.send :include, TestUnlockPublicAuth
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.11.2 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.11.1 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.11.0 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.10.3 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.10.2 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.10.1 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.10.0 test/integration/authentication_test.rb