Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
gitlab-shell
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
gitlab-shell
Commits
805bdd0d
Commit
805bdd0d
authored
5 years ago
by
Nick Thomas
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'master'
Print keys in list-keys command See merge request
!198
parents
344cc6b4
a9e6eb77
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!198
Print keys in list-keys command
Pipeline
#59267193
passed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/gitlab_keys.rb
+1
-1
1 addition, 1 deletion
lib/gitlab_keys.rb
spec/gitlab_keys_spec.rb
+12
-8
12 additions, 8 deletions
spec/gitlab_keys_spec.rb
with
13 additions
and
9 deletions
lib/gitlab_keys.rb
+
1
−
1
View file @
805bdd0d
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
spec/gitlab_keys_spec.rb
+
12
−
8
View file @
805bdd0d
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment