Support for per-user API keys

This commit is contained in:
Robin Ward
2013-10-22 15:53:08 -04:00
parent 5e2d8dcf37
commit 348e2e3ef2
45 changed files with 670 additions and 87 deletions

View File

@ -15,10 +15,18 @@ describe 'api' do
Fabricate(:post)
end
let(:api_key) { user.generate_api_key(user) }
let(:master_key) { ApiKey.create_master_key }
# choosing an arbitrarily easy to mock trusted activity
it 'allows users with api key to bookmark posts' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).once
put :bookmark, bookmarked: "true", post_id: post.id, api_key: SiteSetting.api_key, api_username: user.username, format: :json
put :bookmark, bookmarked: "true", post_id: post.id, api_key: api_key.key, format: :json
end
it 'allows users with a master api key to bookmark posts' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).once
put :bookmark, bookmarked: "true", post_id: post.id, api_key: master_key.key, api_username: user.username, format: :json
end
it 'disallows phonies to bookmark posts' do