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
f13afa2d
Commit
f13afa2d
authored
Jul 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'avoid_sed_i' of /home/git/repositories/gitlab/gitlab-shell
parents
f31c38e8
4de0ee3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
lib/gitlab_keys.rb
lib/gitlab_keys.rb
+5
-3
spec/gitlab_keys_spec.rb
spec/gitlab_keys_spec.rb
+4
-1
No files found.
lib/gitlab_keys.rb
View file @
f13afa2d
require
'
open3
'
require
'
tempfile
'
require_relative
'gitlab_config'
require_relative
'gitlab_logger'
...
...
@@ -36,8 +36,10 @@ class GitlabKeys
def
rm_key
$logger
.
info
"Removing key
#{
@key_id
}
"
cmd
=
"sed -i '/shell
#{
@key_id
}
\"
/d'
#{
auth_file
}
"
system
(
cmd
)
Tempfile
.
open
(
'authorized_keys'
)
do
|
temp
|
cmd
=
"sed '/shell
#{
@key_id
}
\"
/d'
#{
auth_file
}
>
#{
temp
.
path
}
&& mv
#{
temp
.
path
}
#{
auth_file
}
"
system
(
cmd
)
end
end
def
clear
...
...
spec/gitlab_keys_spec.rb
View file @
f13afa2d
...
...
@@ -31,9 +31,12 @@ describe GitlabKeys do
describe
:rm_key
do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'rm-key'
,
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)
}
let
(
:temp_file
)
{
mock
(
:temp_file
,
path:
'tmp_path'
)
}
before
{
Tempfile
.
should_receive
(
:open
).
and_yield
(
temp_file
)
}
it
"should receive valid cmd"
do
valid_cmd
=
"sed -i '/shell key-741
\"
/d'
#{
GitlabConfig
.
new
.
auth_file
}
"
auth_file
=
GitlabConfig
.
new
.
auth_file
valid_cmd
=
"sed '/shell key-741
\"
/d'
#{
auth_file
}
> tmp_path && mv tmp_path
#{
auth_file
}
"
gitlab_keys
.
should_receive
(
:system
).
with
(
valid_cmd
)
gitlab_keys
.
send
:rm_key
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