h2spec

package module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2016 License: MIT Imports: 15 Imported by: 0

README

h2spec

h2spec is a conformance testing tool for HTTP/2 implementation.
This tool is compliant with RFC 7540 (HTTP/2).

Install

Go to the releases page, find the version you want, and download the zip file.

Build

  1. Make sure you have go 1.5 and set GOPATH appropriately
  2. Run go get github.com/summerwind/h2spec/cmd/h2spec

It is also possible to build specific version.

  1. Make sure you have go 1.5 and set GOPATH appropriately
  2. Run go get gopkg.in/summerwind/h2spec.v1/cmd/h2spec

Usage

$ h2spec --help
Usage: h2spec [OPTIONS]

Options:
  -p:        Target port. (Default: 80 or 443)
  -h:        Target host. (Default: 127.0.0.1)
  -t:        Connect over TLS. (Default: false)
  -k:        Don't verify server's certificate. (Default: false)
  -o:        Maximum time allowed for test. (Default: 2)
  -s:        Section number on which to run the test. (Example: -s 6.1 -s 6.2)
  -S:        Run the test cases marked as "strict".
  -j:        Creates report also in JUnit format into specified file.
  --version: Display version information and exit.
  --help:    Display this help and exit.

Screenshot

Sceenshot

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCodeDefault http2.ErrCode = math.MaxUint8
View Source
var FlagDefault http2.Flags = math.MaxUint8
View Source
var LengthDefault uint32 = math.MaxUint32
View Source
var TIMEOUT = errors.New("Timeout")

Functions

func Run

func Run(ctx *Context) bool

func TestConnectionError

func TestConnectionError(ctx *Context, http2Conn *Http2Conn, codes []http2.ErrCode) (pass bool, expected []Result, actual Result)

func TestErrorCode

func TestErrorCode(code http2.ErrCode, expected []http2.ErrCode) bool

func TestStreamClose

func TestStreamClose(ctx *Context, http2Conn *Http2Conn) (pass bool, expected []Result, actual Result)

func TestStreamError

func TestStreamError(ctx *Context, http2Conn *Http2Conn, codes []http2.ErrCode) (pass bool, expected []Result, actual Result)

Types

type Context

type Context struct {
	Port      int
	Host      string
	Strict    bool
	Junit     string
	Tls       bool
	TlsConfig *tls.Config
	Sections  map[string]bool
	Timeout   time.Duration
	Verbose   bool
}

func (*Context) Authority

func (ctx *Context) Authority() string

func (*Context) GetRunMode

func (ctx *Context) GetRunMode(section string) RunMode

type Http2Conn

type Http2Conn struct {
	HpackEncoder   *hpack.Encoder
	HeaderWriteBuf bytes.Buffer
	Settings       map[http2.SettingID]uint32
	// contains filtered or unexported fields
}

func CreateHttp2Conn

func CreateHttp2Conn(ctx *Context, sn bool) *Http2Conn

func (*Http2Conn) EncodeHeader

func (h2Conn *Http2Conn) EncodeHeader(header []hpack.HeaderField) []byte

EncodeHeader encodes header and returns encoded bytes. h2Conn retains encoding context and next call of EncodeHeader will be performed using the same encoding context.

func (*Http2Conn) ReadFrame

func (h2Conn *Http2Conn) ReadFrame(t time.Duration) (http2.Frame, error)

ReadFrame reads a complete HTTP/2 frame from underlying connection. This function blocks until a complete frame is received or timeout t is expired. The returned http2.Frame must not be used after next ReadFrame call.

type Logger added in v1.2.0

type Logger struct {
	IndentLevel int
}

func (*Logger) Clear added in v1.2.0

func (log *Logger) Clear()

func (*Logger) LevelDown added in v1.2.0

func (log *Logger) LevelDown()

func (*Logger) LevelUp added in v1.2.0

func (log *Logger) LevelUp()

func (*Logger) ResetColor added in v1.2.0

func (Log *Logger) ResetColor()

func (*Logger) SetColor added in v1.2.0

func (Log *Logger) SetColor(color string)

func (*Logger) Write added in v1.2.0

func (log *Logger) Write(format string, a ...interface{})

func (*Logger) WriteBlank added in v1.2.0

func (log *Logger) WriteBlank()

type Result

type Result interface {
	String() string
}

type ResultConnectionClose

type ResultConnectionClose struct{}

func (*ResultConnectionClose) String

func (rcc *ResultConnectionClose) String() string

type ResultError

type ResultError struct {
	Error error
}

func (*ResultError) String

func (re *ResultError) String() string

type ResultFrame

type ResultFrame struct {
	Length  uint32
	Type    http2.FrameType
	Flags   http2.Flags
	ErrCode http2.ErrCode
}

func CreateResultFrame added in v1.1.0

func CreateResultFrame(f http2.Frame) (rf *ResultFrame)

func (*ResultFrame) String

func (rf *ResultFrame) String() string

type ResultSkipped

type ResultSkipped struct {
	Reason string
}

func (*ResultSkipped) String

func (rs *ResultSkipped) String() string

type ResultStreamClose

type ResultStreamClose struct{}

func (*ResultStreamClose) String

func (rsc *ResultStreamClose) String() string

type ResultTestTimeout

type ResultTestTimeout struct{}

func (*ResultTestTimeout) String

func (ttr *ResultTestTimeout) String() string

type RunMode

type RunMode int
const (
	ModeAll       RunMode = 0
	ModeGroupOnly RunMode = 1
	ModeSkip      RunMode = 2
)

type TcpConn

type TcpConn struct {
	// contains filtered or unexported fields
}

func CreateTcpConn

func CreateTcpConn(ctx *Context) *TcpConn

