Sha256: 89cd8934f8b9e0f090e4f8d2ec3ca7f61589af9a67e4537d3e378bd3563654a5

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

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

require File.dirname(__FILE__) + '/base.rb'


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

2 entries across 2 versions & 1 rubygems

Version Path
rufus-verbs-1.0.1 test/auth1_test.rb
rufus-verbs-1.0.0 test/auth1_test.rb