func TestHandlerStack(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	// Setup the test server.
	mux := newMultiplexer(assert)
	ts := restaudit.StartServer(mux, assert)
	defer ts.Close()
	err := mux.RegisterAll(rest.Registrations{
		{"authentication", "token", NewTestHandler("auth:token", assert)},
		{"test", "stack", NewAuthHandler("stack:auth", assert)},
		{"test", "stack", NewTestHandler("stack:test", assert)},
	})
	assert.Nil(err)
	// Perform test requests.
	req := restaudit.NewRequest("GET", "/base/test/stack")
	resp := ts.DoRequest(req)
	resp.AssertBodyContains("Resource: token")
	resp.AssertHeaderEquals("Token", "foo")
	req = restaudit.NewRequest("GET", "/base/test/stack")
	req.AddHeader("token", "foo")
	resp = ts.DoRequest(req)
	resp.AssertBodyContains("Resource: stack")
	resp = ts.DoRequest(req)
	resp.AssertBodyContains("Resource: stack")
}
// TestHandlerStack tests a complete handler stack.
TestHandlerStack tests a complete handler stack.
// TestHandlerStack tests a complete handler stack .
func TestHandlerStack(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	mux := newMultiplexer(assert)
	ts := restaudit.StartServer(mux, assert)
	defer ts.Close()
	err := mux.RegisterAll(rest.Registrations{
		{"authentication", "token", NewTestHandler("auth:token", assert)},
		{"test", "stack", NewAuthHandler("stack:auth", assert)},
		{"test", "stack", NewTestHandler("stack:test", assert)},
	})
	assert.Nil(err)
	req := restaudit.NewRequest("GET", "/base/test/stack")
	resp := ts.DoRequest(req)
	resp.AssertBodyContains("Resource: token")
	resp.AssertHeaderEquals("Token", "foo")
	req = restaudit.NewRequest("GET", "/base/test/stack")
	req.AddHeader("token", "foo")
	resp = ts.DoRequest(req)
	resp.AssertBodyContains("Resource: stack")
	resp = ts.DoRequest(req)
	resp.AssertBodyContains("Resource: stack")
}
func TestHandlerStack ( t * testing . T ) { assert := audit . NewTestingAssertion ( t , true ) mux := newMultiplexer ( assert ) ts := restaudit . StartServer ( mux , assert ) defer ts . Close ( ) err := mux . RegisterAll ( rest . Registrations { { " " , " " , NewTestHandler ( " " , assert ) } , { " " , " " , NewAuthHandler ( " " , assert ) } , { " " , " " , NewTestHandler ( " " , assert ) } , } ) assert . Nil ( err ) req := restaudit . NewRequest ( " " , " " ) resp := ts . DoRequest ( req ) resp . AssertBodyContains ( " " ) resp . AssertHeaderEquals ( " " , " " ) req = restaudit . NewRequest ( " " , " " ) req . AddHeader ( " " , " " ) resp = ts . DoRequest ( req ) resp . AssertBodyContains ( " " ) resp = ts . DoRequest ( req ) resp . AssertBodyContains ( " " ) }
TestHandlerStack tests a complete handler stack.
TestHandlerStack tests a complete handler stack .
// Setup the test server. // Perform test requests.