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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-shell
Commits
79aed51b
Commit
79aed51b
authored
Mar 11, 2016
by
Pablo Carranza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add encoding for the ssh key on the url
parent
aedf824d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
3 deletions
+5
-3
lib/gitlab_net.rb
lib/gitlab_net.rb
+1
-1
spec/gitlab_net_spec.rb
spec/gitlab_net_spec.rb
+3
-1
spec/vcr_cassettes/ssh-key-ok.yml
spec/vcr_cassettes/ssh-key-ok.yml
+1
-1
No files found.
lib/gitlab_net.rb
View file @
79aed51b
...
@@ -57,7 +57,7 @@ class GitlabNet
...
@@ -57,7 +57,7 @@ class GitlabNet
end
end
def
authorized_key
(
key
)
def
authorized_key
(
key
)
resp
=
get
(
"
#{
host
}
/authorized_keys?key=
#{
key
}
"
)
resp
=
get
(
"
#{
host
}
/authorized_keys?key=
#{
URI
.
escape
(
key
,
'+/='
)
}
"
)
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
"200"
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
"200"
rescue
rescue
nil
nil
...
...
spec/gitlab_net_spec.rb
View file @
79aed51b
...
@@ -77,6 +77,8 @@ describe GitlabNet, vcr: true do
...
@@ -77,6 +77,8 @@ describe GitlabNet, vcr: true do
end
end
describe
:authorized_key
do
describe
:authorized_key
do
let
(
:ssh_key
)
{
"AAAAB3NzaC1yc2EAAAADAQABAAACAQDPKPqqnqQ9PDFw65cO7iHXrKw6ucSZg8Bd2CZ150Yy1YRDPJOWeRNCnddS+M/Lk"
}
it
"should return nil when the resource is not implemented"
do
it
"should return nil when the resource is not implemented"
do
VCR
.
use_cassette
(
"ssh-key-not-implemented"
)
do
VCR
.
use_cassette
(
"ssh-key-not-implemented"
)
do
result
=
gitlab_net
.
authorized_key
(
"whatever"
)
result
=
gitlab_net
.
authorized_key
(
"whatever"
)
...
@@ -93,7 +95,7 @@ describe GitlabNet, vcr: true do
...
@@ -93,7 +95,7 @@ describe GitlabNet, vcr: true do
it
"should return a ssh key with a valid fingerprint"
do
it
"should return a ssh key with a valid fingerprint"
do
VCR
.
use_cassette
(
"ssh-key-ok"
)
do
VCR
.
use_cassette
(
"ssh-key-ok"
)
do
result
=
gitlab_net
.
authorized_key
(
"42:18:16"
)
result
=
gitlab_net
.
authorized_key
(
ssh_key
)
result
.
should
eq
({
result
.
should
eq
({
"created_at"
=>
"2016-03-04T18:27:36.959Z"
,
"created_at"
=>
"2016-03-04T18:27:36.959Z"
,
"id"
=>
2
,
"id"
=>
2
,
...
...
spec/vcr_cassettes/ssh-key-ok.yml
View file @
79aed51b
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
http_interactions
:
http_interactions
:
-
request
:
-
request
:
method
:
get
method
:
get
uri
:
https://dev.gitlab.org/api/v3/internal/authorized_keys?key=
42:18:16
uri
:
https://dev.gitlab.org/api/v3/internal/authorized_keys?key=
AAAAB3NzaC1yc2EAAAADAQABAAACAQDPKPqqnqQ9PDFw65cO7iHXrKw6ucSZg8Bd2CZ150Yy1YRDPJOWeRNCnddS+M/Lk
body
:
body
:
encoding
:
US-ASCII
encoding
:
US-ASCII
string
:
secret_token=a123
string
:
secret_token=a123
...
...
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