Sha256: aa2d460c3717b27d8ceeac588a37c7d4153fa7f83978b9c87b669e03821f870a

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

#
# Testing rufus-verbs
#
# jmettraux@gmail.com
#
# Sun Jan 13 12:33:03 JST 2008
#

require 'test/unit'
require 'testbase'

require 'rufus/verbs'


class Auth1Test < Test::Unit::TestCase
    include TestBaseMixin

    include Rufus::Verbs

    #
    # Using an items server with the authentication on.
    #
    def setup

        @server = ItemServer.new :auth => :digest
        @server.start
    end


    def test_0

        #res = get :uri => "http://localhost:7777/items"
        #assert_equal 200, res.code.to_i
        #assert_equal "{}", res.body.strip
        #res = expect 401, nil, get(:uri => "http://localhost:7777/items")
        #p res['www-authenticate']

        #$DEBUG = true

        ep = EndPoint.new :digest_authentication => [ "test", "pass" ]

        expect 200, {}, ep.get("http://localhost:7777/items")
        assert_equal 2, $dcount

        expect 200, {}, ep.get("http://localhost:7777/items")
        assert_equal 3, $dcount

        expect 201, nil, ep.post("http://localhost:7777/items/1") { "hammer" }
        assert_equal 4, $dcount

        expect 200, { 1 => "hammer" }, ep.get("http://localhost:7777/items")
        assert_equal 5, $dcount

        expect 401, nil, get(:uri => "http://localhost:7777/items")
        assert_equal 6, $dcount

        expect 401, nil, get(
            :uri => "http://localhost:7777/items", 
            :http_basic_authentication => [ "toto", "toto" ])
        assert_equal 7, $dcount

        expect 200, { 1 => "hammer" }, get(
            :uri => "http://localhost:7777/items", 
            :digest_authentication => [ "test", "pass" ])
        assert_equal 9, $dcount
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rufus-verbs-0.4 test/auth1_test.rb
rufus-verbs-0.9 test/auth1_test.rb
rufus-verbs-0.5 test/auth1_test.rb
rufus-verbs-0.8 test/auth1_test.rb
rufus-verbs-0.3 test/auth1_test.rb
rufus-verbs-0.6 test/auth1_test.rb
rufus-verbs-0.10 test/auth1_test.rb
rufus-verbs-0.7 test/auth1_test.rb