@@ -12,7 +12,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
12 | Setting.rest_api_enabled = '1' |
|
12 | Setting.rest_api_enabled = '1' | |
13 | Setting.login_required = '0' |
|
13 | Setting.login_required = '0' | |
14 | end |
|
14 | end | |
15 |
|
15 | |||
16 | # Using the NewsController because it's a simple API. |
|
16 | # Using the NewsController because it's a simple API. | |
17 | context "get /news with the API disabled" do |
|
17 | context "get /news with the API disabled" do | |
18 |
|
18 | |||
@@ -23,7 +23,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
23 | @token = Token.generate!(:user => @user, :action => 'api') |
|
23 | @token = Token.generate!(:user => @user, :action => 'api') | |
24 | get "/news.xml?key=#{@token.value}" |
|
24 | get "/news.xml?key=#{@token.value}" | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | should_respond_with :unauthorized |
|
27 | should_respond_with :unauthorized | |
28 | should_respond_with_content_type :xml |
|
28 | should_respond_with_content_type :xml | |
29 | should "not login as the user" do |
|
29 | should "not login as the user" do | |
@@ -37,7 +37,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
37 | @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password') |
|
37 | @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password') | |
38 | get "/news.xml", nil, :authorization => @authorization |
|
38 | get "/news.xml", nil, :authorization => @authorization | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | should_respond_with :unauthorized |
|
41 | should_respond_with :unauthorized | |
42 | should_respond_with_content_type :xml |
|
42 | should_respond_with_content_type :xml | |
43 | should "not login as the user" do |
|
43 | should "not login as the user" do | |
@@ -52,7 +52,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
52 | @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X') |
|
52 | @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X') | |
53 | get "/news.xml", nil, :authorization => @authorization |
|
53 | get "/news.xml", nil, :authorization => @authorization | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | should_respond_with :unauthorized |
|
56 | should_respond_with :unauthorized | |
57 | should_respond_with_content_type :xml |
|
57 | should_respond_with_content_type :xml | |
58 | should "not login as the user" do |
|
58 | should "not login as the user" do | |
@@ -68,7 +68,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
68 | @token = Token.generate!(:user => @user, :action => 'api') |
|
68 | @token = Token.generate!(:user => @user, :action => 'api') | |
69 | get "/news.json?key=#{@token.value}" |
|
69 | get "/news.json?key=#{@token.value}" | |
70 | end |
|
70 | end | |
71 |
|
71 | |||
72 | should_respond_with :unauthorized |
|
72 | should_respond_with :unauthorized | |
73 | should_respond_with_content_type :json |
|
73 | should_respond_with_content_type :json | |
74 | should "not login as the user" do |
|
74 | should "not login as the user" do | |
@@ -82,7 +82,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
82 | @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password') |
|
82 | @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'my_password') | |
83 | get "/news.json", nil, :authorization => @authorization |
|
83 | get "/news.json", nil, :authorization => @authorization | |
84 | end |
|
84 | end | |
85 |
|
85 | |||
86 | should_respond_with :unauthorized |
|
86 | should_respond_with :unauthorized | |
87 | should_respond_with_content_type :json |
|
87 | should_respond_with_content_type :json | |
88 | should "not login as the user" do |
|
88 | should "not login as the user" do | |
@@ -104,7 +104,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||||
104 | assert_equal User.anonymous, User.current |
|
104 | assert_equal User.anonymous, User.current | |
105 | end |
|
105 | end | |
106 | end |
|
106 | end | |
107 |
|
107 | |||
108 |
end |
|
108 | end | |
109 | end |
|
109 | end | |
110 | end |
|
110 | end |
General Comments 0
You need to be logged in to leave comments.
Login now