Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
0
Merge Requests
0
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-shell
Commits
5709ea1a
Commit
5709ea1a
authored
Aug 01, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GitlatNet#discover only parse JSON if a 200
parent
3f421a01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
lib/gitlab_net.rb
lib/gitlab_net.rb
+1
-1
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+7
-1
spec/vcr_cassettes/discover-not-found.yml
spec/vcr_cassettes/discover-not-found.yml
+46
-0
No files found.
lib/gitlab_net.rb
View file @
5709ea1a
...
...
@@ -35,7 +35,7 @@ class GitlabNet
def
discover
(
actor
)
resp
=
get
(
"
#{
internal_api_endpoint
}
/discover?
#{
actor
.
identifier_key
}
=
#{
actor
.
id
}
"
)
JSON
.
parse
(
resp
.
body
)
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
HTTP_SUCCESS
rescue
JSON
::
ParserError
,
ApiUnreachableError
nil
end
...
...
spec/gitlab_net_spec.rb
View file @
5709ea1a
...
...
@@ -42,7 +42,7 @@ describe GitlabNet, vcr: true do
end
describe
'#discover'
do
it
'
should return
user has based on key id'
do
it
'
returns
user has based on key id'
do
VCR
.
use_cassette
(
"discover-ok"
)
do
user
=
gitlab_net
.
discover
(
actor1
)
expect
(
user
[
'name'
]).
to
eql
'Administrator'
...
...
@@ -50,6 +50,12 @@ describe GitlabNet, vcr: true do
end
end
it
'returns nil if the user cannot be found'
do
VCR
.
use_cassette
(
"discover-not-found"
)
do
expect
(
gitlab_net
.
discover
(
actor1
)).
to
be_nil
end
end
it
'adds the secret_token to request'
do
VCR
.
use_cassette
(
"discover-ok"
)
do
allow_any_instance_of
(
Net
::
HTTP
::
Get
).
to
receive
(
:set_form_data
).
with
(
hash_including
(
secret_token:
secret
))
...
...
spec/vcr_cassettes/discover-not-found.yml
0 → 100644
View file @
5709ea1a
---
http_interactions
:
-
request
:
method
:
get
uri
:
http://localhost:3000/api/v4/internal/discover?key_id=1
body
:
encoding
:
US-ASCII
string
:
secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
headers
:
Accept-Encoding
:
-
gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept
:
-
"
*/*"
User-Agent
:
-
Ruby
Content-Type
:
-
application/x-www-form-urlencoded
response
:
status
:
code
:
404
message
:
Not Found
headers
:
Cache-Control
:
-
max-age=0, private, must-revalidate
Content-Length
:
-
'
42'
Content-Type
:
-
application/json
Date
:
-
Wed, 21 Jun 2017 10:44:49 GMT
Etag
:
-
W/"63b4ab301951bea83c4fc398eba8e307"
Vary
:
-
Origin
X-Frame-Options
:
-
SAMEORIGIN
X-Request-Id
:
-
dc11b8d4-1972-417b-8305-2c35c849405c
X-Runtime
:
-
'
0.230170'
body
:
encoding
:
UTF-8
string
:
'
{"message":"404
Not
found"}'
http_version
:
recorded_at
:
Wed, 21 Jun 2017 10:44:49 GMT
recorded_with
:
VCR 2.4.0
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