Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
9f1543f8
Commit
9f1543f8
authored
Feb 18, 2017
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration: Add https redirect tests
parent
a7c780a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
4 deletions
+94
-4
integration-tests/nghttpx_http1_test.go
integration-tests/nghttpx_http1_test.go
+43
-0
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+43
-0
integration-tests/server_tester.go
integration-tests/server_tester.go
+8
-4
No files found.
integration-tests/nghttpx_http1_test.go
View file @
9f1543f8
...
...
@@ -533,6 +533,49 @@ func TestH1H1RespPhaseReturn(t *testing.T) {
}
}
// TestH1H1HTTPSRedirect tests that the request to the backend which
// requires TLS is redirected to https URI.
func
TestH1H1HTTPSRedirect
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--redirect-if-not-tls"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH1H1HTTPSRedirect"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
308
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
res
.
header
.
Get
(
"location"
),
"https://127.0.0.1/"
;
got
!=
want
{
t
.
Errorf
(
"location: %v; want %v"
,
got
,
want
)
}
}
// TestH1H1HTTPSRedirectPort tests that the request to the backend
// which requires TLS is redirected to https URI with given port.
func
TestH1H1HTTPSRedirectPort
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--redirect-if-not-tls"
,
"--redirect-https-port=8443"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
path
:
"/foo?bar"
,
name
:
"TestH1H1HTTPSRedirectPort"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
308
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
res
.
header
.
Get
(
"location"
),
"https://127.0.0.1:8443/foo?bar"
;
got
!=
want
{
t
.
Errorf
(
"location: %v; want %v"
,
got
,
want
)
}
}
// // TestH1H2ConnectFailure tests that server handles the situation that
// // connection attempt to HTTP/2 backend failed.
// func TestH1H2ConnectFailure(t *testing.T) {
...
...
integration-tests/nghttpx_http2_test.go
View file @
9f1543f8
...
...
@@ -1405,6 +1405,49 @@ func TestH2H1DNS(t *testing.T) {
}
}
// TestH2H1HTTPSRedirect tests that the request to the backend which
// requires TLS is redirected to https URI.
func
TestH2H1HTTPSRedirect
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--redirect-if-not-tls"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1HTTPSRedirect"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
308
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
res
.
header
.
Get
(
"location"
),
"https://127.0.0.1/"
;
got
!=
want
{
t
.
Errorf
(
"location: %v; want %v"
,
got
,
want
)
}
}
// TestH2H1HTTPSRedirectPort tests that the request to the backend
// which requires TLS is redirected to https URI with given port.
func
TestH2H1HTTPSRedirectPort
(
t
*
testing
.
T
)
{
st
:=
newServerTester
([]
string
{
"--redirect-if-not-tls"
,
"--redirect-https-port=8443"
},
t
,
noopHandler
)
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
path
:
"/foo?bar"
,
name
:
"TestH2H1HTTPSRedirectPort"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
308
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
if
got
,
want
:=
res
.
header
.
Get
(
"location"
),
"https://127.0.0.1:8443/foo?bar"
;
got
!=
want
{
t
.
Errorf
(
"location: %v; want %v"
,
got
,
want
)
}
}
// TestH2H1GracefulShutdown tests graceful shutdown.
func
TestH2H1GracefulShutdown
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
...
...
integration-tests/server_tester.go
View file @
9f1543f8
...
...
@@ -101,10 +101,8 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
args
:=
[]
string
{}
backendTLS
:=
false
dns
:=
false
externalDNS
:=
false
acceptProxyProtocol
:=
false
var
backendTLS
,
dns
,
externalDNS
,
acceptProxyProtocol
,
redirectIfNotTLS
bool
for
_
,
k
:=
range
src_args
{
switch
k
{
case
"--http2-bridge"
:
...
...
@@ -116,6 +114,8 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
externalDNS
=
true
case
"--accept-proxy-protocol"
:
acceptProxyProtocol
=
true
case
"--redirect-if-not-tls"
:
redirectIfNotTLS
=
true
default
:
args
=
append
(
args
,
k
)
}
...
...
@@ -164,6 +164,10 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
b
+=
";dns"
}
if
redirectIfNotTLS
{
b
+=
";redirect-if-not-tls"
}
noTLS
:=
";no-tls"
if
frontendTLS
{
noTLS
=
""
...
...
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