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
784221bd
Commit
784221bd
authored
Aug 03, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add permission check tests, improve check
parent
f9a55789
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
lib/gitlab_keys.rb
lib/gitlab_keys.rb
+3
-3
spec/gitlab_keys_spec.rb
spec/gitlab_keys_spec.rb
+20
-1
No files found.
lib/gitlab_keys.rb
View file @
784221bd
...
...
@@ -94,9 +94,9 @@ class GitlabKeys
end
def
check_permissions
open_auth_file
(
'r+'
)
{
return
true
}
rescue
puts
"error: could not open
#{
auth_file
}
"
open_auth_file
(
'r+'
)
{
true
}
rescue
=>
ex
puts
"error: could not open
#{
auth_file
}
:
#{
ex
}
"
if
File
.
exist?
(
auth_file
)
system
(
'ls'
,
'-l'
,
auth_file
)
else
...
...
spec/gitlab_keys_spec.rb
View file @
784221bd
...
...
@@ -15,7 +15,6 @@ describe GitlabKeys do
it
{
gitlab_keys
.
instance_variable_get
(
:@key_id
).
should
==
'key-741'
}
end
describe
:add_key
do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'add-key'
,
'key-741'
,
'ssh-rsa AAAAB3NzaDAxx2E'
)
}
...
...
@@ -145,6 +144,20 @@ describe GitlabKeys do
end
end
describe
:check_permissions
do
let
(
:gitlab_keys
)
{
build_gitlab_keys
(
'check-permissions'
)
}
it
'returns true when the file can be opened'
do
create_authorized_keys_fixture
expect
(
gitlab_keys
.
exec
).
to
eq
(
true
)
end
it
'returns false if opening raises an exception'
do
gitlab_keys
.
should_receive
(
:open_auth_file
).
and_raise
(
"imaginary error"
)
expect
(
gitlab_keys
.
exec
).
to
eq
(
false
)
end
end
describe
:exec
do
it
'add-key arg should execute add_key method'
do
gitlab_keys
=
build_gitlab_keys
(
'add-key'
)
...
...
@@ -170,6 +183,12 @@ describe GitlabKeys do
gitlab_keys
.
exec
end
it
'check-permissions arg should execute check_permissions method'
do
gitlab_keys
=
build_gitlab_keys
(
'check-permissions'
)
gitlab_keys
.
should_receive
(
:check_permissions
)
gitlab_keys
.
exec
end
it
'should puts message if unknown command arg'
do
gitlab_keys
=
build_gitlab_keys
(
'change-key'
)
gitlab_keys
.
should_receive
(
:puts
).
with
(
'not allowed'
)
...
...
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