Commit 50c8bd63 authored by Matija Čupić's avatar Matija Čupić

Generate user agent header for GCP Client

parent e0f84130
...@@ -82,6 +82,10 @@ module GoogleApi ...@@ -82,6 +82,10 @@ module GoogleApi
def token_life_time(expires_at) def token_life_time(expires_at)
DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc
end end
def user_agent_header
{ 'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)" }
end
end end
end end
end end
...@@ -125,4 +125,13 @@ describe GoogleApi::CloudPlatform::Client do ...@@ -125,4 +125,13 @@ describe GoogleApi::CloudPlatform::Client do
it { is_expected.to be_nil } it { is_expected.to be_nil }
end end
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 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