summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/braintree/manners/test_helpers
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/braintree/manners/test_helpers')
-rw-r--r--vendor/github.com/braintree/manners/test_helpers/certs.go29
-rw-r--r--vendor/github.com/braintree/manners/test_helpers/conn.go13
-rw-r--r--vendor/github.com/braintree/manners/test_helpers/listener.go34
-rw-r--r--vendor/github.com/braintree/manners/test_helpers/temp_file.go27
-rw-r--r--vendor/github.com/braintree/manners/test_helpers/wait_group.go33
5 files changed, 136 insertions, 0 deletions
diff --git a/vendor/github.com/braintree/manners/test_helpers/certs.go b/vendor/github.com/braintree/manners/test_helpers/certs.go
new file mode 100644
index 000000000..ede248b3d
--- /dev/null
+++ b/vendor/github.com/braintree/manners/test_helpers/certs.go
@@ -0,0 +1,29 @@
+package test_helpers
+
+// A PEM-encoded TLS cert with SAN IPs "127.0.0.1" and "[::1]", expiring at the
+// last second of 2049 (the end of ASN.1 time).
+
+// generated from src/pkg/crypto/tls:
+// go run generate_cert.go --rsa-bits 512 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
+var (
+ Cert = []byte(`-----BEGIN CERTIFICATE-----
+MIIBdzCCASOgAwIBAgIBADALBgkqhkiG9w0BAQUwEjEQMA4GA1UEChMHQWNtZSBD
+bzAeFw03MDAxMDEwMDAwMDBaFw00OTEyMzEyMzU5NTlaMBIxEDAOBgNVBAoTB0Fj
+bWUgQ28wWjALBgkqhkiG9w0BAQEDSwAwSAJBAN55NcYKZeInyTuhcCwFMhDHCmwa
+IUSdtXdcbItRB/yfXGBhiex00IaLXQnSU+QZPRZWYqeTEbFSgihqi1PUDy8CAwEA
+AaNoMGYwDgYDVR0PAQH/BAQDAgCkMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1Ud
+EwEB/wQFMAMBAf8wLgYDVR0RBCcwJYILZXhhbXBsZS5jb22HBH8AAAGHEAAAAAAA
+AAAAAAAAAAAAAAEwCwYJKoZIhvcNAQEFA0EAAoQn/ytgqpiLcZu9XKbCJsJcvkgk
+Se6AbGXgSlq+ZCEVo0qIwSgeBqmsJxUu7NCSOwVJLYNEBO2DtIxoYVk+MA==
+-----END CERTIFICATE-----`)
+
+ Key = []byte(`-----BEGIN RSA PRIVATE KEY-----
+MIIBPAIBAAJBAN55NcYKZeInyTuhcCwFMhDHCmwaIUSdtXdcbItRB/yfXGBhiex0
+0IaLXQnSU+QZPRZWYqeTEbFSgihqi1PUDy8CAwEAAQJBAQdUx66rfh8sYsgfdcvV
+NoafYpnEcB5s4m/vSVe6SU7dCK6eYec9f9wpT353ljhDUHq3EbmE4foNzJngh35d
+AekCIQDhRQG5Li0Wj8TM4obOnnXUXf1jRv0UkzE9AHWLG5q3AwIhAPzSjpYUDjVW
+MCUXgckTpKCuGwbJk7424Nb8bLzf3kllAiA5mUBgjfr/WtFSJdWcPQ4Zt9KTMNKD
+EUO0ukpTwEIl6wIhAMbGqZK3zAAFdq8DD2jPx+UJXnh0rnOkZBzDtJ6/iN69AiEA
+1Aq8MJgTaYsDQWyU/hDq5YkDJc9e9DSCvUIzqxQWMQE=
+-----END RSA PRIVATE KEY-----`)
+)
diff --git a/vendor/github.com/braintree/manners/test_helpers/conn.go b/vendor/github.com/braintree/manners/test_helpers/conn.go
new file mode 100644
index 000000000..8c610f58e
--- /dev/null
+++ b/vendor/github.com/braintree/manners/test_helpers/conn.go
@@ -0,0 +1,13 @@
+package test_helpers
+
+import "net"
+
+type Conn struct {
+ net.Conn
+ CloseCalled bool
+}
+
+func (c *Conn) Close() error {
+ c.CloseCalled = true
+ return nil
+}
diff --git a/vendor/github.com/braintree/manners/test_helpers/listener.go b/vendor/github.com/braintree/manners/test_helpers/listener.go
new file mode 100644
index 000000000..e3af35a6e
--- /dev/null
+++ b/vendor/github.com/braintree/manners/test_helpers/listener.go
@@ -0,0 +1,34 @@
+package test_helpers
+
+import (
+ "errors"
+ "net"
+)
+
+type Listener struct {
+ AcceptRelease chan bool
+ CloseCalled chan bool
+}
+
+func NewListener() *Listener {
+ return &Listener{
+ make(chan bool, 1),
+ make(chan bool, 1),
+ }
+}
+
+func (l *Listener) Addr() net.Addr {
+ addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:8080")
+ return addr
+}
+
+func (l *Listener) Close() error {
+ l.CloseCalled <- true
+ l.AcceptRelease <- true
+ return nil
+}
+
+func (l *Listener) Accept() (net.Conn, error) {
+ <-l.AcceptRelease
+ return nil, errors.New("connection closed")
+}
diff --git a/vendor/github.com/braintree/manners/test_helpers/temp_file.go b/vendor/github.com/braintree/manners/test_helpers/temp_file.go
new file mode 100644
index 000000000..c4aa263a0
--- /dev/null
+++ b/vendor/github.com/braintree/manners/test_helpers/temp_file.go
@@ -0,0 +1,27 @@
+package test_helpers
+
+import (
+ "io/ioutil"
+ "os"
+)
+
+type TempFile struct {
+ *os.File
+}
+
+func NewTempFile(content []byte) (*TempFile, error) {
+ f, err := ioutil.TempFile("", "graceful-test")
+ if err != nil {
+ return nil, err
+ }
+
+ f.Write(content)
+ return &TempFile{f}, nil
+}
+
+func (tf *TempFile) Unlink() {
+ if tf.File != nil {
+ os.Remove(tf.Name())
+ tf.File = nil
+ }
+}
diff --git a/vendor/github.com/braintree/manners/test_helpers/wait_group.go b/vendor/github.com/braintree/manners/test_helpers/wait_group.go
new file mode 100644
index 000000000..1df590db7
--- /dev/null
+++ b/vendor/github.com/braintree/manners/test_helpers/wait_group.go
@@ -0,0 +1,33 @@
+package test_helpers
+
+import "sync"
+
+type WaitGroup struct {
+ sync.Mutex
+ Count int
+ WaitCalled chan int
+}
+
+func NewWaitGroup() *WaitGroup {
+ return &WaitGroup{
+ WaitCalled: make(chan int, 1),
+ }
+}
+
+func (wg *WaitGroup) Add(delta int) {
+ wg.Lock()
+ wg.Count++
+ wg.Unlock()
+}
+
+func (wg *WaitGroup) Done() {
+ wg.Lock()
+ wg.Count--
+ wg.Unlock()
+}
+
+func (wg *WaitGroup) Wait() {
+ wg.Lock()
+ wg.WaitCalled <- wg.Count
+ wg.Unlock()
+}