MCPcopy Index your code
hub / github.com/unrolled/secure / TestStsHeaderWithSSLForRequestOnly

Function TestStsHeaderWithSSLForRequestOnly

secure_test.go:576–591  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

574}
575
576func TestStsHeaderWithSSLForRequestOnly(t *testing.T) {
577 s := New(Options{
578 SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"},
579 STSSeconds: 315360000,
580 })
581
582 res := httptest.NewRecorder()
583 req, _ := http.NewRequestWithContext(context.Background(), http.MethodGet, "/foo", nil)
584 req.URL.Scheme = httpSchema
585 req.Header.Add("X-Forwarded-Proto", "https")
586
587 s.HandlerForRequestOnly(myHandler).ServeHTTP(res, req)
588
589 expect(t, res.Code, http.StatusOK)
590 expect(t, res.Header().Get("Strict-Transport-Security"), "")
591}
592
593func TestStsHeaderInDevMode(t *testing.T) {
594 s := New(Options{

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
expectFunction · 0.85
HandlerForRequestOnlyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…