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
0c891977
Commit
0c891977
authored
Mar 19, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken master for ee/spec/migrations/update_authorized_keys_file_spec.rb
parent
df8c9ac3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
ee/spec/migrations/update_authorized_keys_file_spec.rb
ee/spec/migrations/update_authorized_keys_file_spec.rb
+21
-11
No files found.
ee/spec/migrations/update_authorized_keys_file_spec.rb
View file @
0c891977
...
...
@@ -3,6 +3,7 @@ require Rails.root.join('ee', 'db', 'migrate', '20170626202753_update_authorized
describe
UpdateAuthorizedKeysFile
,
:migration
do
let
(
:migration
)
{
described_class
.
new
}
let
(
:authorized_keys_file
)
{
Rails
.
root
.
join
(
Gitlab
.
config
.
gitlab_shell
.
authorized_keys_file
)
}
describe
'#up'
do
context
'when authorized_keys_enabled is nil'
do
...
...
@@ -15,6 +16,8 @@ describe UpdateAuthorizedKeysFile, :migration do
end
it
'sets authorized_keys_enabled to true'
do
FileUtils
.
touch
(
authorized_keys_file
)
migration
.
up
expect
(
described_class
::
ApplicationSetting
.
last
.
authorized_keys_enabled
).
to
be_truthy
...
...
@@ -39,13 +42,14 @@ describe UpdateAuthorizedKeysFile, :migration do
migration
.
up
file
=
File
.
read
(
Rails
.
root
.
join
(
'tmp/tests/.ssh/authorized_keys'
))
file
=
File
.
read
(
authorized_keys_file
)
expect
(
file
.
scan
(
/ssh-rsa/
).
count
).
to
eq
(
2
)
expect
(
file
).
not_to
include
(
Gitlab
::
Shell
.
strip_key
(
@keys
[
0
].
key
))
expect
(
file
).
not_to
include
(
Gitlab
::
Shell
.
strip_key
(
@keys
[
1
].
key
))
expect
(
file
).
to
include
(
Gitlab
::
Shell
.
strip_key
(
@keys
[
2
].
key
))
expect
(
file
).
to
include
(
Gitlab
::
Shell
.
strip_key
(
@keys
[
3
].
key
))
expect
(
file
).
not_to
include
(
strip_key
(
@keys
[
0
].
key
))
expect
(
file
).
not_to
include
(
strip_key
(
@keys
[
1
].
key
))
expect
(
file
).
to
include
(
strip_key
(
@keys
[
2
].
key
))
expect
(
file
).
to
include
(
strip_key
(
@keys
[
3
].
key
))
end
end
...
...
@@ -57,18 +61,24 @@ describe UpdateAuthorizedKeysFile, :migration do
end
it
'deletes the SSH key from authorized_keys'
do
file
=
File
.
read
(
Rails
.
root
.
join
(
'tmp/tests/.ssh/authorized_keys'
))
expect
(
file
).
to
include
(
Gitlab
::
Shell
.
strip_key
(
@key_to_stay
.
key
))
expect
(
file
).
to
include
(
Gitlab
::
Shell
.
strip_key
(
@key_to_delete
.
key
))
file
=
File
.
read
(
authorized_keys_file
)
expect
(
file
).
to
include
(
strip_key
(
@key_to_stay
.
key
))
expect
(
file
).
to
include
(
strip_key
(
@key_to_delete
.
key
))
migration
.
up
file
=
File
.
read
(
Rails
.
root
.
join
(
'tmp/tests/.ssh/authorized_keys'
))
expect
(
file
).
to
include
(
Gitlab
::
Shell
.
strip_key
(
@key_to_stay
.
key
))
expect
(
file
).
not_to
include
(
Gitlab
::
Shell
.
strip_key
(
@key_to_delete
.
key
))
file
=
File
.
read
(
authorized_keys_file
)
expect
(
file
).
to
include
(
strip_key
(
@key_to_stay
.
key
))
expect
(
file
).
not_to
include
(
strip_key
(
@key_to_delete
.
key
))
end
end
end
def
strip_key
(
key
)
key
.
split
(
/[ ]+/
)[
0
,
2
].
join
(
' '
)
end
end
describe
'#authorized_keys_file_in_use_and_stale?'
do
...
...
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