Documentation ¶
Overview ¶
Package testing contains helpers for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( TestKeyPEMBlock = []byte(`-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANMCiODGlCDyIWXG 6jC6FeIXPfXOSikxOCOhLPNU2HdlRaBsekzRqBmbsFKMWqnD0WZ2fQbsCbmYVURc HVPZujgtugidqdhBTydEZ4dU16FTSTDCzJfn8E1NeVrxBROJQ7X+hFFyAHDEdlS0 wO1d70Aj9DWLzE4BEpePrgNp215XAgMBAAECgYAvPVIHgG2JMqvnbTDg18guZaWp chWIQ0yeLWcy0rvjfvingaGfsRBBK2m+EU3606v9lGlJM2657jCorTajnwrhQGaE rPVwktsHrrQrAxDGPXHOwzrfWdJdsIahYx3raq8M8heEJPlrppDClnt+f60PUQTZ hnYz0a3ybDewCW4zAQJBAP1wogYhkqA8jaZjBaE02srXAPCRKw2I0kCuCvHvIywz ngCMsfzNcfLV5fEr+OOQPpT0yzR9ak0QHX4f3o/GAp8CQQDVJC6yb3gDsmGc+SuX O+DOYKpKG43+G7G3klQDkIVKdHZU/afk6QENbpSa2zgfKN1Mwu4xEQNkIsoDa5eS XgFJAkEAvabVeCUTZhkqHsKm6dV1jKiLqXnYb85dF82lnxnGhkMyD1M5teW/SWrL IUg4fYHpcuokTekz7OsMRt9uWsRgHQJBAKIXUiwA+ZRWJEXseGoa72wDt32EVwfY p96jOaE8VyG4UAVyoixDxrkgT4M1FAkeWq310I8gESQmENtpB2wYcYECQGbi8qUV zR7hk6TXzsdXhQFzWeP9b1k0+UI8bmzGIvMPyrD2cbkbHBVY2pr6JPGmXA9J+Zls BOXvP0OI6kkouG0= -----END PRIVATE KEY-----`) TestCertPEMBlock = []byte(`-----BEGIN CERTIFICATE----- MIIB/DCCAWWgAwIBAgIRAIina36VIKk2Y/ZZWR23HBcwDQYJKoZIhvcNAQELBQAw EjEQMA4GA1UEChMHQWNtZSBDbzAeFw0yMTA0MDYxNzAwMTRaFw0zMTA0MDQxNzAw MTRaMBIxEDAOBgNVBAoTB0FjbWUgQ28wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ AoGBANMCiODGlCDyIWXG6jC6FeIXPfXOSikxOCOhLPNU2HdlRaBsekzRqBmbsFKM WqnD0WZ2fQbsCbmYVURcHVPZujgtugidqdhBTydEZ4dU16FTSTDCzJfn8E1NeVrx BROJQ7X+hFFyAHDEdlS0wO1d70Aj9DWLzE4BEpePrgNp215XAgMBAAGjUjBQMA4G A1UdDwEB/wQEAwICpDATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHRMBAf8EBTAD AQH/MBgGA1UdEQQRMA+CDXB1c2gtZGVsaXZlcnkwDQYJKoZIhvcNAQELBQADgYEA X/91b8KgBxP06bMArFhBgCt47Dsq7jjeMm9MOXi2qRKIVcWOq5BcVMBHsydrR2Zk 8V3z+OEfCPp3bK/OOpa2R9f+vIeI0bjEace5eG0rhOMbVHuBqwpVclY6p/TmuU1P 4QpSpXBdPtsaqGAE08P0ZyBJFwpsaaUmYV1OP4S0gDM= -----END CERTIFICATE-----`) // key&cert generated with openssl req -x509 -nodes -newkey rsa:2048 // -multivalue-rdn -sha512 -days 3650 -keyout testing.key -out // testing.cert -subj "/O=Acme Co/CN=push-delivery/" TestKeyPEMBlock512 = []byte(`-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC4ySO/avJFWps8 AygUZ0dcylNr1UxZb4QPHuO93OXAkYX5ngw7TjnWIGHjvoLzLzPZCxlrGl7e+M1H GNZqFT3kFv/XYexp9Cx3MCDy0ZWkK9BAVDTAxMkjSR8ZwRjByQqniilDA/kr92NQ yaL0GlajsxpmcGMjDM0Dp5QF+inQM48ADJpJl0xlfFwE8CwfVVGM8G/ZtQpBJ3AN RelEG1iF8tsT9nVlWF37Zp9Wp/CxDDVTuzboZx9pkryOeJmm0l93x1aoSy6DTVyg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kz2L2AUrko/ao1/ZgKhHsIBFQ7mm5fkvuNd14ZEJ0F8LyI 55Et63IYWYOPHl0oNmzTHex0WRL9nmNvxbQ5UytzGTE5amv/sZTOYH9qnpEes68O TPP+C3OoM+U6hjOXNGG73zb54JHQUZ4arMg2gbVzxNXU2ReoKYKrYexGGuqIlHcE XdOQp93oJfqWAj111YS6tIn63ccjx7bKzFzaufuVvCIsk0WrXG2rpuqx+0OYzRKc deU3hnONgWVXjCQdNysBzUXLeOWcv1KuqScETvGZe7D1UIk7HWsAgnQnYQ== -----END CERTIFICATE-----`) // key&cert, same as server/acceptance/ssl/testing.* TestKeyPEMBlockAcceptance []byte TestCertPEMBlockAcceptance []byte )
key&cert generated with go run /usr/lib/go/src/pkg/crypto/tls/generate_cert.go -ca -host push-delivery -rsa-bits 1024 -duration 87600h
var ( TestTLSServerConfigs = map[string]*tls.Config{} TestTLSClientConfigs = map[string]*tls.Config{} TestTLSServerConfig, TestTLSClientConfig *tls.Config )
test tls server & client configs
Functions ¶
func Ns ¶
func Ns(payloads ...json.RawMessage) []protocol.Notification
Ns makes a []Notification from just payloads.
func ScriptAbsPath ¶
ScriptAbsPath gets the absolute path to a script in the scripts directory assuming we're in a subdirectory of the project
func SourceRelative ¶
SourceRelative produces a path relative to the source code, makes sense only for tests when the code is available on disk.
Types ¶
type TestLogger ¶
TestLogger implements logger.Logger using gocheck.C and supporting capturing log strings.
func NewTestLogger ¶
func NewTestLogger(minLog logger.MinimalLogger, level string) *TestLogger
NewTestLogger can be used in tests instead of NewSimpleLogger(FromMinimalLogger).
func (*TestLogger) Captured ¶
func (tlog *TestLogger) Captured() string
Captured returns accumulated log events.
func (*TestLogger) ResetCapture ¶
func (tlog *TestLogger) ResetCapture()
Reset resets accumulated log events.
func (*TestLogger) SetLogEventCb ¶
func (tlog *TestLogger) SetLogEventCb(cb func(string))
SetLogEventCb sets a callback invoked for log events.