Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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-ce
Commits
6fcc65b5
Commit
6fcc65b5
authored
Mar 21, 2019
by
Patrick Bajao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Gitlab::AuthorizedKeys specs to be clearer
parent
983dcba3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
4 deletions
+40
-4
spec/lib/gitlab/authorized_keys_spec.rb
spec/lib/gitlab/authorized_keys_spec.rb
+40
-4
No files found.
spec/lib/gitlab/authorized_keys_spec.rb
View file @
6fcc65b5
...
...
@@ -7,16 +7,16 @@ describe Gitlab::AuthorizedKeys do
subject
{
described_class
.
new
(
logger
)
}
after
do
delete_authorized_keys_file
end
describe
'#add_key'
do
context
'authorized_keys file exists'
do
before
do
create_authorized_keys_fixture
end
after
do
delete_authorized_keys_file
end
it
"adds a line at the end of the file and strips trailing garbage"
do
auth_line
=
"command=
\"
#{
Gitlab
.
config
.
gitlab_shell
.
path
}
/bin/gitlab-shell key-741
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaDAxx2E"
...
...
@@ -28,6 +28,10 @@ describe Gitlab::AuthorizedKeys do
end
context
'authorized_keys file does not exist'
do
before
do
delete_authorized_keys_file
end
it
'creates the file'
do
expect
(
subject
.
add_key
(
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)).
to
be_truthy
expect
(
File
.
exist?
(
tmp_authorized_keys_path
)).
to
be_truthy
...
...
@@ -48,6 +52,10 @@ describe Gitlab::AuthorizedKeys do
create_authorized_keys_fixture
end
after
do
delete_authorized_keys_file
end
it
"adds lines at the end of the file"
do
auth_line1
=
"command=
\"
#{
Gitlab
.
config
.
gitlab_shell
.
path
}
/bin/gitlab-shell key-12
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-dsa ASDFASGADG"
auth_line2
=
"command=
\"
#{
Gitlab
.
config
.
gitlab_shell
.
path
}
/bin/gitlab-shell key-123
\"
,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa GFDGDFSGSDFG"
...
...
@@ -69,6 +77,10 @@ describe Gitlab::AuthorizedKeys do
end
context
'authorized_keys file does not exist'
do
before
do
delete_authorized_keys_file
end
it
'creates the file'
do
expect
(
subject
.
batch_add_keys
(
keys
)).
to
be_truthy
expect
(
File
.
exist?
(
tmp_authorized_keys_path
)).
to
be_truthy
...
...
@@ -82,6 +94,10 @@ describe Gitlab::AuthorizedKeys do
create_authorized_keys_fixture
end
after
do
delete_authorized_keys_file
end
it
"removes the right line"
do
other_line
=
"command=
\"
#{
Gitlab
.
config
.
gitlab_shell
.
path
}
/bin/gitlab-shell key-742
\"
,options ssh-rsa AAAAB3NzaDAxx2E"
delete_line
=
"command=
\"
#{
Gitlab
.
config
.
gitlab_shell
.
path
}
/bin/gitlab-shell key-741
\"
,options ssh-rsa AAAAB3NzaDAxx2E"
...
...
@@ -98,6 +114,10 @@ describe Gitlab::AuthorizedKeys do
end
context
'authorized_keys file does not exist'
do
before
do
delete_authorized_keys_file
end
it
'returns false'
do
expect
(
subject
.
rm_key
(
'key-741'
)).
to
be_falsey
end
...
...
@@ -110,12 +130,20 @@ describe Gitlab::AuthorizedKeys do
create_authorized_keys_fixture
end
after
do
delete_authorized_keys_file
end
it
"returns true"
do
expect
(
subject
.
clear
).
to
be_truthy
end
end
context
'authorized_keys file does not exist'
do
before
do
delete_authorized_keys_file
end
it
"still returns true"
do
expect
(
subject
.
clear
).
to
be_truthy
end
...
...
@@ -131,12 +159,20 @@ describe Gitlab::AuthorizedKeys do
)
end
after
do
delete_authorized_keys_file
end
it
'returns array of key IDs'
do
expect
(
subject
.
list_key_ids
).
to
eq
([
1
,
2
,
3
,
9000
])
end
end
context
'authorized_keys file does not exist'
do
before
do
delete_authorized_keys_file
end
it
'returns an empty array'
do
expect
(
subject
.
list_key_ids
).
to
be_empty
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