Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
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
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
caddy
Commits
61a6b951
Commit
61a6b951
authored
Oct 01, 2015
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commenting on the need for additional redirect tests
parent
3f9f675c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
middleware/redirect/redirect_test.go
middleware/redirect/redirect_test.go
+11
-0
No files found.
middleware/redirect/redirect_test.go
View file @
61a6b951
...
...
@@ -26,6 +26,12 @@ func TestRedirect(t *testing.T) {
{
"http://localhost/asdf?foo=bar"
,
""
,
http
.
StatusOK
},
{
"http://localhost/foo#bar"
,
""
,
http
.
StatusOK
},
{
"http://localhost/a#foo"
,
"/b"
,
http
.
StatusTemporaryRedirect
},
// The scheme checks that were added to this package don't actually
// help with redirects because of Caddy's design: a redirect middleware
// for http will always be different than the redirect middleware for
// https because they have to be on different listeners. These tests
// just go to show extra bulletproofing, I guess.
{
"http://localhost/scheme"
,
"https://localhost/scheme"
,
http
.
StatusMovedPermanently
},
{
"https://localhost/scheme"
,
""
,
http
.
StatusOK
},
{
"https://localhost/scheme2"
,
"http://localhost/scheme2"
,
http
.
StatusMovedPermanently
},
...
...
@@ -43,6 +49,11 @@ func TestRedirect(t *testing.T) {
Rules
:
[]
Rule
{
{
FromPath
:
"/from"
,
To
:
"/to"
,
Code
:
http
.
StatusMovedPermanently
},
{
FromPath
:
"/a"
,
To
:
"/b"
,
Code
:
http
.
StatusTemporaryRedirect
},
// These http and https schemes would never actually be mixed in the same
// redirect rule with Caddy because http and https schemes have different listeners,
// so they don't share a redirect rule. So although these tests prove something
// impossible with Caddy, it's extra bulletproofing at very little cost.
{
FromScheme
:
"http"
,
FromPath
:
"/scheme"
,
To
:
"https://localhost/scheme"
,
Code
:
http
.
StatusMovedPermanently
},
{
FromScheme
:
"https"
,
FromPath
:
"/scheme2"
,
To
:
"http://localhost/scheme2"
,
Code
:
http
.
StatusMovedPermanently
},
{
FromScheme
:
""
,
FromPath
:
"/scheme3"
,
To
:
"https://localhost/scheme3"
,
Code
:
http
.
StatusMovedPermanently
},
...
...
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