-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
186 additions
and
13 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,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDTjCCAjYCCQCsd4M/nAhEeDANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJE | ||
RTEPMA0GA1UECAwGQmVybGluMRMwEQYDVQQKDApaYWxhbmRvIFNFMRMwEQYDVQQL | ||
DApUZWNobm9sb2d5MR8wHQYDVQQDDBZkby1ub3QtdHJ1c3QtdGVzdC1kYXRhMB4X | ||
DTE2MDQwNDA4NTEyN1oXDTI2MDQwMjA4NTEyN1owaTELMAkGA1UEBhMCREUxDzAN | ||
BgNVBAgMBkJlcmxpbjETMBEGA1UECgwKWmFsYW5kbyBTRTETMBEGA1UECwwKVGVj | ||
aG5vbG9neTEfMB0GA1UEAwwWZG8tbm90LXRydXN0LXRlc3QtZGF0YTCCASIwDQYJ | ||
KoZIhvcNAQEBBQADggEPADCCAQoCggEBALZY9V/Psbq/9nqTQEnwz0CjHV7t+THG | ||
wo5Xa3BGO4hKWKdAODDXc5Z7M6OmnboP0FmlKF8IKVsrdtKHxK4WzrlRiUDoRSgc | ||
2lOuO8/kGr/MhIqEapQ95WJMiG6yGBkaZulmg8pb3FL+iHARCDzYIoWcozU69nvF | ||
HPNgeFGUE/jjkZJLyHmOgbxhfhJYin2X/OFyN0DkPGzpHBnGGqYXCHUt25mkYgqG | ||
OAQSwpR7XwRSJCg+Z09tXvUV06G/yfU+zFfzimD6CmQRa03Z8zXP5yRaJfxavqVV | ||
kKwL9awCnoIeXBZGdOO6Y0+I71+72m6KwwvpHZK2nEBj23BT9xHbFfkCAwEAATAN | ||
BgkqhkiG9w0BAQsFAAOCAQEASkABIkz//wxTOiAmVfY7NVndAYMzSbQJ+hrfmUhr | ||
uyx8eF/UYFNf/lQ6IqGYF09xi/8CexliMoYQNnRhHG5KyFWyHi52lMLjTiMCpn4w | ||
PyQZhy3PUQoK/69+4zVDytTGIlOC9epYgYTGEhvRSNsm192sq+BXuibSoEOSOwKV | ||
Hd9lvhdeumeScWxUComl83HHhLE1rVRE4RzH0JTkGwgKrFbBBgaapJVCw2238QfE | ||
ZtMlh+BBvFJcQgldlhHn4PHDZwPWxn7i6kcGCILvO/EIRFvgUvYn1Y+gvwFJinlU | ||
cBOOedjhYVj+nPc3uL480Mo5fPWgHHI04uqDD77m1fkG3w== | ||
-----END CERTIFICATE----- |
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,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC2WPVfz7G6v/Z6 | ||
k0BJ8M9Aox1e7fkxxsKOV2twRjuISlinQDgw13OWezOjpp26D9BZpShfCClbK3bS | ||
h8SuFs65UYlA6EUoHNpTrjvP5Bq/zISKhGqUPeViTIhushgZGmbpZoPKW9xS/ohw | ||
EQg82CKFnKM1OvZ7xRzzYHhRlBP445GSS8h5joG8YX4SWIp9l/zhcjdA5Dxs6RwZ | ||
xhqmFwh1LduZpGIKhjgEEsKUe18EUiQoPmdPbV71FdOhv8n1PsxX84pg+gpkEWtN | ||
2fM1z+ckWiX8Wr6lVZCsC/WsAp6CHlwWRnTjumNPiO9fu9puisML6R2StpxAY9tw | ||
U/cR2xX5AgMBAAECggEBAI8AjM4qz7MpQF84g754/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4CbkaK4LOzIqgIyrQKBgQCvh7xmwIFAWIBPYqH8 | ||
o0njbU6N4dSTyXuY61a30bo5dc3X6DDgdMkoIp6vhs3WBbmOr7AH2oBBkfs3RIcC | ||
TIa9KaUEWBhO2DZoUcDY49kwUeAjoVjQetxJgdS4gDejBugmI13jJMuGfxbDw+Qi | ||
E5hUPz8TmgWaDNQWBQqnB8CIPQ== | ||
-----END PRIVATE KEY----- |
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,98 @@ | ||
package skipper | ||
|
||
import ( | ||
"crypto/tls" | ||
"io/ioutil" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/zalando/skipper/filters/builtin" | ||
"github.com/zalando/skipper/proxy" | ||
"github.com/zalando/skipper/routing" | ||
) | ||
|
||
func initializeProxy() *http.Handler { | ||
filterRegistry := builtin.MakeRegistry() | ||
proxy := proxy.New(routing.New(routing.Options{ | ||
FilterRegistry: filterRegistry, | ||
DataClients: []routing.DataClient{}}), proxy.OptionsNone) | ||
return &proxy | ||
} | ||
|
||
func TestMissingOptionHTTP(t *testing.T) { | ||
o := Options{} | ||
if o.isHTTPS() { | ||
t.FailNow() | ||
} | ||
} | ||
|
||
func TestWithOptionHTTPS(t *testing.T) { | ||
o := Options{CertPathTLS: "foo", KeyPathTLS: "bar"} | ||
if !o.isHTTPS() { | ||
t.FailNow() | ||
} | ||
} | ||
|
||
func TestWrongCert(t *testing.T) { | ||
o := Options{Address: ":9091", | ||
CertPathTLS: "fixtures/notFound.crt", | ||
KeyPathTLS: "fixtures/test.key", | ||
} | ||
proxy := initializeProxy() | ||
|
||
err := listenAndServe(proxy, &o) | ||
if err == nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestWrongKey(t *testing.T) { | ||
o := Options{Address: ":9091", | ||
CertPathTLS: "fixtures/test.crt", | ||
KeyPathTLS: "fixtures/notFound.key", | ||
} | ||
proxy := initializeProxy() | ||
err := listenAndServe(proxy, &o) | ||
if err == nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestHTTPSServer(t *testing.T) { | ||
o := Options{ | ||
Address: ":9091", | ||
CertPathTLS: "fixtures/test.crt", | ||
KeyPathTLS: "fixtures/test.key", | ||
} | ||
proxy := initializeProxy() | ||
go listenAndServe(proxy, &o) | ||
|
||
tr := &http.Transport{ | ||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | ||
} | ||
client := &http.Client{Transport: tr} | ||
r, err := client.Get("https://localhost:9091") | ||
if err == nil { | ||
defer r.Body.Close() | ||
_, _ = ioutil.ReadAll(r.Body) | ||
if r.StatusCode != 404 { | ||
t.Fatalf("Status code should be 404, instead got: %d\n", r.StatusCode) | ||
} | ||
} | ||
} | ||
|
||
func TestHTTPServer(t *testing.T) { | ||
o := Options{ | ||
Address: ":9090", | ||
} | ||
proxy := initializeProxy() | ||
go listenAndServe(proxy, &o) | ||
r, err := http.Get("http://localhost:9090") | ||
if err == nil { | ||
defer r.Body.Close() | ||
_, _ = ioutil.ReadAll(r.Body) | ||
if r.StatusCode != 404 { | ||
t.Fatalf("Status code should be 404, instead got: %d\n", r.StatusCode) | ||
} | ||
} | ||
} |