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
aad5cbcb
Commit
aad5cbcb
authored
Mar 12, 2021
by
Mark Lapierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use HTTPS port for SSH
parent
5b4100cc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
qa/qa/support/ssh.rb
qa/qa/support/ssh.rb
+12
-2
qa/spec/support/ssh_spec.rb
qa/spec/support/ssh_spec.rb
+22
-0
No files found.
qa/qa/support/ssh.rb
View file @
aad5cbcb
...
...
@@ -51,11 +51,21 @@ module QA
private
def
uri_port
u
ri
.
port
&&
(
uri
.
port
!=
80
)
?
uri
.
port
:
nil
u
se_typical_params?
?
nil
:
uri
.
port
end
def
git_user
QA
::
Runtime
::
Env
.
running_in_ci?
||
[
443
,
80
].
include?
(
uri
.
port
)
?
'git'
:
Etc
.
getlogin
QA
::
Runtime
::
Env
.
running_in_ci?
||
use_typical_params?
?
'git'
:
Etc
.
getlogin
end
# Checks if typical parameters should be used. That means the SSH port will not be
# needed because it's port 22, and the git user is named 'git'. We assume that
# typical parameters should be used if the host URI includes a typical HTTP(S)
# port (80 or 443)
#
# @return [Boolean] whether typical SSH port and git user parameters should be used
def
use_typical_params?
[
443
,
80
].
include?
(
uri
.
port
)
end
end
end
...
...
qa/spec/support/ssh_spec.rb
View file @
aad5cbcb
...
...
@@ -26,6 +26,16 @@ RSpec.describe QA::Support::SSH do
end
end
context
'when no port specified in https uri'
do
let
(
:uri
)
{
'https://foo.com'
}
it
'does not provide port in ssh command'
do
expect
(
ssh
).
to
receive
(
:run
).
with
(
expected_ssh_command_no_port
,
any_args
).
and_return
(
result
)
call_method
end
end
context
'when port 80 specified in uri'
do
let
(
:uri
)
{
'http://foo.com:80'
}
...
...
@@ -86,6 +96,18 @@ RSpec.describe QA::Support::SSH do
end
end
context
'when running on a review app in CI'
do
let
(
:uri
)
{
'https://gitlab-review.app'
}
before
do
allow
(
QA
::
Runtime
::
Env
).
to
receive
(
:running_in_ci?
).
and_return
(
true
)
end
it
'returns git user'
do
expect
(
ssh
.
send
(
:git_user
)).
to
eq
(
'git'
)
end
end
context
'when running against environment on a port other than 80 or 443'
do
let
(
:uri
)
{
'http://localhost:3000'
}
...
...
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