1
0
mirror of https://github.com/labstack/echo.git synced 2025-04-23 12:18:53 +02:00
echo/middleware/secure_test.go
Vishal Rana f0526349ff Fixed #499
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-05-02 22:41:07 -07:00

33 lines
1.0 KiB
Go

package middleware
// func TestSecureWithConfig(t *testing.T) {
// e := echo.New()
//
// config := SecureConfig{
// STSMaxAge: 100,
// STSIncludeSubdomains: true,
// FrameDeny: true,
// FrameOptionsValue: "",
// ContentTypeNosniff: true,
// XssProtected: true,
// XssProtectionValue: "",
// ContentSecurityPolicy: "default-src 'self'",
// DisableProdCheck: true,
// }
// secure := SecureWithConfig(config)
// h := secure(func(c echo.Context) error {
// return c.String(http.StatusOK, "test")
// })
//
// rq := test.NewRequest(echo.GET, "/", nil)
// rc := test.NewResponseRecorder()
// c := e.NewContext(rq, rc)
// h(c)
//
// assert.Equal(t, "max-age=100; includeSubdomains", rc.Header().Get(stsHeader))
// assert.Equal(t, "DENY", rc.Header().Get(frameOptionsHeader))
// assert.Equal(t, "nosniff", rc.Header().Get(contentTypeHeader))
// assert.Equal(t, xssProtectionValue, rc.Header().Get(xssProtectionHeader))
// assert.Equal(t, "default-src 'self'", rc.Header().Get(cspHeader))
// }