File: spec_session_abstract_id.rb

package info (click to toggle)
ruby-rack 2.1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,492 kB
  • sloc: ruby: 14,778; sh: 12; makefile: 6; javascript: 1
file content (33 lines) | stat: -rw-r--r-- 736 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require 'minitest/global_expectations/autorun'
### WARNING: there be hax in this file.

require 'rack/session/abstract/id'

describe Rack::Session::Abstract::ID do
  attr_reader :id

  def setup
    super
    @id = Rack::Session::Abstract::ID
  end

  it "use securerandom" do
    assert_equal ::SecureRandom, id::DEFAULT_OPTIONS[:secure_random]

    id = @id.new nil
    assert_equal ::SecureRandom, id.sid_secure
  end

  it "allow to use another securerandom provider" do
    secure_random = Class.new do
      def hex(*args)
        'fake_hex'
      end
    end
    id = Rack::Session::Abstract::ID.new nil, secure_random: secure_random.new
    id.send(:generate_sid).must_equal 'fake_hex'
  end

end