type Test

type Test interface {
	Run(*Context)
}

type TestCase

type TestCase struct {
	Desc string
	Spec string
	// contains filtered or unexported fields
}

func NewTestCase

func NewTestCase(desc, spec string, handler func(*Context) (bool, []Result, Result)) *TestCase

func (*TestCase) HandleFunc

func (tc *TestCase) HandleFunc(handler func(*Context) (bool, []Result, Result))

func (*TestCase) PrintEphemeralDesc

func (tc *TestCase) PrintEphemeralDesc()

func (*TestCase) PrintFail added in v1.1.0

func (tc *TestCase) PrintFail(expected []Result, actual Result)

func (*TestCase) PrintPass added in v1.1.0

func (tc *TestCase) PrintPass()

func (*TestCase) PrintSkipped

func (tc *TestCase) PrintSkipped(actual Result)

func (*TestCase) Run

func (tc *TestCase) Run(ctx *Context) TestResult

type TestGroup

type TestGroup struct {
	Section string
	Name    string
	// contains filtered or unexported fields
}

func ConnectionErrorHandlingTestGroup

func ConnectionErrorHandlingTestGroup(ctx *Context) *TestGroup

func ConnectionSpecificHeaderFieldsTestGroup

func ConnectionSpecificHeaderFieldsTestGroup(ctx *Context) *TestGroup

func ContinuationTestGroup

func ContinuationTestGroup(ctx *Context) *TestGroup

func DataTestGroup

func DataTestGroup(ctx *Context) *TestGroup

func DefinedSettingsParametersTestGroup

func DefinedSettingsParametersTestGroup(ctx *Context) *TestGroup

func ErrorHandlingTestGroup

func ErrorHandlingTestGroup(ctx *Context) *TestGroup

func ExtendingHttp2TestGroup

func ExtendingHttp2TestGroup(ctx *Context) *TestGroup

func FrameSizeTestGroup

func FrameSizeTestGroup(ctx *Context) *TestGroup

func GoawayTestGroup

func GoawayTestGroup(ctx *Context) *TestGroup

func HeaderCompressionAndDecompressionTestGroup

func HeaderCompressionAndDecompressionTestGroup(ctx *Context) *TestGroup

func HeadersTestGroup

func HeadersTestGroup(ctx *Context) *TestGroup

func Http2ConnectionPrefaceTestGroup

func Http2ConnectionPrefaceTestGroup(ctx *Context) *TestGroup

func HttpHeaderFieldsTestGroup

func HttpHeaderFieldsTestGroup(ctx *Context) *TestGroup

func HttpRequestResponseExchangeTestGroup

func HttpRequestResponseExchangeTestGroup(ctx *Context) *TestGroup

func InitialFlowControlWindowSizeTestGroup

func InitialFlowControlWindowSizeTestGroup(ctx *Context) *TestGroup

func MalformedRequestsAndResponsesTestGroup

func MalformedRequestsAndResponsesTestGroup(ctx *Context) *TestGroup

func NewTestGroup

func NewTestGroup(section, name string) *TestGroup

func PingTestGroup

func PingTestGroup(ctx *Context) *TestGroup

func PriorityTestGroup

func PriorityTestGroup(ctx *Context) *TestGroup

func PseudoHeaderFieldsTestGroup

func PseudoHeaderFieldsTestGroup(ctx *Context) *TestGroup

func RequestPseudoHeaderFieldsTestGroup

func RequestPseudoHeaderFieldsTestGroup(ctx *Context) *TestGroup

func RstStreamTestGroup

func RstStreamTestGroup(ctx *Context) *TestGroup

func ServerPushTestGroup

func ServerPushTestGroup(ctx *Context) *TestGroup

func SettingsTestGroup

func SettingsTestGroup(ctx *Context) *TestGroup

func StreamConcurrencyTestGroup

func StreamConcurrencyTestGroup(ctx *Context) *TestGroup

func StreamDependenciesTestGroup added in v1.0.1

func StreamDependenciesTestGroup(ctx *Context) *TestGroup

func StreamIdentifiersTestGroup

func StreamIdentifiersTestGroup(ctx *Context) *TestGroup

func StreamPriorityTestGroup added in v1.0.1

func StreamPriorityTestGroup(ctx *Context) *TestGroup

func StreamStatesTestGroup

func StreamStatesTestGroup(ctx *Context) *TestGroup

func TheFlowControlWindowTestGroup

func TheFlowControlWindowTestGroup(ctx *Context) *TestGroup

func WindowUpdateTestGroup

func WindowUpdateTestGroup(ctx *Context) *TestGroup

func (*TestGroup) AddTestCase

func (tg *TestGroup) AddTestCase(testCase *TestCase)

func (*TestGroup) AddTestGroup

func (tg *TestGroup) AddTestGroup(testGroup *TestGroup)

func (*TestGroup) CountFailed

func (tg *TestGroup) CountFailed() int

func (*TestGroup) CountSkipped

func (tg *TestGroup) CountSkipped() int

func (*TestGroup) CountTestCases

func (tg *TestGroup) CountTestCases() int

func (*TestGroup) PrintFailedTestCase

func (tg *TestGroup) PrintFailedTestCase(ctx *Context)

PrintFailedTestCase prints failed TestCase results under this TestGroup.

func (*TestGroup) PrintFooter

func (tg *TestGroup) PrintFooter()

func (*TestGroup) PrintHeader

func (tg *TestGroup) PrintHeader()

func (*TestGroup) Run

func (tg *TestGroup) Run(ctx *Context) bool

type TestResult

type TestResult int
const (
	Failed TestResult = iota
	Skipped
	Passed
)

TestResult indicates the result of test case

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL