Generate user agent header for GCP Client
This commit is contained in:
parent
e0f8413056
commit
50c8bd6350
|
@ -82,6 +82,10 @@ module GoogleApi
|
|||
def token_life_time(expires_at)
|
||||
DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc
|
||||
end
|
||||
|
||||
def user_agent_header
|
||||
{ 'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)" }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -125,4 +125,13 @@ describe GoogleApi::CloudPlatform::Client do
|
|||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#user_agent_header' do
|
||||
subject { client.instance_eval { user_agent_header } }
|
||||
|
||||
it 'returns the correct major and minor GitLab version ' do
|
||||
stub_const('Gitlab::VERSION', '10.3.0-pre')
|
||||
expect(subject).to eq({ 'User-Agent': 'GitLab/10.3 (GPN:GitLab;)' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue