Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openfaas-faas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Team Jaz CS 598 CCC Final Project
openfaas-faas
Commits
3e0ed5ed
Commit
3e0ed5ed
authored
6 years ago
by
Stefan Prodan
Committed by
Alex Ellis
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add X-Forwarded-Host test when already present
Signed-off-by:
Stefan Prodan
<
stefan.prodan@gmail.com
>
parent
3d44fa81
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gateway/handlers/forwarding_proxy.go
+0
-2
0 additions, 2 deletions
gateway/handlers/forwarding_proxy.go
gateway/handlers/forwarding_proxy_test.go
+18
-0
18 additions, 0 deletions
gateway/handlers/forwarding_proxy_test.go
with
18 additions
and
2 deletions
gateway/handlers/forwarding_proxy.go
+
0
−
2
View file @
3e0ed5ed
...
...
@@ -103,8 +103,6 @@ func forwardRequest(w http.ResponseWriter, r *http.Request, proxyClient *http.Cl
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
log
.
Printf
(
"Upstream request to: %s, %+v
\n
"
,
upstreamReq
.
URL
.
Path
,
upstreamReq
)
res
,
resErr
:=
proxyClient
.
Do
(
upstreamReq
.
WithContext
(
ctx
))
if
resErr
!=
nil
{
badStatus
:=
http
.
StatusBadGateway
...
...
This diff is collapsed.
Click to expand it.
gateway/handlers/forwarding_proxy_test.go
+
18
−
0
View file @
3e0ed5ed
...
...
@@ -106,6 +106,24 @@ func Test_buildUpstreamRequest_XForwardedHostHeader_Empty_WhenNotSet(t *testing.
}
}
func
Test_buildUpstreamRequest_XForwardedHostHeader_WhenAlreadyPresent
(
t
*
testing
.
T
)
{
srcBytes
:=
[]
byte
(
"hello world"
)
headerValue
:=
"test.openfaas.com"
reader
:=
bytes
.
NewReader
(
srcBytes
)
request
,
err
:=
http
.
NewRequest
(
http
.
MethodPost
,
"/function/test"
,
reader
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
request
.
Header
.
Set
(
"X-Forwarded-Host"
,
headerValue
)
upstream
:=
buildUpstreamRequest
(
request
,
"/"
,
"/"
)
if
upstream
.
Header
.
Get
(
"X-Forwarded-Host"
)
!=
headerValue
{
t
.
Errorf
(
"X-Forwarded-Host - want: %s, got: %s"
,
headerValue
,
upstream
.
Header
.
Get
(
"X-Forwarded-Host"
))
}
}
func
Test_getServiceName
(
t
*
testing
.
T
)
{
scenarios
:=
[]
struct
{
name
string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment