Commit 09bc223a authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-add-geo-node-api-internal' into 'master'

Include whether the actor is a GeoNode in the `/internal/allowed` endpoint

See merge request !2489
parents 80334707 ebecb844
......@@ -48,7 +48,8 @@ module API
status: true,
gl_repository: gl_repository,
repository_path: repository_path,
gitaly: gitaly_payload(params[:action])
gitaly: gitaly_payload(params[:action]),
geo_node: actor.is_a?(GeoNodeKey)
}
end
......
require 'spec_helper'
describe API::Internal do # rubocop:disable RSpec/FilePath
let(:project) { create(:project, :repository) }
let(:secret_token) { Gitlab::Shell.secret_token }
describe "POST /internal/allowed", :clean_gitlab_redis_shared_state do
context 'Geo Node' do
let(:geo_node) { create(:geo_node) }
it 'recognizes the Geo Node' do
post(
api("/internal/allowed"),
key_id: geo_node.geo_node_key.id,
project: project.repository.path_to_repo,
action: 'git-upload-pack',
secret_token: secret_token,
protocol: 'ssh')
expect(response.status).to eq(200)
expect(json_response['geo_node']).to be(true)
end
end
context 'user' do
let(:user) { create(:user) }
let(:key) { create(:key, user: user) }
before do
project.team << [user, :developer]
end
it 'does not recognize key as a Geo Node' do
post(
api("/internal/allowed"),
key_id: key.id,
project: project.repository.path_to_repo,
action: 'git-upload-pack',
secret_token: secret_token,
protocol: 'ssh')
expect(response.status).to eq(200)
expect(json_response['geo_node']).to be(false)
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