github.com/avenga/couper@v1.12.2/server/writer/cookies_internal_test.go (about) 1 package writer 2 3 import ( 4 "net/http" 5 "reflect" 6 "testing" 7 ) 8 9 func TestCookies_StripSecureCookies(t *testing.T) { 10 header := http.Header{} 11 12 header.Add(setCookieHeader, "name=1; HttpOnly") 13 header.Add(setCookieHeader, "name=2; Path=path; Secure; HttpOnly") 14 header.Add(setCookieHeader, "name=2; Path=path; Secure; HttpOnly;") 15 header.Add(setCookieHeader, "name=3; Path=path; HttpOnly; Secure;") 16 header.Add(setCookieHeader, "name=4; Path=path; HttpOnly; secure") 17 header.Add(setCookieHeader, "name=secure; Path=path; HttpOnly") 18 header.Add(setCookieHeader, "name=Secure; Path=path; HttpOnly;") 19 20 stripSecureCookies(header) 21 22 exp := http.Header{} 23 exp.Add(setCookieHeader, "name=1; HttpOnly") 24 exp.Add(setCookieHeader, "name=2; Path=path; HttpOnly") 25 exp.Add(setCookieHeader, "name=2; Path=path; HttpOnly") 26 exp.Add(setCookieHeader, "name=3; Path=path; HttpOnly") 27 exp.Add(setCookieHeader, "name=4; Path=path; HttpOnly") 28 exp.Add(setCookieHeader, "name=secure; Path=path; HttpOnly") 29 exp.Add(setCookieHeader, "name=Secure; Path=path; HttpOnly;") 30 31 if !reflect.DeepEqual(header, exp) { 32 t.Errorf("Expected \n'%v', got: \n'%v'", exp, header) 33 } 34 }