Commit ebecb844 authored by Stan Hu's avatar Stan Hu

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

This is needed to support #2959: gitlab-shell or Gitaly will need
to know whether the request is coming from a GeoNode, in which
case we will have some way of disabling the `transfer.hideRefs`
git command in order to mirror all the refs on the primary.
parent b6326824
......@@ -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