spec/grape/middleware/auth/digest_spec.rb in grape-0.1.5 vs spec/grape/middleware/auth/digest_spec.rb in grape-0.2.0
- old
+ new
@@ -7,12 +7,10 @@
actual_response.body.empty?
end
end
class Test < Grape::API
- version '1'
-
http_digest({:realm => 'Test Api', :opaque => 'secret'}) do |username|
{'foo' => 'bar'}[username]
end
get '/test' do
@@ -24,26 +22,26 @@
def app
Test
end
it 'should be a digest authentication challenge' do
- get '/1/test'
+ get '/test'
last_response.should be_challenge
end
it 'should throw a 401 if no auth is given' do
- get '/1/test'
+ get '/test'
last_response.status.should == 401
end
it 'should authenticate if given valid creds' do
digest_authorize "foo", "bar"
- get '/1/test'
+ get '/test'
last_response.status.should == 200
end
it 'should throw a 401 if given invalid creds' do
digest_authorize "bar", "foo"
- get '/1/test'
+ get '/test'
last_response.status.should == 401
end
end