(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestHSTS(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | tests := []struct { |
| 17 | Name string |
| 18 | MaxAge int |
| 19 | Options []string |
| 20 | |
| 21 | wantErr bool |
| 22 | expectHeader string |
| 23 | }{ |
| 24 | { |
| 25 | Name: "Empty", |
| 26 | MaxAge: 0, |
| 27 | Options: nil, |
| 28 | }, |
| 29 | { |
| 30 | Name: "NoAge", |
| 31 | MaxAge: 0, |
| 32 | Options: []string{"includeSubDomains"}, |
| 33 | }, |
| 34 | { |
| 35 | Name: "NegativeAge", |
| 36 | MaxAge: -100, |
| 37 | Options: []string{"includeSubDomains"}, |
| 38 | }, |
| 39 | { |
| 40 | Name: "Age", |
| 41 | MaxAge: 1000, |
| 42 | Options: []string{}, |
| 43 | expectHeader: "max-age=1000", |
| 44 | }, |
| 45 | { |
| 46 | Name: "AgeSubDomains", |
| 47 | MaxAge: 1000, |
| 48 | // Mess with casing |
| 49 | Options: []string{"INCLUDESUBDOMAINS"}, |
| 50 | expectHeader: "max-age=1000; includeSubDomains", |
| 51 | }, |
| 52 | { |
| 53 | Name: "AgePreload", |
| 54 | MaxAge: 1000, |
| 55 | Options: []string{"Preload"}, |
| 56 | expectHeader: "max-age=1000; preload", |
| 57 | }, |
| 58 | { |
| 59 | Name: "AllOptions", |
| 60 | MaxAge: 1000, |
| 61 | Options: []string{"preload", "includeSubDomains"}, |
| 62 | expectHeader: "max-age=1000; preload; includeSubDomains", |
| 63 | }, |
| 64 | |
| 65 | // Error values |
| 66 | { |
| 67 | Name: "BadOption", |
| 68 | MaxAge: 100, |
| 69 | Options: []string{"not-valid"}, |
| 70 | wantErr: true, |
nothing calls this directly
no test coverage detected