BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
38020064
Commit
38020064
authored
Mar 11, 2018
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect the protocol in `expose_url`
When https is configured in the URL, also use that, and do not set it to http. Closes gitlab-org/gitlab-ee#5217
parent
4bc58ca2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
1 deletion
+47
-1
tc-api-fix-expose_url.yml
changelogs/unreleased/tc-api-fix-expose_url.yml
+5
-0
related_resources_helpers.rb
lib/api/helpers/related_resources_helpers.rb
+1
-1
related_resources_helpers_spec.rb
spec/lib/api/helpers/related_resources_helpers_spec.rb
+41
-0
No files found.
changelogs/unreleased/tc-api-fix-expose_url.yml
0 → 100644
View file @
38020064
---
title
:
Ensure the API returns https links when https is configured
merge_request
:
17681
author
:
type
:
fixed
lib/api/helpers/related_resources_helpers.rb
View file @
38020064
...
...
@@ -15,7 +15,7 @@ module API
url_options
=
Gitlab
::
Application
.
routes
.
default_url_options
protocol
,
host
,
port
=
url_options
.
slice
(
:protocol
,
:host
,
:port
).
values
URI
::
HTTP
.
build
(
scheme:
protocol
,
host:
host
,
port:
port
,
path:
path
).
to_s
URI
::
Generic
.
build
(
scheme:
protocol
,
host:
host
,
port:
port
,
path:
path
).
to_s
end
private
...
...
spec/lib/api/helpers/related_resources_helpers_spec.rb
0 → 100644
View file @
38020064
require
'spec_helper'
describe
API
::
Helpers
::
RelatedResourcesHelpers
do
subject
(
:helpers
)
do
Class
.
new
.
include
(
described_class
).
new
end
describe
'#expose_url'
do
let
(
:path
)
{
'/api/v4/awesome_endpoint'
}
subject
(
:url
)
{
helpers
.
expose_url
(
path
)
}
def
stub_default_url_options
(
protocol:
'http'
,
host:
'example.com'
,
port:
nil
)
expect
(
Gitlab
::
Application
.
routes
).
to
receive
(
:default_url_options
)
.
and_return
(
protocol:
protocol
,
host:
host
,
port:
port
)
end
it
'respects the protocol if it is HTTP'
do
stub_default_url_options
(
protocol:
'http'
)
is_expected
.
to
start_with
(
'http://'
)
end
it
'respects the protocol if it is HTTPS'
do
stub_default_url_options
(
protocol:
'https'
)
is_expected
.
to
start_with
(
'https://'
)
end
it
'accepts port to be nil'
do
stub_default_url_options
(
port:
nil
)
is_expected
.
to
start_with
(
'http://example.com/'
)
end
it
'includes port if provided'
do
stub_default_url_options
(
port:
8080
)
is_expected
.
to
start_with
(
'http://example.com:8080/'
)
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