token_authentication_test.rb
26 lines
| 611 B
| text/x-ruby
|
RubyLexer
|
r4395 | require File.expand_path('../../../test_helper', __FILE__) | ||
|
r3104 | |||
|
r4243 | class ApiTest::TokenAuthenticationTest < ActionController::IntegrationTest | ||
|
r3104 | fixtures :all | ||
|
r3105 | def setup | ||
|
r3106 | Setting.rest_api_enabled = '1' | ||
|
r3105 | Setting.login_required = '1' | ||
end | ||||
def teardown | ||||
|
r3106 | Setting.rest_api_enabled = '0' | ||
|
r3105 | Setting.login_required = '0' | ||
end | ||||
|
r3104 | # Using the NewsController because it's a simple API. | ||
|
r3105 | context "get /news" do | ||
|
r3104 | context "in :xml format" do | ||
|
r4244 | should_allow_key_based_auth(:get, "/news.xml") | ||
|
r3104 | end | ||
context "in :json format" do | ||||
|
r4244 | should_allow_key_based_auth(:get, "/news.json") | ||
|
r3104 | end | ||
end | ||||
end | ||||