Sha256: 534b89c8bb805b52ecf17daf0ddf3cfb807af490c016c1b9364e1dc3625bb854

Contents?: true

Size: 1.99 KB

Versions: 3

Compression:

Stored size: 1.99 KB

Contents

require "test_helper"

module SessionTest
  class HttpAuthTest < ActiveSupport::TestCase
    class ConfigTest < ActiveSupport::TestCase
      def test_allow_http_basic_auth
        UserSession.allow_http_basic_auth = false
        assert_equal false, UserSession.allow_http_basic_auth

        UserSession.allow_http_basic_auth true
        assert_equal true, UserSession.allow_http_basic_auth
      end

      def test_request_http_basic_auth
        UserSession.request_http_basic_auth = true
        assert_equal true, UserSession.request_http_basic_auth

        UserSession.request_http_basic_auth = false
        assert_equal false, UserSession.request_http_basic_auth
      end

      def test_http_basic_auth_realm
        assert_equal "Application", UserSession.http_basic_auth_realm
        UserSession.http_basic_auth_realm = "TestRealm"
        assert_equal "TestRealm", UserSession.http_basic_auth_realm
      end
    end

    class InstanceMethodsTest < ActiveSupport::TestCase
      def test_persist_persist_by_http_auth
        UserSession.allow_http_basic_auth = true

        aaron = users(:aaron)
        http_basic_auth_for do
          refute UserSession.find
        end
        http_basic_auth_for(aaron) do
          assert session = UserSession.find
          assert_equal aaron, session.record
          assert_equal aaron.login, session.login
          assert_equal "aaronrocks", session.send(:protected_password)
          refute controller.http_auth_requested?
        end
        unset_session
        UserSession.request_http_basic_auth = true
        UserSession.http_basic_auth_realm = "PersistTestRealm"
        http_basic_auth_for(aaron) do
          assert session = UserSession.find
          assert_equal aaron, session.record
          assert_equal aaron.login, session.login
          assert_equal "aaronrocks", session.send(:protected_password)
          assert_equal "PersistTestRealm", controller.realm
          assert controller.http_auth_requested?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authlogic-4.2.0 test/session_test/http_auth_test.rb
authlogic-4.1.1 test/session_test/http_auth_test.rb
authlogic-4.1.0 test/session_test/http_auth_test.rb