Sha256: 6ac5e424f0d778f1b443545aae69396e80f552c9074ebc3716bfe38b9a20b233

Contents?: true

Size: 1.34 KB

Versions: 67

Compression:

Stored size: 1.34 KB

Contents

require File.expand_path('../test_helper', File.dirname(__FILE__))

class AuthenticationTest < 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 '/cms-admin/sites'
    assert_response :unauthorized
    get '/'
    assert_response :success
  end
  
  def test_get_with_authorized_access
    http_auth :get, '/cms-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, '/cms-admin/sites'
    assert_response :unauthorized
    http_auth :get, '/cms-admin/sites', {}, 'newuser', 'newpass'
    assert_response :success
  end
  
  def test_get_public_with_custom_auth
    CmsContentController.send :include, TestLockPublicAuth
    get '/'
    assert_response :redirect
    assert_redirected_to '/lockout'
    # reset auth module
    CmsContentController.send :include, TestUnlockPublicAuth
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.31 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.8.3 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.8.2 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.8.1 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.8.0 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.30 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.7.3 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.7.1 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.7.0 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.26 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.25 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.24 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.23 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.22 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.21 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.20 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.19 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.18 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.17 test/integration/authentication_test.rb
comfortable_mexican_sofa-1.6.16 test/integration/authentication_test.rb