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
Kazuhiko Shiozaki
gitlab-shell
Commits
c67395e9
Commit
c67395e9
authored
Nov 20, 2013
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor file writing tests
parent
9e00fb40
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
33 deletions
+34
-33
spec/gitlab_keys_spec.rb
spec/gitlab_keys_spec.rb
+34
-33
No files found.
spec/gitlab_keys_spec.rb
View file @
c67395e9
...
...
@@ -14,17 +14,12 @@ describe GitlabKeys do
it
{
gitlab_keys
.
instance_variable_get
(
:@key_id
).
should
==
'key-741'
}
end
context
"file writing tests"
do
before
do
FileUtils
.
mkdir_p
(
File
.
dirname
(
tmp_authorized_keys_path
))
open
(
tmp_authorized_keys_path
,
'w'
)
{
|
file
|
file
.
puts
(
'existing content'
)
}
gitlab_keys
.
stub
(
auth_file:
tmp_authorized_keys_path
)
end
describe
:add_key
do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'add-key'
,
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)
}
it
"adds a line at the end of the file"
do
create_authorized_keys_fixture
gitlab_keys
.
send
:add_key
auth_line
=
"command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell key-741
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E"
File
.
read
(
tmp_authorized_keys_path
).
should
==
"existing content
\n
#{
auth_line
}
\n
"
...
...
@@ -41,6 +36,7 @@ describe GitlabKeys do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'rm-key'
,
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)
}
it
"removes the right line"
do
create_authorized_keys_fixture
other_line
=
"command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell key-742
\"
,options ssh-rsa AAAAB3NzaDAxx2E"
open
(
tmp_authorized_keys_path
,
'a'
)
do
|
auth_file
|
auth_file
.
puts
"command=
\"
#{
ROOT_PATH
}
/bin/gitlab-shell key-741
\"
,options ssh-rsa AAAAB3NzaDAxx2E"
...
...
@@ -55,7 +51,6 @@ describe GitlabKeys do
gitlab_keys
.
send
:rm_key
end
end
end
describe
:exec
do
it
'add-key arg should execute add_key method'
do
...
...
@@ -95,6 +90,12 @@ describe GitlabKeys do
end
end
def
create_authorized_keys_fixture
FileUtils
.
mkdir_p
(
File
.
dirname
(
tmp_authorized_keys_path
))
open
(
tmp_authorized_keys_path
,
'w'
)
{
|
file
|
file
.
puts
(
'existing content'
)
}
gitlab_keys
.
stub
(
auth_file:
tmp_authorized_keys_path
)
end
def
tmp_authorized_keys_path
File
.
join
(
ROOT_PATH
,
'tmp'
,
'authorized_keys'
)
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