warden 1.2.6 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +27 -0
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/{History.rdoc → CHANGELOG.md} +76 -38
- data/Gemfile +3 -2
- data/LICENSE +2 -1
- data/README.md +18 -0
- data/Rakefile +4 -8
- data/lib/warden.rb +1 -0
- data/lib/warden/config.rb +1 -0
- data/lib/warden/errors.rb +2 -1
- data/lib/warden/hooks.rb +1 -0
- data/lib/warden/manager.rb +2 -1
- data/lib/warden/mixins/common.rb +1 -0
- data/lib/warden/proxy.rb +24 -4
- data/lib/warden/session_serializer.rb +1 -0
- data/lib/warden/strategies.rb +1 -0
- data/lib/warden/strategies/base.rb +3 -1
- data/lib/warden/test/helpers.rb +2 -1
- data/lib/warden/test/mock.rb +5 -4
- data/lib/warden/test/warden_helpers.rb +1 -0
- data/lib/warden/version.rb +2 -1
- data/warden.gemspec +19 -18
- metadata +18 -37
- data/README.textile +0 -9
- data/spec/helpers/request_helper.rb +0 -51
- data/spec/helpers/strategies/fail_with_user.rb +0 -10
- data/spec/helpers/strategies/failz.rb +0 -8
- data/spec/helpers/strategies/invalid.rb +0 -8
- data/spec/helpers/strategies/pass.rb +0 -8
- data/spec/helpers/strategies/pass_with_message.rb +0 -8
- data/spec/helpers/strategies/password.rb +0 -13
- data/spec/helpers/strategies/single.rb +0 -12
- data/spec/spec_helper.rb +0 -25
- data/spec/warden/authenticated_data_store_spec.rb +0 -114
- data/spec/warden/config_spec.rb +0 -48
- data/spec/warden/errors_spec.rb +0 -47
- data/spec/warden/hooks_spec.rb +0 -373
- data/spec/warden/manager_spec.rb +0 -340
- data/spec/warden/proxy_spec.rb +0 -1050
- data/spec/warden/scoped_session_serializer.rb +0 -123
- data/spec/warden/session_serializer_spec.rb +0 -53
- data/spec/warden/strategies/base_spec.rb +0 -313
- data/spec/warden/strategies_spec.rb +0 -94
- data/spec/warden/test/helpers_spec.rb +0 -93
- data/spec/warden/test/mock_spec.rb +0 -15
- data/spec/warden/test/test_mode_spec.rb +0 -75
    
        data/lib/warden/strategies.rb
    CHANGED
    
    
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # encoding: utf-8
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 2 3 | 
             
            module Warden
         | 
| 3 4 | 
             
              module Strategies
         | 
| 4 5 | 
             
                # A strategy is a place where you can put logic related to authentication. Any strategy inherits
         | 
| @@ -44,6 +45,7 @@ module Warden | |
| 44 45 | 
             
                    @env, @scope = env, scope
         | 
| 45 46 | 
             
                    @status, @headers = nil, {}
         | 
| 46 47 | 
             
                    @halted, @performed = false, false
         | 
| 48 | 
            +
                    @result = nil
         | 
| 47 49 | 
             
                  end
         | 
| 48 50 |  | 
| 49 51 | 
             
                  # The method that is called from above. This method calls the underlying authenticate! method
         | 
| @@ -157,7 +159,7 @@ module Warden | |
| 157 159 | 
             
                  def redirect!(url, params = {}, opts = {})
         | 
| 158 160 | 
             
                    halt!
         | 
| 159 161 | 
             
                    @status = opts[:permanent] ? 301 : 302
         | 
| 160 | 
            -
                    headers["Location"] = url
         | 
| 162 | 
            +
                    headers["Location"] = url.dup
         | 
| 161 163 | 
             
                    headers["Location"] << "?" << Rack::Utils.build_query(params) unless params.empty?
         | 
| 162 164 | 
             
                    headers["Content-Type"] = opts[:content_type] || 'text/plain'
         | 
