-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from decke/26-tls-reqd-for-auth
Don't allow configuration requiring authentication with non-TLS listener
- Loading branch information
Showing
3 changed files
with
106 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSplitProto(t *testing.T) { | ||
var tests = []struct { | ||
input string | ||
proto string | ||
addr string | ||
}{ | ||
{ | ||
input: "localhost", | ||
proto: "", | ||
addr: "localhost", | ||
}, | ||
{ | ||
input: "tls://my.local.domain", | ||
proto: "tls", | ||
addr: "my.local.domain", | ||
}, | ||
{ | ||
input: "starttls://my.local.domain", | ||
proto: "starttls", | ||
addr: "my.local.domain", | ||
}, | ||
} | ||
|
||
for i, test := range tests { | ||
testName := test.input | ||
t.Run(testName, func(t *testing.T) { | ||
pa := splitProto(test.input) | ||
if pa.protocol != test.proto { | ||
t.Errorf("Testcase %d: Incorrect proto: expected %v, got %v", | ||
i, test.proto, pa.protocol) | ||
} | ||
if pa.address != test.addr { | ||
t.Errorf("Testcase %d: Incorrect addr: expected %v, got %v", | ||
i, test.addr, pa.address) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters