(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestValidateCsrfSession(t *testing.T) { |
| 68 | const name = "oauth2_authentication_csrf" |
| 69 | |
| 70 | type cookie struct { |
| 71 | name string |
| 72 | csrfValue string |
| 73 | sameSite http.SameSite |
| 74 | } |
| 75 | for k, tc := range []struct { |
| 76 | cookies []cookie |
| 77 | csrfValue string |
| 78 | sameSiteLegacyWorkaround bool |
| 79 | expectError bool |
| 80 | sameSite http.SameSite |
| 81 | }{ |
| 82 | { |
| 83 | cookies: []cookie{}, |
| 84 | csrfValue: "CSRF-VALUE", |
| 85 | sameSiteLegacyWorkaround: false, |
| 86 | expectError: true, |
| 87 | }, |
| 88 | { |
| 89 | cookies: []cookie{}, |
| 90 | csrfValue: "CSRF-VALUE", |
| 91 | sameSiteLegacyWorkaround: true, |
| 92 | expectError: true, |
| 93 | }, |
| 94 | { |
| 95 | cookies: []cookie{ |
| 96 | { |
| 97 | name: name, |
| 98 | csrfValue: "WRONG-CSRF-VALUE", |
| 99 | sameSite: http.SameSiteDefaultMode, |
| 100 | }, |
| 101 | }, |
| 102 | csrfValue: "CSRF-VALUE", |
| 103 | sameSiteLegacyWorkaround: false, |
| 104 | expectError: true, |
| 105 | }, |
| 106 | { |
| 107 | cookies: []cookie{ |
| 108 | { |
| 109 | name: name, |
| 110 | csrfValue: "WRONG-CSRF-VALUE", |
| 111 | sameSite: http.SameSiteDefaultMode, |
| 112 | }, |
| 113 | }, |
| 114 | csrfValue: "CSRF-VALUE", |
| 115 | sameSiteLegacyWorkaround: true, |
| 116 | expectError: true, |
| 117 | }, |
| 118 | { |
| 119 | cookies: []cookie{ |
| 120 | { |
| 121 | name: name, |
| 122 | csrfValue: "CSRF-VALUE", |
| 123 | sameSite: http.SameSiteDefaultMode, |
| 124 | }, |
nothing calls this directly
no test coverage detected