| 163 165 |  | 
    
        data/lib/warden/test/helpers.rb
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # encoding: utf-8
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 2 3 |  | 
| 3 4 | 
             
            module Warden
         | 
| 4 5 | 
             
              module Test
         | 
| @@ -6,7 +7,7 @@ module Warden | |
| 6 7 | 
             
                # These provide the ability to login and logout on any given request
         | 
| 7 8 | 
             
                # Note: During the teardown phase of your specs you should include: Warden.test_reset!
         | 
| 8 9 | 
             
                module Helpers
         | 
| 9 | 
            -
                  def self.included( | 
| 10 | 
            +
                  def self.included(_base)
         | 
| 10 11 | 
             
                    ::Warden.test_mode!
         | 
| 11 12 | 
             
                  end
         | 
| 12 13 |  | 
    
        data/lib/warden/test/mock.rb
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # encoding: utf-8
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 2 3 |  | 
| 3 4 | 
             
            require 'rack'
         | 
| 4 5 |  | 
| @@ -7,7 +8,7 @@ module Warden | |
| 7 8 | 
             
                # A mock of an application to get a Warden object to test on
         | 
| 8 9 | 
             
                # Note: During the teardown phase of your specs you should include: Warden.test_reset!
         | 
| 9 10 | 
             
                module Mock
         | 
| 10 | 
            -
                  def self.included( | 
| 11 | 
            +
                  def self.included(_base)
         | 
| 11 12 | 
             
                    ::Warden.test_mode!
         | 
| 12 13 | 
             
                  end
         | 
| 13 14 |  | 
| @@ -36,7 +37,7 @@ module Warden | |
| 36 37 | 
             
                  def app
         | 
| 37 38 | 
             
                    @app ||= begin
         | 
| 38 39 | 
             
                      opts = {
         | 
| 39 | 
            -
                        failure_app: lambda {
         | 
| 40 | 
            +
                        failure_app: lambda { |_e|
         | 
| 40 41 | 
             
                          [401, { 'Content-Type' => 'text/plain' }, ['You Fail!']]
         | 
| 41 42 | 
             
                        },
         | 
| 42 43 | 
             
                        default_strategies: :password,
         | 
| @@ -45,7 +46,7 @@ module Warden | |
| 45 46 | 
             
                      Rack::Builder.new do
         | 
| 46 47 | 
             
                        use Warden::Test::Mock::Session
         | 
| 47 48 | 
             
                        use Warden::Manager, opts, &proc {}
         | 
| 48 | 
            -
                        run lambda { | | 
| 49 | 
            +
                        run lambda { |_e|
         | 
| 49 50 | 
             
                          [200, { 'Content-Type' => 'text/plain' }, ['You Win']]
         | 
| 50 51 | 
             
                        }
         | 
| 51 52 | 
             
                      end
         | 
| @@ -54,7 +55,7 @@ module Warden | |
| 54 55 |  | 
| 55 56 | 
             
                  class Session
         | 
| 56 57 | 
             
                    attr_accessor :app
         | 
| 57 | 
            -
                    def initialize(app, | 
| 58 | 
            +
                    def initialize(app, _configs={})
         | 
| 58 59 | 
             
                      @app = app
         | 
| 59 60 | 
             
                    end
         | 
| 60 61 |  | 
    
        data/lib/warden/version.rb
    CHANGED
    
    
    
        data/warden.gemspec
    CHANGED
    
    | @@ -1,24 +1,25 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 2 3 |  | 
| 3 | 
            -
             | 
| 4 | 
            +
            lib = File.expand_path("../lib", __FILE__)
         | 
| 5 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 6 | 
            +
            require 'warden/version'
         | 
| 4 7 |  | 
| 5 | 
            -
            Gem::Specification.new do | | 
| 6 | 
            -
               | 
| 7 | 
            -
               | 
| 8 | 
            -
               | 
| 9 | 
            -
               | 
| 10 | 
            -
               | 
| 11 | 
            -
               | 
| 8 | 
            +
            Gem::Specification.new do |spec|
         | 
| 9 | 
            +
              spec.name = "warden"
         | 
| 10 | 
            +
              spec.version = Warden::VERSION
         | 
| 11 | 
            +
              spec.authors = ["Daniel Neighman", "Justin Smestad", "Whitney Smestad", "José Valim"]
         | 
| 12 | 
            +
              spec.email = %q{hasox.sox@gmail.com justin.smestad@gmail.com whitcolorado@gmail.com}
         | 
| 13 | 
            +
              spec.homepage = "https://github.com/hassox/warden"
         | 
| 14 | 
            +
              spec.summary = "An authentication library compatible with all Rack-based frameworks"
         | 
| 15 | 
            +
              spec.license = "MIT"
         | 
| 16 | 
            +
              spec.extra_rdoc_files = [
         | 
| 12 17 | 
             
                "LICENSE",
         | 
| 13 | 
            -
             | 
| 18 | 
            +
                "README.md"
         | 
| 14 19 | 
             
              ]
         | 
| 15 | 
            -
               | 
| 16 | 
            -
             | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
               | 
| 20 | 
            -
              s.rubygems_version = %q{1.3.7}
         | 
| 21 | 
            -
              s.summary = %q{Rack middleware that provides authentication for rack applications}
         | 
| 22 | 
            -
              s.add_dependency "rack", ">= 1.0"
         | 
| 20 | 
            +
              spec.files = `git ls-files -z`.split("\x0").reject do |f|
         | 
| 21 | 
            +
                f.match(%r{^(test|spec|features)/})
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
              spec.require_paths = ["lib"]
         | 
| 24 | 
            +
              spec.add_dependency "rack", ">= 2.0.9"
         | 
| 23 25 | 
             
            end
         | 
| 24 | 
            -
             | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,17 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: warden
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.2. | 
| 4 | 
            +
              version: 1.2.9
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Daniel Neighman
         | 
| 8 | 
            +
            - Justin Smestad
         | 
| 9 | 
            +
            - Whitney Smestad
         | 
| 10 | 
            +
            - José Valim
         | 
| 8 11 | 
             
            autorequire: 
         | 
| 9 12 | 
             
            bindir: bin
         | 
| 10 13 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 14 | 
            +
            date: 2020-08-31 00:00:00.000000000 Z
         | 
| 12 15 | 
             
            dependencies:
         | 
| 13 16 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 17 | 
             
              name: rack
         | 
| @@ -16,26 +19,29 @@ dependencies: | |
| 16 19 | 
             
                requirements:
         | 
| 17 20 | 
             
                - - ">="
         | 
| 18 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 22 | 
            +
                    version: 2.0.9
         | 
| 20 23 | 
             
              type: :runtime
         | 
| 21 24 | 
             
              prerelease: false
         | 
| 22 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 26 | 
             
                requirements:
         | 
| 24 27 | 
             
                - - ">="
         | 
| 25 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 29 | 
            +
                    version: 2.0.9
         | 
| 27 30 | 
             
            description: 
         | 
| 28 | 
            -
            email:  | 
| 31 | 
            +
            email: hasox.sox@gmail.com justin.smestad@gmail.com whitcolorado@gmail.com
         | 
| 29 32 | 
             
            executables: []
         | 
| 30 33 | 
             
            extensions: []
         | 
| 31 34 | 
             
            extra_rdoc_files:
         | 
| 32 35 | 
             
            - LICENSE
         | 
| 33 | 
            -
            - README. | 
| 36 | 
            +
            - README.md
         | 
| 34 37 | 
             
            files:
         | 
| 38 | 
            +
            - ".github/workflows/ruby.yml"
         | 
| 39 | 
            +
            - ".gitignore"
         | 
| 40 | 
            +
            - ".rspec"
         | 
| 41 | 
            +
            - CHANGELOG.md
         | 
| 35 42 | 
             
            - Gemfile
         | 
| 36 | 
            -
            - History.rdoc
         | 
| 37 43 | 
             
            - LICENSE
         | 
| 38 | 
            -
            - README. | 
| 44 | 
            +
            - README.md
         | 
| 39 45 | 
             
            - Rakefile
         | 
| 40 46 | 
             
            - lib/warden.rb
         | 
| 41 47 | 
             
            - lib/warden/config.rb
         | 
| @@ -51,36 +57,13 @@ files: | |
| 51 57 | 
             
            - lib/warden/test/mock.rb
         | 
| 52 58 | 
             
            - lib/warden/test/warden_helpers.rb
         | 
| 53 59 | 
             
            - lib/warden/version.rb
         | 
| 54 | 
            -
            - spec/helpers/request_helper.rb
         | 
| 55 | 
            -
            - spec/helpers/strategies/fail_with_user.rb
         | 
| 56 | 
            -
            - spec/helpers/strategies/failz.rb
         | 
| 57 | 
            -
            - spec/helpers/strategies/invalid.rb
         | 
| 58 | 
            -
            - spec/helpers/strategies/pass.rb
         | 
| 59 | 
            -
            - spec/helpers/strategies/pass_with_message.rb
         | 
| 60 | 
            -
            - spec/helpers/strategies/password.rb
         | 
| 61 | 
            -
            - spec/helpers/strategies/single.rb
         | 
| 62 | 
            -
            - spec/spec_helper.rb
         | 
| 63 | 
            -
            - spec/warden/authenticated_data_store_spec.rb
         | 
| 64 | 
            -
            - spec/warden/config_spec.rb
         | 
| 65 | 
            -
            - spec/warden/errors_spec.rb
         | 
| 66 | 
            -
            - spec/warden/hooks_spec.rb
         | 
| 67 | 
            -
            - spec/warden/manager_spec.rb
         | 
| 68 | 
            -
            - spec/warden/proxy_spec.rb
         | 
| 69 | 
            -
            - spec/warden/scoped_session_serializer.rb
         | 
| 70 | 
            -
            - spec/warden/session_serializer_spec.rb
         | 
| 71 | 
            -
            - spec/warden/strategies/base_spec.rb
         | 
| 72 | 
            -
            - spec/warden/strategies_spec.rb
         | 
| 73 | 
            -
            - spec/warden/test/helpers_spec.rb
         | 
| 74 | 
            -
            - spec/warden/test/mock_spec.rb
         | 
| 75 | 
            -
            - spec/warden/test/test_mode_spec.rb
         | 
| 76 60 | 
             
            - warden.gemspec
         | 
| 77 | 
            -
            homepage:  | 
| 61 | 
            +
            homepage: https://github.com/hassox/warden
         | 
| 78 62 | 
             
            licenses:
         | 
| 79 63 | 
             
            - MIT
         | 
| 80 64 | 
             
            metadata: {}
         | 
| 81 65 | 
             
            post_install_message: 
         | 
| 82 | 
            -
            rdoc_options:
         | 
| 83 | 
            -
            - "--charset=UTF-8"
         | 
| 66 | 
            +
            rdoc_options: []
         | 
| 84 67 | 
             
            require_paths:
         | 
| 85 68 | 
             
            - lib
         | 
| 86 69 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| @@ -94,10 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 94 77 | 
             
                - !ruby/object:Gem::Version
         | 
| 95 78 | 
             
                  version: '0'
         | 
| 96 79 | 
             
            requirements: []
         | 
| 97 | 
            -
             | 
| 98 | 
            -
            rubygems_version: 2.4.5.1
         | 
| 80 | 
            +
            rubygems_version: 3.1.2
         | 
| 99 81 | 
             
            signing_key: 
         | 
| 100 82 | 
             
            specification_version: 4
         | 
| 101 | 
            -
            summary:  | 
| 83 | 
            +
            summary: An authentication library compatible with all Rack-based frameworks
         | 
| 102 84 | 
             
            test_files: []
         | 
| 103 | 
            -
            has_rdoc: 
         | 
    
        data/README.textile
    DELETED
    
    | @@ -1,9 +0,0 @@ | |
| 1 | 
            -
            Please see the "Warden Wiki":http://wiki.github.com/hassox/warden for overview documentation.
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            h2. Maintainers
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            * Daniel Neighman (hassox)
         | 
| 6 | 
            -
            * José Valim (josevalim)
         | 
| 7 | 
            -
            * Justin Smestad (jsmestad)
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            "A list of all contributors is available on Github.":https://github.com/hassox/warden/contributors
         | 
| @@ -1,51 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
            module Warden::Spec
         | 
| 3 | 
            -
              module Helpers
         | 
| 4 | 
            -
                FAILURE_APP = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["You Fail!"]] }
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                def env_with_params(path = "/", params = {}, env = {})
         | 
| 7 | 
            -
                  method = params.delete(:method) || "GET"
         | 
| 8 | 
            -
                  env = { 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => "#{method}" }.merge(env)
         | 
| 9 | 
            -
                  Rack::MockRequest.env_for("#{path}?#{Rack::Utils.build_query(params)}", env)
         | 
| 10 | 
            -
                end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                def setup_rack(app = nil, opts = {}, &block)
         | 
| 13 | 
            -
                  app ||= block if block_given?
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  opts[:failure_app]         ||= failure_app
         | 
| 16 | 
            -
                  opts[:default_strategies]  ||= [:password]
         | 
| 17 | 
            -
                  opts[:default_serializers] ||= [:session]
         | 
| 18 | 
            -
                  blk = opts[:configurator] || proc{}
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                  Rack::Builder.new do
         | 
| 21 | 
            -
                    use opts[:session] || Warden::Spec::Helpers::Session unless opts[:nil_session]
         | 
| 22 | 
            -
                    use Warden::Manager, opts, &blk
         | 
| 23 | 
            -
                    run app
         | 
| 24 | 
            -
                  end
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                def valid_response
         | 
| 28 | 
            -
                  Rack::Response.new("OK").finish
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                def failure_app
         | 
| 32 | 
            -
                  Warden::Spec::Helpers::FAILURE_APP
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                def success_app
         | 
| 36 | 
            -
                  lambda{|e| [200, {"Content-Type" => "text/plain"}, ["You Win"]]}
         | 
| 37 | 
            -
                end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                class Session
         | 
| 40 | 
            -
                  attr_accessor :app
         | 
| 41 | 
            -
                  def initialize(app,configs = {})
         | 
| 42 | 
            -
                    @app = app
         | 
| 43 | 
            -
                  end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                  def call(e)
         | 
| 46 | 
            -
                    e['rack.session'] ||= {}
         | 
| 47 | 
            -
                    @app.call(e)
         | 
| 48 | 
            -
                  end
         | 
| 49 | 
            -
                end # session
         | 
| 50 | 
            -
              end
         | 
| 51 | 
            -
            end
         | 
| @@ -1,8 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
            Warden::Strategies.add(:pass_with_message) do
         | 
| 3 | 
            -
              def authenticate!
         | 
| 4 | 
            -
                request.env['warden.spec.strategies'] ||= []
         | 
| 5 | 
            -
                request.env['warden.spec.strategies'] << :pass_with_message
         | 
| 6 | 
            -
                success!("Valid User", "The Success Strategy Has Accepted You") unless scope == :failz
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
            end
         | 
| @@ -1,13 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
            Warden::Strategies.add(:password) do
         | 
| 3 | 
            -
              def authenticate!
         | 
| 4 | 
            -
                request.env['warden.spec.strategies'] ||= []
         | 
| 5 | 
            -
                request.env['warden.spec.strategies'] << :password
         | 
| 6 | 
            -
                if params["password"] || params["username"]
         | 
| 7 | 
            -
                  params["password"] == "sekrit" && params["username"] == "fred" ?
         | 
| 8 | 
            -
                    success!("Authenticated User") : fail!("Username or password is incorrect")
         | 
| 9 | 
            -
                else
         | 
| 10 | 
            -
                  pass
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
            end
         | 
    
        data/spec/spec_helper.rb
    DELETED
    
    | @@ -1,25 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
            $TESTING=true
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
         | 
| 5 | 
            -
            $:.unshift File.expand_path(File.join(File.dirname(__FILE__)))
         | 
| 6 | 
            -
            require 'warden'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            require 'rubygems'
         | 
| 9 | 
            -
            require 'rack'
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            Dir[File.join(File.dirname(__FILE__), "helpers", "**/*.rb")].each do |f|
         | 
| 12 | 
            -
              require f
         | 
| 13 | 
            -
            end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            RSpec.configure do |config|
         | 
| 16 | 
            -
              config.include(Warden::Spec::Helpers)
         | 
| 17 | 
            -
              config.include(Warden::Test::Helpers)
         | 
| 18 | 
            -
              config.include(Warden::Test::Mock)
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              def load_strategies
         | 
| 21 | 
            -
                Dir[File.join(File.dirname(__FILE__), "helpers", "strategies", "**/*.rb")].each do |f|
         | 
| 22 | 
            -
                  load f
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
              end
         | 
| 25 | 
            -
            end
         | 
| @@ -1,114 +0,0 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 | 
            -
            require 'spec_helper'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            describe "authenticated data store" do
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              before(:each) do
         | 
| 7 | 
            -
                @env = env_with_params
         | 
| 8 | 
            -
                @env['rack.session'] = {
         | 
| 9 | 
            -
                  "warden.user.foo.key"     => "foo user",
         | 
| 10 | 
            -
                  "warden.user.default.key" => "default user",
         | 
| 11 | 
            -
                  :foo => "bar"
         | 
| 12 | 
            -
                }
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              it "should store data for the default scope" do
         | 
| 16 | 
            -
                app = lambda do |e|
         | 
| 17 | 
            -
                  e['warden'].authenticate(:pass)
         | 
| 18 | 
            -
                  e['warden'].authenticate(:pass, :scope => :foo)
         | 
| 19 | 
            -
                  expect(e['warden']).to be_authenticated
         | 
| 20 | 
            -
                  expect(e['warden']).to be_authenticated(:foo)
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  # Store the data for :default
         | 
| 23 | 
            -
                  e['warden'].session[:key] = "value"
         | 
| 24 | 
            -
                  valid_response
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
                setup_rack(app).call(@env)
         | 
| 27 | 
            -
                expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
         | 
| 28 | 
            -
                expect(@env['rack.session']['warden.user.foo.session']).to be_nil
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              it "should store data for the foo user" do
         | 
| 32 | 
            -
                app = lambda do |e|
         | 
| 33 | 
            -
                  e['warden'].session(:foo)[:key] = "value"
         | 
| 34 | 
            -
                  valid_response
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
                setup_rack(app).call(@env)
         | 
| 37 | 
            -
                expect(@env['rack.session']['warden.user.foo.session']).to eq(key: "value")
         | 
| 38 | 
            -
              end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
              it "should store the data separately" do
         | 
| 41 | 
            -
                app = lambda do |e|
         | 
| 42 | 
            -
                  e['warden'].session[:key] = "value"
         | 
| 43 | 
            -
                  e['warden'].session(:foo)[:key] = "another value"
         | 
| 44 | 
            -
                  valid_response
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
                setup_rack(app).call(@env)
         | 
| 47 | 
            -
                expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
         | 
| 48 | 
            -
                expect(@env['rack.session']['warden.user.foo.session'    ]).to eq(key: "another value")
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
              it "should clear the foo scoped data when foo logs out" do
         | 
| 52 | 
            -
                app = lambda do |e|
         | 
| 53 | 
            -
                  e['warden'].session[:key] = "value"
         | 
| 54 | 
            -
                  e['warden'].session(:foo)[:key] = "another value"
         | 
| 55 | 
            -
                  e['warden'].logout(:foo)
         | 
| 56 | 
            -
                  valid_response
         | 
| 57 | 
            -
                end
         | 
| 58 | 
            -
                setup_rack(app).call(@env)
         | 
| 59 | 
            -
                expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
         | 
| 60 | 
            -
                expect(@env['rack.session']['warden.user.foo.session'    ]).to be_nil
         | 
| 61 | 
            -
              end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
              it "should clear out the default data when :default logs out" do
         | 
| 64 | 
            -
                app = lambda do |e|
         | 
| 65 | 
            -
                  e['warden'].session[:key] = "value"
         | 
| 66 | 
            -
                  e['warden'].session(:foo)[:key] = "another value"
         | 
| 67 | 
            -
                  e['warden'].logout(:default)
         | 
| 68 | 
            -
                  valid_response
         | 
| 69 | 
            -
                end
         | 
| 70 | 
            -
                setup_rack(app).call(@env)
         | 
| 71 | 
            -
                expect(@env['rack.session']['warden.user.default.session']).to be_nil
         | 
| 72 | 
            -
                expect(@env['rack.session']['warden.user.foo.session'    ]).to eq(key: "another value")
         | 
| 73 | 
            -
              end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
              it "should clear out all data when a general logout is performed" do
         | 
| 76 | 
            -
                app = lambda do |e|
         | 
| 77 | 
            -
                  e['warden'].session[:key] = "value"
         | 
| 78 | 
            -
                  e['warden'].session(:foo)[:key] = "another value"
         | 
| 79 | 
            -
                  e['warden'].logout
         | 
| 80 | 
            -
                  valid_response
         | 
| 81 | 
            -
                end
         | 
| 82 | 
            -
                setup_rack(app).call(@env)
         | 
| 83 | 
            -
                expect(@env['rack.session']['warden.user.default.session']).to be_nil
         | 
| 84 | 
            -
                expect(@env['rack.session']['warden.user.foo.session'    ]).to be_nil
         | 
| 85 | 
            -
              end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
              it "should logout multiple persons at once" do
         | 
| 88 | 
            -
                @env['rack.session']['warden.user.bar.key'] = "bar user"
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                app = lambda do |e|
         | 
| 91 | 
            -
                  e['warden'].session[:key] = "value"
         | 
| 92 | 
            -
                  e['warden'].session(:foo)[:key] = "another value"
         | 
| 93 | 
            -
                  e['warden'].session(:bar)[:key] = "yet another"
         | 
| 94 | 
            -
                  e['warden'].logout(:bar, :default)
         | 
| 95 | 
            -
                  valid_response
         | 
| 96 | 
            -
                end
         | 
| 97 | 
            -
                setup_rack(app).call(@env)
         | 
| 98 | 
            -
                expect(@env['rack.session']['warden.user.default.session']).to be_nil
         | 
| 99 | 
            -
                expect(@env['rack.session']['warden.user.foo.session'    ]).to eq(key: "another value")
         | 
| 100 | 
            -
                expect(@env['rack.session']['warden.user.bar.session'    ]).to be_nil
         | 
| 101 | 
            -
              end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
              it "should not store data for a user who is not logged in" do
         | 
| 104 | 
            -
                @env['rack.session']
         | 
| 105 | 
            -
                app = lambda do |e|
         | 
| 106 | 
            -
                  e['warden'].session(:not_here)[:key] = "value"
         | 
| 107 | 
            -
                  valid_response
         | 
| 108 | 
            -
                end
         | 
| 109 | 
            -
             | 
| 110 | 
            -
                expect {
         | 
| 111 | 
            -
                  setup_rack(app).call(@env)
         | 
| 112 | 
            -
                }.to raise_error(Warden::NotAuthenticated)
         | 
| 113 | 
            -
              end
         | 
| 114 | 
            -
            end
         |