File: digest_session_test.rb

package info (click to toggle)
ruby-httpauth 0.2.1%2Bgh-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 192 kB
  • ctags: 127
  • sloc: ruby: 925; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (3)
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
34
35
36
37
$LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'

require 'test/unit'
require 'digest/md5'

require 'test_helper'
require 'httpauth/digest'

class DigestSessionTest < Test::Unit::TestCase
  def setup
    remove_tmpdir
    create_tmpdir
    @opaque = Digest::MD5.hexdigest Time.now.to_s
  end

  def test_session_create_and_load
    h = {:username => 'bob', :password => 'secret'}
    session = HTTPAuth::Digest::Session.new @opaque, :tmpdir => tmpdir
    session.save h

    session = HTTPAuth::Digest::Session.new @opaque, :tmpdir => tmpdir
    assert_equal h, session.load

    session = HTTPAuth::Digest::Session.new @opaque, :tmpdir => tmpdir
    assert_equal h, session.load
  end

  def test_session_load_without_session
    session = HTTPAuth::Digest::Session.new @opaque, :tmpdir => tmpdir
    h = nil
    assert_nothing_raised do
      h = session.load
    end
    assert_equal({}, h)
  end
end