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
460c0c8a
Commit
460c0c8a
authored
Jun 20, 2015
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup: export functions and variables for external packages.
parent
528d1b03
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
49 deletions
+49
-49
config/directives.go
config/directives.go
+2
-2
config/setup/basicauth_test.go
config/setup/basicauth_test.go
+4
-4
config/setup/controllertest.go
config/setup/controllertest.go
+6
-6
config/setup/ext_test.go
config/setup/ext_test.go
+4
-4
config/setup/git_test.go
config/setup/git_test.go
+4
-4
config/setup/gzip_test.go
config/setup/gzip_test.go
+4
-4
config/setup/headers_test.go
config/setup/headers_test.go
+4
-4
config/setup/internal_test.go
config/setup/internal_test.go
+4
-4
config/setup/log_test.go
config/setup/log_test.go
+4
-4
config/setup/rewrite_test.go
config/setup/rewrite_test.go
+5
-5
config/setup/tls_test.go
config/setup/tls_test.go
+8
-8
No files found.
config/directives.go
View file @
460c0c8a
...
@@ -71,10 +71,10 @@ var directiveOrder = []directive{
...
@@ -71,10 +71,10 @@ var directiveOrder = []directive{
// directive ties together a directive name with its setup function.
// directive ties together a directive name with its setup function.
type
directive
struct
{
type
directive
struct
{
name
string
name
string
setup
s
etupFunc
setup
S
etupFunc
}
}
// A setup function takes a setup controller. Its return values may
// A setup function takes a setup controller. Its return values may
// both be nil. If middleware is not nil, it will be chained into
// both be nil. If middleware is not nil, it will be chained into
// the HTTP handlers in the order specified in this package.
// the HTTP handlers in the order specified in this package.
type
s
etupFunc
func
(
c
*
setup
.
Controller
)
(
middleware
.
Middleware
,
error
)
type
S
etupFunc
func
(
c
*
setup
.
Controller
)
(
middleware
.
Middleware
,
error
)
config/setup/basicauth_test.go
View file @
460c0c8a
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
)
)
func
TestBasicAuth
(
t
*
testing
.
T
)
{
func
TestBasicAuth
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`basicauth user pwd`
)
c
:=
N
ewTestController
(
`basicauth user pwd`
)
mid
,
err
:=
BasicAuth
(
c
)
mid
,
err
:=
BasicAuth
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -18,13 +18,13 @@ func TestBasicAuth(t *testing.T) {
...
@@ -18,13 +18,13 @@ func TestBasicAuth(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
basicauth
.
BasicAuth
)
myHandler
,
ok
:=
handler
.
(
basicauth
.
BasicAuth
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"Expected handler to be type BasicAuth, got: %#v"
,
handler
)
t
.
Fatalf
(
"Expected handler to be type BasicAuth, got: %#v"
,
handler
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
}
}
...
@@ -62,7 +62,7 @@ func TestBasicAuthParse(t *testing.T) {
...
@@ -62,7 +62,7 @@ func TestBasicAuthParse(t *testing.T) {
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
input
)
c
:=
N
ewTestController
(
test
.
input
)
actual
,
err
:=
basicAuthParse
(
c
)
actual
,
err
:=
basicAuthParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
...
config/setup/controller
_
test.go
→
config/setup/controllertest.go
View file @
460c0c8a
...
@@ -10,23 +10,23 @@ import (
...
@@ -10,23 +10,23 @@ import (
"github.com/mholt/caddy/server"
"github.com/mholt/caddy/server"
)
)
//
n
ewTestController creates a new *Controller for
//
N
ewTestController creates a new *Controller for
// the input specified, with a filename of "Testfile"
// the input specified, with a filename of "Testfile"
func
n
ewTestController
(
input
string
)
*
Controller
{
func
N
ewTestController
(
input
string
)
*
Controller
{
return
&
Controller
{
return
&
Controller
{
Config
:
&
server
.
Config
{},
Config
:
&
server
.
Config
{},
Dispenser
:
parse
.
NewDispenser
(
"Testfile"
,
strings
.
NewReader
(
input
)),
Dispenser
:
parse
.
NewDispenser
(
"Testfile"
,
strings
.
NewReader
(
input
)),
}
}
}
}
//
e
mptyNext is a no-op function that can be passed into
//
E
mptyNext is a no-op function that can be passed into
// middleware.Middleware functions so that the assignment
// middleware.Middleware functions so that the assignment
// to the Next field of the Handler can be tested.
// to the Next field of the Handler can be tested.
var
e
mptyNext
=
middleware
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
var
E
mptyNext
=
middleware
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
(
int
,
error
)
{
return
0
,
nil
return
0
,
nil
})
})
//
s
ameNext does a pointer comparison between next1 and next2.
//
S
ameNext does a pointer comparison between next1 and next2.
func
s
ameNext
(
next1
,
next2
middleware
.
Handler
)
bool
{
func
S
ameNext
(
next1
,
next2
middleware
.
Handler
)
bool
{
return
fmt
.
Sprintf
(
"%p"
,
next1
)
==
fmt
.
Sprintf
(
"%p"
,
next2
)
return
fmt
.
Sprintf
(
"%p"
,
next1
)
==
fmt
.
Sprintf
(
"%p"
,
next2
)
}
}
config/setup/ext_test.go
View file @
460c0c8a
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
)
)
func
TestExt
(
t
*
testing
.
T
)
{
func
TestExt
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`ext .html .htm .php`
)
c
:=
N
ewTestController
(
`ext .html .htm .php`
)
mid
,
err
:=
Ext
(
c
)
mid
,
err
:=
Ext
(
c
)
...
@@ -19,7 +19,7 @@ func TestExt(t *testing.T) {
...
@@ -19,7 +19,7 @@ func TestExt(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
extensions
.
Ext
)
myHandler
,
ok
:=
handler
.
(
extensions
.
Ext
)
if
!
ok
{
if
!
ok
{
...
@@ -35,7 +35,7 @@ func TestExt(t *testing.T) {
...
@@ -35,7 +35,7 @@ func TestExt(t *testing.T) {
if
myHandler
.
Extensions
[
2
]
!=
".php"
{
if
myHandler
.
Extensions
[
2
]
!=
".php"
{
t
.
Errorf
(
"Expected .php in the list of Extensions"
)
t
.
Errorf
(
"Expected .php in the list of Extensions"
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
...
@@ -52,7 +52,7 @@ func TestExtParse(t *testing.T) {
...
@@ -52,7 +52,7 @@ func TestExtParse(t *testing.T) {
{
`ext .txt .php .xml`
,
false
,
[]
string
{
".txt"
,
".php"
,
".xml"
}},
{
`ext .txt .php .xml`
,
false
,
[]
string
{
".txt"
,
".php"
,
".xml"
}},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
inputExts
)
c
:=
N
ewTestController
(
test
.
inputExts
)
actualExts
,
err
:=
extParse
(
c
)
actualExts
,
err
:=
extParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
...
config/setup/git_test.go
View file @
460c0c8a
...
@@ -22,7 +22,7 @@ func check(t *testing.T, err error) {
...
@@ -22,7 +22,7 @@ func check(t *testing.T, err error) {
}
}
func
TestGit
(
t
*
testing
.
T
)
{
func
TestGit
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`git git@github.com:mholt/caddy.git`
)
c
:=
N
ewTestController
(
`git git@github.com:mholt/caddy.git`
)
mid
,
err
:=
Git
(
c
)
mid
,
err
:=
Git
(
c
)
check
(
t
,
err
)
check
(
t
,
err
)
...
@@ -43,11 +43,11 @@ func TestIntervals(t *testing.T) {
...
@@ -43,11 +43,11 @@ func TestIntervals(t *testing.T) {
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
git
.
SetLogger
(
gittest
.
NewLogger
(
gittest
.
Open
(
"file"
)))
git
.
SetLogger
(
gittest
.
NewLogger
(
gittest
.
Open
(
"file"
)))
c1
:=
n
ewTestController
(
test
)
c1
:=
N
ewTestController
(
test
)
repo
,
err
:=
gitParse
(
c1
)
repo
,
err
:=
gitParse
(
c1
)
check
(
t
,
err
)
check
(
t
,
err
)
c2
:=
n
ewTestController
(
test
)
c2
:=
N
ewTestController
(
test
)
_
,
err
=
Git
(
c2
)
_
,
err
=
Git
(
c2
)
check
(
t
,
err
)
check
(
t
,
err
)
...
@@ -166,7 +166,7 @@ func TestGitParse(t *testing.T) {
...
@@ -166,7 +166,7 @@ func TestGitParse(t *testing.T) {
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
input
)
c
:=
N
ewTestController
(
test
.
input
)
repo
,
err
:=
gitParse
(
c
)
repo
,
err
:=
gitParse
(
c
)
if
!
test
.
shouldErr
&&
err
!=
nil
{
if
!
test
.
shouldErr
&&
err
!=
nil
{
t
.
Errorf
(
"Test %v should not error but found %v"
,
i
,
err
)
t
.
Errorf
(
"Test %v should not error but found %v"
,
i
,
err
)
...
...
config/setup/gzip_test.go
View file @
460c0c8a
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
)
)
func
TestGzip
(
t
*
testing
.
T
)
{
func
TestGzip
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`gzip`
)
c
:=
N
ewTestController
(
`gzip`
)
mid
,
err
:=
Gzip
(
c
)
mid
,
err
:=
Gzip
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -17,13 +17,13 @@ func TestGzip(t *testing.T) {
...
@@ -17,13 +17,13 @@ func TestGzip(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
gzip
.
Gzip
)
myHandler
,
ok
:=
handler
.
(
gzip
.
Gzip
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"Expected handler to be type Gzip, got: %#v"
,
handler
)
t
.
Fatalf
(
"Expected handler to be type Gzip, got: %#v"
,
handler
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
...
@@ -82,7 +82,7 @@ func TestGzip(t *testing.T) {
...
@@ -82,7 +82,7 @@ func TestGzip(t *testing.T) {
`
,
false
},
`
,
false
},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
input
)
c
:=
N
ewTestController
(
test
.
input
)
_
,
err
:=
gzipParse
(
c
)
_
,
err
:=
gzipParse
(
c
)
if
test
.
shouldErr
&&
err
==
nil
{
if
test
.
shouldErr
&&
err
==
nil
{
t
.
Errorf
(
"Test %v: Expected error but found nil"
,
i
)
t
.
Errorf
(
"Test %v: Expected error but found nil"
,
i
)
...
...
config/setup/headers_test.go
View file @
460c0c8a
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
)
)
func
TestHeaders
(
t
*
testing
.
T
)
{
func
TestHeaders
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`header / Foo Bar`
)
c
:=
N
ewTestController
(
`header / Foo Bar`
)
mid
,
err
:=
Headers
(
c
)
mid
,
err
:=
Headers
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -18,13 +18,13 @@ func TestHeaders(t *testing.T) {
...
@@ -18,13 +18,13 @@ func TestHeaders(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
headers
.
Headers
)
myHandler
,
ok
:=
handler
.
(
headers
.
Headers
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"Expected handler to be type Headers, got: %#v"
,
handler
)
t
.
Fatalf
(
"Expected handler to be type Headers, got: %#v"
,
handler
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
}
}
...
@@ -51,7 +51,7 @@ func TestHeadersParse(t *testing.T) {
...
@@ -51,7 +51,7 @@ func TestHeadersParse(t *testing.T) {
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
input
)
c
:=
N
ewTestController
(
test
.
input
)
actual
,
err
:=
headersParse
(
c
)
actual
,
err
:=
headersParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
...
config/setup/internal_test.go
View file @
460c0c8a
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
)
)
func
TestInternal
(
t
*
testing
.
T
)
{
func
TestInternal
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`internal /internal`
)
c
:=
N
ewTestController
(
`internal /internal`
)
mid
,
err
:=
Internal
(
c
)
mid
,
err
:=
Internal
(
c
)
...
@@ -19,7 +19,7 @@ func TestInternal(t *testing.T) {
...
@@ -19,7 +19,7 @@ func TestInternal(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
inner
.
Internal
)
myHandler
,
ok
:=
handler
.
(
inner
.
Internal
)
if
!
ok
{
if
!
ok
{
...
@@ -30,7 +30,7 @@ func TestInternal(t *testing.T) {
...
@@ -30,7 +30,7 @@ func TestInternal(t *testing.T) {
t
.
Errorf
(
"Expected internal in the list of internal Paths"
)
t
.
Errorf
(
"Expected internal in the list of internal Paths"
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
...
@@ -48,7 +48,7 @@ func TestInternalParse(t *testing.T) {
...
@@ -48,7 +48,7 @@ func TestInternalParse(t *testing.T) {
internal /internal2`
,
false
,
[]
string
{
"/internal1"
,
"/internal2"
}},
internal /internal2`
,
false
,
[]
string
{
"/internal1"
,
"/internal2"
}},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
inputInternalPaths
)
c
:=
N
ewTestController
(
test
.
inputInternalPaths
)
actualInternalPaths
,
err
:=
internalParse
(
c
)
actualInternalPaths
,
err
:=
internalParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
...
config/setup/log_test.go
View file @
460c0c8a
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
func
TestLog
(
t
*
testing
.
T
)
{
func
TestLog
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`log`
)
c
:=
N
ewTestController
(
`log`
)
mid
,
err
:=
Log
(
c
)
mid
,
err
:=
Log
(
c
)
...
@@ -20,7 +20,7 @@ func TestLog(t *testing.T) {
...
@@ -20,7 +20,7 @@ func TestLog(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
caddylog
.
Logger
)
myHandler
,
ok
:=
handler
.
(
caddylog
.
Logger
)
if
!
ok
{
if
!
ok
{
...
@@ -36,7 +36,7 @@ func TestLog(t *testing.T) {
...
@@ -36,7 +36,7 @@ func TestLog(t *testing.T) {
if
myHandler
.
Rules
[
0
]
.
Format
!=
caddylog
.
DefaultLogFormat
{
if
myHandler
.
Rules
[
0
]
.
Format
!=
caddylog
.
DefaultLogFormat
{
t
.
Errorf
(
"Expected %s as the default Log Format"
,
caddylog
.
DefaultLogFormat
)
t
.
Errorf
(
"Expected %s as the default Log Format"
,
caddylog
.
DefaultLogFormat
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
...
@@ -100,7 +100,7 @@ func TestLogParse(t *testing.T) {
...
@@ -100,7 +100,7 @@ func TestLogParse(t *testing.T) {
}}},
}}},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
n
ewTestController
(
test
.
inputLogRules
)
c
:=
N
ewTestController
(
test
.
inputLogRules
)
actualLogRules
,
err
:=
logParse
(
c
)
actualLogRules
,
err
:=
logParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
...
config/setup/rewrite_test.go
View file @
460c0c8a
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
)
)
func
TestRewrite
(
t
*
testing
.
T
)
{
func
TestRewrite
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`rewrite /from /to`
)
c
:=
N
ewTestController
(
`rewrite /from /to`
)
mid
,
err
:=
Rewrite
(
c
)
mid
,
err
:=
Rewrite
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -20,13 +20,13 @@ func TestRewrite(t *testing.T) {
...
@@ -20,13 +20,13 @@ func TestRewrite(t *testing.T) {
t
.
Fatal
(
"Expected middleware, was nil instead"
)
t
.
Fatal
(
"Expected middleware, was nil instead"
)
}
}
handler
:=
mid
(
e
mptyNext
)
handler
:=
mid
(
E
mptyNext
)
myHandler
,
ok
:=
handler
.
(
rewrite
.
Rewrite
)
myHandler
,
ok
:=
handler
.
(
rewrite
.
Rewrite
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"Expected handler to be type Rewrite, got: %#v"
,
handler
)
t
.
Fatalf
(
"Expected handler to be type Rewrite, got: %#v"
,
handler
)
}
}
if
!
sameNext
(
myHandler
.
Next
,
e
mptyNext
)
{
if
!
SameNext
(
myHandler
.
Next
,
E
mptyNext
)
{
t
.
Error
(
"'Next' field of handler was not set properly"
)
t
.
Error
(
"'Next' field of handler was not set properly"
)
}
}
...
@@ -57,7 +57,7 @@ func TestRewriteParse(t *testing.T) {
...
@@ -57,7 +57,7 @@ func TestRewriteParse(t *testing.T) {
}
}
for
i
,
test
:=
range
simpleTests
{
for
i
,
test
:=
range
simpleTests
{
c
:=
n
ewTestController
(
test
.
input
)
c
:=
N
ewTestController
(
test
.
input
)
actual
,
err
:=
rewriteParse
(
c
)
actual
,
err
:=
rewriteParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
@@ -140,7 +140,7 @@ func TestRewriteParse(t *testing.T) {
...
@@ -140,7 +140,7 @@ func TestRewriteParse(t *testing.T) {
}
}
for
i
,
test
:=
range
regexpTests
{
for
i
,
test
:=
range
regexpTests
{
c
:=
n
ewTestController
(
test
.
input
)
c
:=
N
ewTestController
(
test
.
input
)
actual
,
err
:=
rewriteParse
(
c
)
actual
,
err
:=
rewriteParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
...
...
config/setup/tls_test.go
View file @
460c0c8a
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
)
)
func
TestTLSParseBasic
(
t
*
testing
.
T
)
{
func
TestTLSParseBasic
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`tls cert.pem key.pem`
)
c
:=
N
ewTestController
(
`tls cert.pem key.pem`
)
_
,
err
:=
TLS
(
c
)
_
,
err
:=
TLS
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -66,14 +66,14 @@ func TestTLSParseBasic(t *testing.T) {
...
@@ -66,14 +66,14 @@ func TestTLSParseBasic(t *testing.T) {
}
}
func
TestTLSParseIncompleteParams
(
t
*
testing
.
T
)
{
func
TestTLSParseIncompleteParams
(
t
*
testing
.
T
)
{
c
:=
n
ewTestController
(
`tls`
)
c
:=
N
ewTestController
(
`tls`
)
_
,
err
:=
TLS
(
c
)
_
,
err
:=
TLS
(
c
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expected errors, but no error returned"
)
t
.
Errorf
(
"Expected errors, but no error returned"
)
}
}
c
=
n
ewTestController
(
`tls cert.key`
)
c
=
N
ewTestController
(
`tls cert.key`
)
_
,
err
=
TLS
(
c
)
_
,
err
=
TLS
(
c
)
if
err
==
nil
{
if
err
==
nil
{
...
@@ -86,7 +86,7 @@ func TestTLSParseWithOptionalParams(t *testing.T) {
...
@@ -86,7 +86,7 @@ func TestTLSParseWithOptionalParams(t *testing.T) {
protocols ssl3.0 tls1.2
protocols ssl3.0 tls1.2
ciphers RSA-3DES-EDE-CBC-SHA RSA-AES256-CBC-SHA ECDHE-RSA-AES128-GCM-SHA256
ciphers RSA-3DES-EDE-CBC-SHA RSA-AES256-CBC-SHA ECDHE-RSA-AES128-GCM-SHA256
}`
}`
c
:=
n
ewTestController
(
params
)
c
:=
N
ewTestController
(
params
)
_
,
err
:=
TLS
(
c
)
_
,
err
:=
TLS
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -111,7 +111,7 @@ func TestTLSParseWithWrongOptionalParams(t *testing.T) {
...
@@ -111,7 +111,7 @@ func TestTLSParseWithWrongOptionalParams(t *testing.T) {
params
:=
`tls cert.crt cert.key {
params
:=
`tls cert.crt cert.key {
protocols ssl tls
protocols ssl tls
}`
}`
c
:=
n
ewTestController
(
params
)
c
:=
N
ewTestController
(
params
)
_
,
err
:=
TLS
(
c
)
_
,
err
:=
TLS
(
c
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expected errors, but no error returned"
)
t
.
Errorf
(
"Expected errors, but no error returned"
)
...
@@ -121,7 +121,7 @@ func TestTLSParseWithWrongOptionalParams(t *testing.T) {
...
@@ -121,7 +121,7 @@ func TestTLSParseWithWrongOptionalParams(t *testing.T) {
params
=
`tls cert.crt cert.key {
params
=
`tls cert.crt cert.key {
ciphers not-valid-cipher
ciphers not-valid-cipher
}`
}`
c
=
n
ewTestController
(
params
)
c
=
N
ewTestController
(
params
)
_
,
err
=
TLS
(
c
)
_
,
err
=
TLS
(
c
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expected errors, but no error returned"
)
t
.
Errorf
(
"Expected errors, but no error returned"
)
...
@@ -132,7 +132,7 @@ func TestTLSParseWithClientAuth(t *testing.T) {
...
@@ -132,7 +132,7 @@ func TestTLSParseWithClientAuth(t *testing.T) {
params
:=
`tls cert.crt cert.key {
params
:=
`tls cert.crt cert.key {
clients client_ca.crt client2_ca.crt
clients client_ca.crt client2_ca.crt
}`
}`
c
:=
n
ewTestController
(
params
)
c
:=
N
ewTestController
(
params
)
_
,
err
:=
TLS
(
c
)
_
,
err
:=
TLS
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Expected no errors, got: %v"
,
err
)
t
.
Errorf
(
"Expected no errors, got: %v"
,
err
)
...
@@ -152,7 +152,7 @@ func TestTLSParseWithClientAuth(t *testing.T) {
...
@@ -152,7 +152,7 @@ func TestTLSParseWithClientAuth(t *testing.T) {
params
=
`tls cert.crt cert.key {
params
=
`tls cert.crt cert.key {
clients
clients
}`
}`
c
=
n
ewTestController
(
params
)
c
=
N
ewTestController
(
params
)
_
,
err
=
TLS
(
c
)
_
,
err
=
TLS
(
c
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expected an error, but no error returned"
)
t
.
Errorf
(
"Expected an error, but no error returned"
)
...
...
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