MCPcopy
hub / github.com/vouch/vouch-proxy / BenchmarkValidateRequestHandler

Function BenchmarkValidateRequestHandler

handlers/validate_test.go:29–62  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

27)
28
29func BenchmarkValidateRequestHandler(b *testing.B) {
30 setUp("/config/testing/handler_email.yml")
31 user := &structs.User{Username: "testuser", Email: "test@example.com", Name: "Test Name"}
32 tokens := structs.PTokens{}
33 customClaims := structs.CustomClaims{}
34
35 userTokenString, err := jwtmanager.NewVPJWT(*user, customClaims, tokens)
36 assert.NoError(b, err)
37
38 c := &http.Cookie{
39 // Name: cfg.Cfg.Cookie.Name + "_1of1",
40 Name: cfg.Cfg.Cookie.Name,
41 Value: userTokenString,
42 Expires: time.Now().Add(1 * time.Hour),
43 }
44
45 handler := jwtmanager.JWTCacheHandler(http.HandlerFunc(ValidateRequestHandler))
46 // handler := http.HandlerFunc(ValidateRequestHandler)
47 ts := httptest.NewServer(handler)
48 defer ts.Close()
49
50 req, err := http.NewRequest("GET", "/validate", nil)
51 if err != nil {
52 b.Fatal(err)
53 }
54 req.Host = "myapp.example.com"
55 req.AddCookie(c)
56 w := httptest.NewRecorder()
57
58 for i := 0; i < b.N; i++ {
59 handler.ServeHTTP(w, req)
60 }
61
62}
63
64func TestValidateRequestHandlerPerf(t *testing.T) {
65 if _, ok := os.LookupEnv("ISTRAVIS"); ok {

Callers

nothing calls this directly

Calls 3

NewVPJWTFunction · 0.92
JWTCacheHandlerFunction · 0.92
setUpFunction · 0.70

Tested by

no test coverage detected