(t *testing.T)
| 205 | } |
| 206 | |
| 207 | func Test_HSTSHeaders(t *testing.T) { |
| 208 | t.Parallel() |
| 209 | |
| 210 | tests := []struct { |
| 211 | name string |
| 212 | scheme string |
| 213 | expected string |
| 214 | config Config |
| 215 | }{ |
| 216 | { |
| 217 | name: "TLS request with max age sets header", |
| 218 | config: Config{HSTSMaxAge: 60}, |
| 219 | scheme: "https", |
| 220 | expected: "max-age=60; includeSubDomains", |
| 221 | }, |
| 222 | { |
| 223 | name: "TLS request with zero max age omits header", |
| 224 | config: Config{HSTSMaxAge: 0}, |
| 225 | scheme: "https", |
| 226 | }, |
| 227 | { |
| 228 | name: "HTTP request with max age omits header", |
| 229 | config: Config{HSTSMaxAge: 60}, |
| 230 | scheme: "http", |
| 231 | }, |
| 232 | } |
| 233 | |
| 234 | for _, tt := range tests { |
| 235 | t.Run(tt.name, func(t *testing.T) { |
| 236 | t.Parallel() |
| 237 | |
| 238 | require.Equal(t, tt.expected, hstsHeaderForRequest(t, &tt.config, tt.scheme)) |
| 239 | }) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | func Test_HSTSHeadersPanicsOnNegativeMaxAge(t *testing.T) { |
| 244 | t.Parallel() |
nothing calls this directly
no test coverage detected