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
nexedi
gitlab-shell
Commits
a9e6eb77
Commit
a9e6eb77
authored
Mar 16, 2018
by
Christian Ratzenhofer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actually print matched keys in list_keys
parent
344cc6b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
lib/gitlab_keys.rb
lib/gitlab_keys.rb
+1
-1
spec/gitlab_keys_spec.rb
spec/gitlab_keys_spec.rb
+12
-8
No files found.
lib/gitlab_keys.rb
View file @
a9e6eb77
...
...
@@ -99,7 +99,7 @@ class GitlabKeys # rubocop:disable Metrics/ClassLength
matches
=
/^command=\".+?\s+(.+?)\".+?(?:ssh|ecdsa)-.*?\s(.+)\s*.*\n*$/
.
match
(
line
)
keys
<<
"
#{
matches
[
1
]
}
#{
matches
[
2
]
}
\n
"
unless
matches
.
nil?
end
keys
puts
keys
end
def
list_key_ids
...
...
spec/gitlab_keys_spec.rb
View file @
a9e6eb77
...
...
@@ -95,16 +95,20 @@ describe GitlabKeys do
end
end
describe
:list_keys
do
let
(
:gitlab_keys
)
do
build_gitlab_keys
(
'add-key'
,
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)
describe
':list_keys'
do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'list_keys'
)
}
let
(
:key_data
)
{
"%s
\n
%s
\n
"
%
[
described_class
.
key_line
(
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
),
described_class
.
key_line
(
'key-742'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)]
}
let
(
:key_output
)
{
"key-741 AAAAB3NzaDAxx2E
\n
key-742 AAAAB3NzaDAxx2E
\n
"
}
before
do
create_authorized_keys_fixture
(
existing_content:
key_data
)
end
it
'adds a key and lists it'
do
create_authorized_keys_fixture
gitlab_keys
.
send
:add_key
auth_line1
=
'key-741 AAAAB3NzaDAxx2E'
expect
(
gitlab_keys
.
send
(
:list_keys
)).
to
eq
(
"
#{
auth_line1
}
\n
"
)
it
'outputs the keys with IDs, separated by newlines'
do
expect
{
gitlab_keys
.
send
(
:list_keys
)
}.
to
output
(
key_output
).
to_stdout
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