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
634482d1
Commit
634482d1
authored
Oct 31, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'puts_instead_of_echo' of /home/git/repositories/gitlab/gitlab-shell
parents
4a76edde
8d680709
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
lib/gitlab_keys.rb
lib/gitlab_keys.rb
+2
-3
spec/gitlab_keys_spec.rb
spec/gitlab_keys_spec.rb
+5
-2
No files found.
lib/gitlab_keys.rb
View file @
634482d1
...
...
@@ -29,9 +29,8 @@ class GitlabKeys
def
add_key
$logger
.
info
"Adding key
#{
@key_id
}
=>
#{
@key
.
inspect
}
"
cmd
=
"command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell
#{
@key_id
}
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
#{
@key
}
"
cmd
=
"echo
\'
#{
cmd
}
\'
>>
#{
auth_file
}
"
system
(
cmd
)
auth_line
=
"command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell
#{
@key_id
}
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
#{
@key
}
"
open
(
auth_file
,
'a'
)
{
|
file
|
file
.
puts
(
auth_line
)
}
end
def
rm_key
...
...
spec/gitlab_keys_spec.rb
View file @
634482d1
...
...
@@ -16,15 +16,18 @@ describe GitlabKeys do
describe
:add_key
do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'add-key'
,
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)
}
let
(
:file
)
{
mock
(
:file
)
}
it
"should receive valid cmd"
do
valid_cmd
=
"echo 'command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell key-741
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E' >>
#{
GitlabConfig
.
new
.
auth_file
}
"
gitlab_keys
.
should_receive
(
:system
).
with
(
valid_cmd
)
auth_line
=
"command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell key-741
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E"
gitlab_keys
.
should_receive
(
:open
).
with
(
GitlabConfig
.
new
.
auth_file
,
'a'
).
and_yield
(
file
)
file
.
should_receive
(
:puts
).
with
(
auth_line
)
gitlab_keys
.
send
:add_key
end
it
"should log an add-key event"
do
$logger
.
should_receive
(
:info
).
with
(
'Adding key key-741 => "ssh-rsa AAAAB3NzaDAxx2E"'
)
gitlab_keys
.
stub
(
:open
)
gitlab_keys
.
send
:add_key
end
end
...
...
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