Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: b98ae0d619
Fetching contributors…

Cannot retrieve contributors at this time

66 lines (46 sloc) 1.64 kB
#
# 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
Jump to Line
Something went wrong with that request. Please try again.