Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cb6df34b
Commit
cb6df34b
authored
Nov 29, 2017
by
Yongkun Anfernee Gui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test probe for redirect endpoint
Make sure #18233 works
parent
bb9f27f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
http_test.go
pkg/probe/http/http_test.go
+42
-0
No files found.
pkg/probe/http/http_test.go
View file @
cb6df34b
...
...
@@ -52,6 +52,16 @@ func TestHTTPProbeChecker(t *testing.T) {
w
.
Write
([]
byte
(
output
))
}
redirectHandler
:=
func
(
s
int
,
bad
bool
)
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
r
.
URL
.
Path
==
"/"
{
http
.
Redirect
(
w
,
r
,
"/new"
,
s
)
}
else
if
bad
&&
r
.
URL
.
Path
==
"/new"
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
}
}
}
prober
:=
New
()
testCases
:=
[]
struct
{
handler
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
...
...
@@ -122,6 +132,38 @@ func TestHTTPProbeChecker(t *testing.T) {
},
health
:
probe
.
Failure
,
},
{
handler
:
redirectHandler
(
http
.
StatusMovedPermanently
,
false
),
// 301
health
:
probe
.
Success
,
},
{
handler
:
redirectHandler
(
http
.
StatusMovedPermanently
,
true
),
// 301
health
:
probe
.
Failure
,
},
{
handler
:
redirectHandler
(
http
.
StatusFound
,
false
),
// 302
health
:
probe
.
Success
,
},
{
handler
:
redirectHandler
(
http
.
StatusFound
,
true
),
// 302
health
:
probe
.
Failure
,
},
{
handler
:
redirectHandler
(
http
.
StatusTemporaryRedirect
,
false
),
// 307
health
:
probe
.
Success
,
},
{
handler
:
redirectHandler
(
http
.
StatusTemporaryRedirect
,
true
),
// 307
health
:
probe
.
Failure
,
},
{
handler
:
redirectHandler
(
http
.
StatusPermanentRedirect
,
false
),
// 308
health
:
probe
.
Success
,
},
{
handler
:
redirectHandler
(
http
.
StatusPermanentRedirect
,
true
),
// 308
health
:
probe
.
Failure
,
},
}
for
i
,
test
:=
range
testCases
{
func
()
{
...
...
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