Commit 4dd573b4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve broadcast message API

parent 52c676f2
...@@ -83,7 +83,7 @@ module API ...@@ -83,7 +83,7 @@ module API
end end
def authenticate_by_gitlab_shell_token! def authenticate_by_gitlab_shell_token!
unauthorized! unless secret_token == params['secret_token'] unauthorized! unless secret_token == params['secret_token'].try(:chomp)
end end
def authenticated_as_admin! def authenticated_as_admin!
...@@ -236,7 +236,7 @@ module API ...@@ -236,7 +236,7 @@ module API
end end
def secret_token def secret_token
File.read(Rails.root.join('.gitlab_shell_secret')) File.read(Rails.root.join('.gitlab_shell_secret')).chomp
end end
def handle_member_errors(errors) def handle_member_errors(errors)
......
...@@ -73,6 +73,8 @@ module API ...@@ -73,6 +73,8 @@ module API
get "/broadcast_message" do get "/broadcast_message" do
if message = BroadcastMessage.current if message = BroadcastMessage.current
present message, with: Entities::BroadcastMessage present message, with: Entities::BroadcastMessage
else
{}
end end
end end
end end
......
...@@ -32,7 +32,8 @@ describe API::API, api: true do ...@@ -32,7 +32,8 @@ describe API::API, api: true do
it do it do
get api("/internal/broadcast_message"), secret_token: secret_token get api("/internal/broadcast_message"), secret_token: secret_token
expect(response.status).to eq(404) expect(response.status).to eq(200)
expect(json_response).to be_empty
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment