Revert "Revert "BUGFIX: improve error messages for invalid API keys""

This reverts commit e9afe28586cd887b92fa86c52db78d543a70e433.
This commit is contained in:
Sam
2014-05-23 08:13:25 +10:00
parent 43bac5467a
commit cf254000cf
6 changed files with 94 additions and 40 deletions

View File

@ -163,16 +163,14 @@ describe 'api' do
it 'disallows phonies to bookmark posts' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).never
lambda do
put :bookmark, bookmarked: "true", post_id: post.id, api_key: SecureRandom.hex(32), api_username: user.username, format: :json
end.should raise_error Discourse::NotLoggedIn
put :bookmark, bookmarked: "true", post_id: post.id, api_key: SecureRandom.hex(32), api_username: user.username, format: :json
response.code.to_i.should == 403
end
it 'disallows blank api' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).never
lambda do
put :bookmark, bookmarked: "true", post_id: post.id, api_key: "", api_username: user.username, format: :json
end.should raise_error Discourse::NotLoggedIn
put :bookmark, bookmarked: "true", post_id: post.id, api_key: "", api_username: user.username, format: :json
response.code.to_i.should == 403
end
end
end