func TestDecodeCachedRequest(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	assert.Logf("testing decode a request token using a cache")
	key := []byte("secret")
	claimsIn := initClaims()
	jwtIn, err := jwt.Encode(claimsIn, key, jwt.HS512)
	assert.Nil(err)
	// Setup the test server.
	mux := newMultiplexer(assert)
	ts := restaudit.StartServer(mux, assert)
	defer ts.Close()
	asserter := newDecodeAsserter(assert, true)
	err = mux.Register("test", "jwt", newTestHandler("jwt", asserter))
	assert.Nil(err)
	// Perform first test request.
	req := restaudit.NewRequest("GET", "/test/jwt/1234567890")
	req.AddHeader(restaudit.HeaderAccept, restaudit.ApplicationJSON)
	req.SetRequestProcessor(func(req *http.Request) *http.Request {
		return jwt.AddToRequest(req, jwtIn)
	})
	resp := ts.DoRequest(req)
	claimsOut := jwt.Claims{}
	resp.AssertUnmarshalledBody(&claimsOut)
	assert.Equal(claimsOut, claimsIn)
	// Perform second test request.
	resp = ts.DoRequest(req)
	claimsOut = jwt.Claims{}
	resp.AssertUnmarshalledBody(&claimsOut)
	assert.Equal(claimsOut, claimsIn)
}
// TestDecodeCachedRequest tests the decoding of a token
// in a handler including usage of the cache.
TestDecodeCachedRequest tests the decoding of a token
in a handler including usage of the cache.
// TestDecodeCachedRequest tests the decoding of a token // in a handler including usage of the cache .
func TestDecodeCachedRequest(t *testing.T) {
	assert := audit.NewTestingAssertion(t, true)
	assert.Logf("testing decode a request token using a cache")
	key := []byte("secret")
	claimsIn := initClaims()
	jwtIn, err := jwt.Encode(claimsIn, key, jwt.HS512)
	assert.Nil(err)
	mux := newMultiplexer(assert)
	ts := restaudit.StartServer(mux, assert)
	defer ts.Close()
	asserter := newDecodeAsserter(assert, true)
	err = mux.Register("test", "jwt", newTestHandler("jwt", asserter))
	assert.Nil(err)
	req := restaudit.NewRequest("GET", "/test/jwt/1234567890")
	req.AddHeader(restaudit.HeaderAccept, restaudit.ApplicationJSON)
	req.SetRequestProcessor(func(req *http.Request) *http.Request {
		return jwt.AddToRequest(req, jwtIn)
	})
	resp := ts.DoRequest(req)
	claimsOut := jwt.Claims{}
	resp.AssertUnmarshalledBody(&claimsOut)
	assert.Equal(claimsOut, claimsIn)
	resp = ts.DoRequest(req)
	claimsOut = jwt.Claims{}
	resp.AssertUnmarshalledBody(&claimsOut)
	assert.Equal(claimsOut, claimsIn)
}
func TestDecodeCachedRequest ( t * testing . T ) { assert := audit . NewTestingAssertion ( t , true ) assert . Logf ( " " ) key := [ ] byte ( " " ) claimsIn := initClaims ( ) jwtIn , err := jwt . Encode ( claimsIn , key , jwt . HS512 ) assert . Nil ( err ) mux := newMultiplexer ( assert ) ts := restaudit . StartServer ( mux , assert ) defer ts . Close ( ) asserter := newDecodeAsserter ( assert , true ) err = mux . Register ( " " , " " , newTestHandler ( " " , asserter ) ) assert . Nil ( err ) req := restaudit . NewRequest ( " " , " " ) req . AddHeader ( restaudit . HeaderAccept , restaudit . ApplicationJSON ) req . SetRequestProcessor ( func ( req * http . Request ) * http . Request { return jwt . AddToRequest ( req , jwtIn ) } ) resp := ts . DoRequest ( req ) claimsOut := jwt . Claims { } resp . AssertUnmarshalledBody ( & claimsOut ) assert . Equal ( claimsOut , claimsIn ) resp = ts . DoRequest ( req ) claimsOut = jwt . Claims { } resp . AssertUnmarshalledBody ( & claimsOut ) assert . Equal ( claimsOut , claimsIn ) }
TestDecodeCachedRequest tests the decoding of a token
in a handler including usage of the cache.
TestDecodeCachedRequest tests the decoding of a token in a handler including usage of the cache .
// Setup the test server. // Perform first test request. // Perform second test request.