mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 21:55:25 +08:00
SECURITY: Prevent access to other user's bookmark lists
This commit is contained in:
@ -4167,6 +4167,25 @@ describe UsersController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#bookmarks" do
|
||||
let!(:bookmark1) { Fabricate(:bookmark, user: user) }
|
||||
let!(:bookmark2) { Fabricate(:bookmark, user: user) }
|
||||
let!(:bookmark3) { Fabricate(:bookmark) }
|
||||
|
||||
it "returns a list of serialized bookmarks for the user" do
|
||||
sign_in(user)
|
||||
get "/u/#{user.username}/bookmarks.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['bookmarks'].map { |b| b['id'] }).to match_array([bookmark1.id, bookmark2.id])
|
||||
end
|
||||
|
||||
it "does not show another user's bookmarks" do
|
||||
sign_in(user)
|
||||
get "/u/#{bookmark3.user.username}/bookmarks.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
end
|
||||
|
||||
def create_second_factor_security_key
|
||||
sign_in(user)
|
||||
stub_secure_session_confirmed
|
||||
|
Reference in New Issue
Block a user