Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
Railgun
Coredns
Commits
cff0c9fb
Commit
cff0c9fb
authored
Apr 13, 2018
by
Miek Gieben
Committed by
GitHub
Apr 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/forward: test TLS setup (#1677)
parent
662edf66
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
plugin/forward/setup.go
plugin/forward/setup.go
+1
-1
plugin/forward/setup_test.go
plugin/forward/setup_test.go
+37
-0
No files found.
plugin/forward/setup.go
View file @
cff0c9fb
...
...
@@ -114,7 +114,7 @@ func parseForward(c *caddy.Controller) (*Forward, error) {
break
}
// This is more of a bug in
//
dnsutil.ParseHostPortOrFile that defaults to
// This is more of a bug in dnsutil.ParseHostPortOrFile that defaults to
// 53 because it doesn't know about the tls:// // and friends (that should be fixed). Hence
// Fix the port number here, back to what the user intended.
if
p
==
"53"
{
...
...
plugin/forward/setup_test.go
View file @
cff0c9fb
...
...
@@ -68,3 +68,40 @@ func TestSetup(t *testing.T) {
}
}
}
func
TestSetupTLS
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
input
string
shouldErr
bool
expectedServerName
string
expectedErr
string
}{
// positive
{
`forward . 127.0.0.1 {
tls_servername dns
}`
,
false
,
"dns"
,
""
},
}
for
i
,
test
:=
range
tests
{
c
:=
caddy
.
NewTestController
(
"dns"
,
test
.
input
)
f
,
err
:=
parseForward
(
c
)
if
test
.
shouldErr
&&
err
==
nil
{
t
.
Errorf
(
"Test %d: expected error but found %s for input %s"
,
i
,
err
,
test
.
input
)
}
if
err
!=
nil
{
if
!
test
.
shouldErr
{
t
.
Errorf
(
"Test %d: expected no error but found one for input %s, got: %v"
,
i
,
test
.
input
,
err
)
}
if
!
strings
.
Contains
(
err
.
Error
(),
test
.
expectedErr
)
{
t
.
Errorf
(
"Test %d: expected error to contain: %v, found error: %v, input: %s"
,
i
,
test
.
expectedErr
,
err
,
test
.
input
)
}
}
if
!
test
.
shouldErr
&&
test
.
expectedServerName
!=
f
.
tlsConfig
.
ServerName
{
t
.
Errorf
(
"Test %d: expected: %q, actual: %q"
,
i
,
test
.
expectedServerName
,
f
.
tlsConfig
.
ServerName
)
}
}
}
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