Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
50c8bd63
Commit
50c8bd63
authored
7 years ago
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate user agent header for GCP Client
parent
e0f84130
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
lib/google_api/cloud_platform/client.rb
lib/google_api/cloud_platform/client.rb
+4
-0
spec/lib/google_api/cloud_platform/client_spec.rb
spec/lib/google_api/cloud_platform/client_spec.rb
+9
-0
No files found.
lib/google_api/cloud_platform/client.rb
View file @
50c8bd63
...
@@ -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
This diff is collapsed.
Click to expand it.
spec/lib/google_api/cloud_platform/client_spec.rb
View file @
50c8bd63
...
@@ -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
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment