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
e14cc772
Commit
e14cc772
authored
Oct 14, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify integration specs
parent
18096b54
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
130 deletions
+32
-130
spec/gitlab_shell_authorized_principals_check_spec.rb
spec/gitlab_shell_authorized_principals_check_spec.rb
+5
-30
spec/gitlab_shell_custom_git_receive_pack_spec.rb
spec/gitlab_shell_custom_git_receive_pack_spec.rb
+9
-29
spec/gitlab_shell_discover_spec.rb
spec/gitlab_shell_discover_spec.rb
+5
-21
spec/gitlab_shell_lfs_authentication_spec.rb
spec/gitlab_shell_lfs_authentication_spec.rb
+6
-25
spec/gitlab_shell_two_factor_recovery_spec.rb
spec/gitlab_shell_two_factor_recovery_spec.rb
+7
-25
No files found.
spec/gitlab_shell_authorized_principals_check_spec.rb
View file @
e14cc772
...
@@ -3,13 +3,17 @@ require_relative 'spec_helper'
...
@@ -3,13 +3,17 @@ require_relative 'spec_helper'
describe
'bin/gitlab-shell-authorized-principals-check'
do
describe
'bin/gitlab-shell-authorized-principals-check'
do
include_context
'gitlab shell'
include_context
'gitlab shell'
before
(
:all
)
do
write_config
({})
end
def
mock_server
(
server
)
def
mock_server
(
server
)
# Do nothing as we're not connecting to a server in this check.
# Do nothing as we're not connecting to a server in this check.
end
end
let
(
:authorized_principals_check_path
)
{
File
.
join
(
tmp_root_path
,
'bin'
,
'gitlab-shell-authorized-principals-check'
)
}
let
(
:authorized_principals_check_path
)
{
File
.
join
(
tmp_root_path
,
'bin'
,
'gitlab-shell-authorized-principals-check'
)
}
shared_examples
'authorized principals check'
do
describe
'authorized principals check'
do
it
'succeeds when a valid principal is given'
do
it
'succeeds when a valid principal is given'
do
output
,
status
=
run!
output
,
status
=
run!
...
@@ -39,35 +43,6 @@ describe 'bin/gitlab-shell-authorized-principals-check' do
...
@@ -39,35 +43,6 @@ describe 'bin/gitlab-shell-authorized-principals-check' do
end
end
end
end
describe
'without go features'
do
before
(
:all
)
do
write_config
({})
end
it_behaves_like
'authorized principals check'
end
describe
'without go features (via go)'
,
:go
do
before
(
:all
)
do
write_config
({})
end
it_behaves_like
'authorized principals check'
end
describe
'with the go authorized-principals-check feature'
,
:go
do
before
(
:all
)
do
write_config
(
'migration'
=>
{
'enabled'
=>
true
,
'features'
=>
[
'authorized-principals-check'
]
}
)
end
it_behaves_like
'authorized principals check'
end
def
run!
(
key_id:
'key'
,
principals:
[
'principal'
])
def
run!
(
key_id:
'key'
,
principals:
[
'principal'
])
cmd
=
[
cmd
=
[
authorized_principals_check_path
,
authorized_principals_check_path
,
...
...
spec/gitlab_shell_custom_git_receive_pack_spec.rb
View file @
e14cc772
...
@@ -7,6 +7,12 @@ require 'base64'
...
@@ -7,6 +7,12 @@ require 'base64'
describe
'Custom bin/gitlab-shell git-receive-pack'
do
describe
'Custom bin/gitlab-shell git-receive-pack'
do
include_context
'gitlab shell'
include_context
'gitlab shell'
let
(
:env
)
{
{
'SSH_CONNECTION'
=>
'fake'
,
'SSH_ORIGINAL_COMMAND'
=>
'git-receive-pack group/repo'
}
}
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
)
end
def
mock_server
(
server
)
def
mock_server
(
server
)
server
.
mount_proc
(
'/geo/proxy_git_push_ssh/info_refs'
)
do
|
req
,
res
|
server
.
mount_proc
(
'/geo/proxy_git_push_ssh/info_refs'
)
do
|
req
,
res
|
res
.
content_type
=
'application/json'
res
.
content_type
=
'application/json'
...
@@ -58,7 +64,9 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
...
@@ -58,7 +64,9 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
end
end
end
end
shared_examples
'dialog for performing a custom action'
do
describe
'dialog for performing a custom action'
do
let
(
:inaccessible_error
)
{
"Internal API error (403)
\n
"
}
context
'when API calls perform successfully'
do
context
'when API calls perform successfully'
do
def
verify_successful_call!
(
cmd
)
def
verify_successful_call!
(
cmd
)
Open3
.
popen3
(
env
,
cmd
)
do
|
stdin
,
stdout
,
stderr
|
Open3
.
popen3
(
env
,
cmd
)
do
|
stdin
,
stdout
,
stderr
|
...
@@ -103,32 +111,4 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
...
@@ -103,32 +111,4 @@ describe 'Custom bin/gitlab-shell git-receive-pack' do
end
end
end
end
end
end
let
(
:env
)
{
{
'SSH_CONNECTION'
=>
'fake'
,
'SSH_ORIGINAL_COMMAND'
=>
'git-receive-pack group/repo'
}
}
describe
'without go features'
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
)
end
it_behaves_like
'dialog for performing a custom action'
do
let
(
:inaccessible_error
)
{
"> GitLab: API is not accessible
\n
"
}
end
end
describe
'with go features'
,
:go
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
"migration"
=>
{
"enabled"
=>
true
,
"features"
=>
[
"git-receive-pack"
]
}
)
end
it_behaves_like
'dialog for performing a custom action'
do
let
(
:inaccessible_error
)
{
"Internal API error (403)
\n
"
}
end
end
end
end
spec/gitlab_shell_
gitlab_shell
_spec.rb
→
spec/gitlab_shell_
discover
_spec.rb
View file @
e14cc772
...
@@ -5,6 +5,10 @@ require 'open3'
...
@@ -5,6 +5,10 @@ require 'open3'
describe
'bin/gitlab-shell'
do
describe
'bin/gitlab-shell'
do
include_context
'gitlab shell'
include_context
'gitlab shell'
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
)
end
def
mock_server
(
server
)
def
mock_server
(
server
)
server
.
mount_proc
(
'/api/v4/internal/discover'
)
do
|
req
,
res
|
server
.
mount_proc
(
'/api/v4/internal/discover'
)
do
|
req
,
res
|
identifier
=
req
.
query
[
'key_id'
]
||
req
.
query
[
'username'
]
||
req
.
query
[
'user_id'
]
identifier
=
req
.
query
[
'key_id'
]
||
req
.
query
[
'username'
]
||
req
.
query
[
'user_id'
]
...
@@ -35,7 +39,7 @@ describe 'bin/gitlab-shell' do
...
@@ -35,7 +39,7 @@ describe 'bin/gitlab-shell' do
Open3
.
capture3
(
env
,
cmd
)
Open3
.
capture3
(
env
,
cmd
)
end
end
shared_examples
'results with keys'
do
describe
'results with keys'
do
# Basic valid input
# Basic valid input
it
'succeeds and prints username when a valid known key id is given'
do
it
'succeeds and prints username when a valid known key id is given'
do
output
,
_
,
status
=
run!
([
"key-100"
])
output
,
_
,
status
=
run!
([
"key-100"
])
...
@@ -102,26 +106,6 @@ describe 'bin/gitlab-shell' do
...
@@ -102,26 +106,6 @@ describe 'bin/gitlab-shell' do
expect
(
output
).
to
eq
(
"Welcome to GitLab, @someuser!
\n
"
)
expect
(
output
).
to
eq
(
"Welcome to GitLab, @someuser!
\n
"
)
expect
(
status
).
to
be_success
expect
(
status
).
to
be_success
end
end
end
describe
'without go features'
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
)
end
it_behaves_like
'results with keys'
end
describe
'with the go discover feature'
,
:go
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
"migration"
=>
{
"enabled"
=>
true
,
"features"
=>
[
"discover"
]
}
)
end
it_behaves_like
'results with keys'
it
'outputs "Only SSH allowed"'
do
it
'outputs "Only SSH allowed"'
do
_
,
stderr
,
status
=
run!
([
"-c/usr/share/webapps/gitlab-shell/bin/gitlab-shell"
,
"username-someuser"
],
env:
{})
_
,
stderr
,
status
=
run!
([
"-c/usr/share/webapps/gitlab-shell/bin/gitlab-shell"
,
"username-someuser"
],
env:
{})
...
...
spec/gitlab_shell_lfs_authentication_spec.rb
View file @
e14cc772
...
@@ -6,6 +6,11 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
...
@@ -6,6 +6,11 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
include_context
'gitlab shell'
include_context
'gitlab shell'
let
(
:path
)
{
"https://gitlab.com/repo/path"
}
let
(
:path
)
{
"https://gitlab.com/repo/path"
}
let
(
:env
)
{
{
'SSH_CONNECTION'
=>
'fake'
,
'SSH_ORIGINAL_COMMAND'
=>
'git-lfs-authenticate project/repo download'
}
}
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
)
end
def
mock_server
(
server
)
def
mock_server
(
server
)
server
.
mount_proc
(
'/api/v4/internal/lfs_authenticate'
)
do
|
req
,
res
|
server
.
mount_proc
(
'/api/v4/internal/lfs_authenticate'
)
do
|
req
,
res
|
...
@@ -49,7 +54,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
...
@@ -49,7 +54,7 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
end
end
end
end
shared_examples
'lfs authentication command'
do
describe
'lfs authentication command'
do
def
successful_response
def
successful_response
{
{
"header"
=>
{
"header"
=>
{
...
@@ -119,28 +124,4 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
...
@@ -119,28 +124,4 @@ describe 'bin/gitlab-shell git-lfs-authentication' do
end
end
end
end
end
end
let
(
:env
)
{
{
'SSH_CONNECTION'
=>
'fake'
,
'SSH_ORIGINAL_COMMAND'
=>
'git-lfs-authenticate project/repo download'
}
}
describe
'without go features'
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
)
end
it_behaves_like
'lfs authentication command'
end
describe
'with go features'
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
"migration"
=>
{
"enabled"
=>
true
,
"features"
=>
[
"git-lfs-authenticate"
]
}
)
end
it_behaves_like
'lfs authentication command'
end
end
end
spec/gitlab_shell_two_factor_recovery_spec.rb
View file @
e14cc772
...
@@ -5,6 +5,12 @@ require 'open3'
...
@@ -5,6 +5,12 @@ require 'open3'
describe
'bin/gitlab-shell 2fa_recovery_codes'
do
describe
'bin/gitlab-shell 2fa_recovery_codes'
do
include_context
'gitlab shell'
include_context
'gitlab shell'
let
(
:env
)
{
{
'SSH_CONNECTION'
=>
'fake'
,
'SSH_ORIGINAL_COMMAND'
=>
'2fa_recovery_codes'
}
}
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
)
end
def
mock_server
(
server
)
def
mock_server
(
server
)
server
.
mount_proc
(
'/api/v4/internal/two_factor_recovery_codes'
)
do
|
req
,
res
|
server
.
mount_proc
(
'/api/v4/internal/two_factor_recovery_codes'
)
do
|
req
,
res
|
res
.
content_type
=
'application/json'
res
.
content_type
=
'application/json'
...
@@ -31,7 +37,7 @@ describe 'bin/gitlab-shell 2fa_recovery_codes' do
...
@@ -31,7 +37,7 @@ describe 'bin/gitlab-shell 2fa_recovery_codes' do
end
end
end
end
shared_examples
'dialog for regenerating recovery keys'
do
describe
'dialog for regenerating recovery keys'
do
context
'when the user agrees to regenerate keys'
do
context
'when the user agrees to regenerate keys'
do
def
verify_successful_regeneration!
(
cmd
)
def
verify_successful_regeneration!
(
cmd
)
Open3
.
popen2
(
env
,
cmd
)
do
|
stdin
,
stdout
|
Open3
.
popen2
(
env
,
cmd
)
do
|
stdin
,
stdout
|
...
@@ -101,28 +107,4 @@ describe 'bin/gitlab-shell 2fa_recovery_codes' do
...
@@ -101,28 +107,4 @@ describe 'bin/gitlab-shell 2fa_recovery_codes' do
end
end
end
end
end
end
let
(
:env
)
{
{
'SSH_CONNECTION'
=>
'fake'
,
'SSH_ORIGINAL_COMMAND'
=>
'2fa_recovery_codes'
}
}
describe
'without go features'
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
)
end
it_behaves_like
'dialog for regenerating recovery keys'
end
describe
'with go features'
,
:go
do
before
(
:context
)
do
write_config
(
"gitlab_url"
=>
"http+unix://
#{
CGI
.
escape
(
tmp_socket_path
)
}
"
,
"migration"
=>
{
"enabled"
=>
true
,
"features"
=>
[
"2fa_recovery_codes"
]
}
)
end
it_behaves_like
'dialog for regenerating recovery keys'
end
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