Commit 1d8d249b authored by Pablo Carranza's avatar Pablo Carranza

Change API endpoint to authorized_keys

parent 1c035418
...@@ -25,7 +25,7 @@ module API ...@@ -25,7 +25,7 @@ module API
post "/allowed" do post "/allowed" do
status 200 status 200
actor = actor =
if params[:key_id] if params[:key_id]
Key.find_by(id: params[:key_id]) Key.find_by(id: params[:key_id])
elsif params[:user_id] elsif params[:user_id]
...@@ -33,7 +33,7 @@ module API ...@@ -33,7 +33,7 @@ module API
end end
project_path = params[:project] project_path = params[:project]
# Check for *.wiki repositories. # Check for *.wiki repositories.
# Strip out the .wiki from the pathname before finding the # Strip out the .wiki from the pathname before finding the
# project. This applies the correct project permissions to # project. This applies the correct project permissions to
...@@ -55,7 +55,7 @@ module API ...@@ -55,7 +55,7 @@ module API
# #
# Get a ssh key using the fingerprint # Get a ssh key using the fingerprint
# #
get "/ssh-key" do get "/authorized_keys" do
key = Key.find_by(fingerprint: params[:fingerprint]) key = Key.find_by(fingerprint: params[:fingerprint])
not_found!("Key") if key.nil? not_found!("Key") if key.nil?
present key, with: Entities::SSHKey present key, with: Entities::SSHKey
......
...@@ -48,10 +48,10 @@ describe API::API, api: true do ...@@ -48,10 +48,10 @@ describe API::API, api: true do
end end
end end
describe "GET /internal/ssh-key" do describe "GET /internal/authorized_keys" do
context "existing key" do context "existing key" do
it "finds the key" do it "finds the key" do
get(api('/internal/ssh-key'), fingerprint: key.fingerprint, secret_token: secret_token) get(api('/internal/authorized_keys'), fingerprint: key.fingerprint, secret_token: secret_token)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response["key"]).to eq(key.key) expect(json_response["key"]).to eq(key.key)
...@@ -60,7 +60,7 @@ describe API::API, api: true do ...@@ -60,7 +60,7 @@ describe API::API, api: true do
context "non existing key" do context "non existing key" do
it "returns 404" do it "returns 404" do
get(api('/internal/ssh-key'), fingerprint: "not-valid", secret_token: secret_token) get(api('/internal/authorized_keys'), fingerprint: "not-valid", secret_token: secret_token)
expect(response.status).to eq(404) expect(response.status).to eq(404)
end end
...@@ -68,7 +68,7 @@ describe API::API, api: true do ...@@ -68,7 +68,7 @@ describe API::API, api: true do
context "partial key match" do context "partial key match" do
it "returns 404" do it "returns 404" do
get(api('/internal/ssh-key'), fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token) get(api('/internal/authorized_keys'), fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token)
expect(response.status).to eq(404) expect(response.status).to eq(404)
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