mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 10:24:39 +08:00
FEATURE: allow system api to target users via external id or user id
usage ?api_key=XYZ&api_user_external_id=ABC usage ?api_key=XYZ&api_user_id=123
This commit is contained in:
@ -88,6 +88,19 @@ describe Auth::DefaultCurrentUserProvider do
|
||||
expect(provider("/?api_key=hello&api_username=#{user.username.downcase}").current_user.id).to eq(user.id)
|
||||
end
|
||||
|
||||
it "finds a user for a correct system api key with external id" do
|
||||
user = Fabricate(:user)
|
||||
ApiKey.create!(key: "hello", created_by_id: -1)
|
||||
SingleSignOnRecord.create(user_id: user.id, external_id: "abc", last_payload: '')
|
||||
expect(provider("/?api_key=hello&api_user_external_id=abc").current_user.id).to eq(user.id)
|
||||
end
|
||||
|
||||
it "finds a user for a correct system api key with id" do
|
||||
user = Fabricate(:user)
|
||||
ApiKey.create!(key: "hello", created_by_id: -1)
|
||||
expect(provider("/?api_key=hello&api_user_id=#{user.id}").current_user.id).to eq(user.id)
|
||||
end
|
||||
|
||||
context "rate limiting" do
|
||||
before do
|
||||
RateLimiter.enable
|
||||
|
Reference in New Issue
Block a user