diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-06-24 17:22:27 +0300 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-06-24 17:22:27 +0300 |
commit | efa9cb909e6c972e779c9e4ccba2aa293809adaf (patch) | |
tree | e4a95af24074b6e75882a95a9c3a0ac66cfaa18d /cookie_test.go | |
parent | Deprecate ByteBuffer in favor of bytebufferpool (diff) | |
download | fasthttp-efa9cb909e6c972e779c9e4ccba2aa293809adaf.tar.gz fasthttp-efa9cb909e6c972e779c9e4ccba2aa293809adaf.tar.bz2 fasthttp-efa9cb909e6c972e779c9e4ccba2aa293809adaf.zip |
Issue #121: Added a test to make sure equal and space chars may be used inside cookie values
Diffstat (limited to 'cookie_test.go')
-rw-r--r-- | cookie_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cookie_test.go b/cookie_test.go index d672d3b..ecf3c1f 100644 --- a/cookie_test.go +++ b/cookie_test.go @@ -6,6 +6,38 @@ import ( "time" ) +func TestCookieValueWithEqualAndSpaceChars(t *testing.T) { + testCookieValueWithEqualAndSpaceChars(t, "sth1", "/", "MTQ2NjU5NTcwN3xfUVduVXk4aG9jSmZaNzNEb1dGa1VjekY1bG9vMmxSWlJBZUN2Q1ZtZVFNMTk2YU9YaWtCVmY1eDRWZXd3M3Q5RTJRZnZMbk5mWklSSFZJcVlXTDhiSFFHWWdpdFVLd1hwbXR2UUN4QlJ1N3BITFpkS3Y4PXzDvPNn6JVDBFB2wYVYPHdkdlZBm6n1_0QB3_GWwE40Tg== ") + testCookieValueWithEqualAndSpaceChars(t, "sth2", "/", "123") + testCookieValueWithEqualAndSpaceChars(t, "sth3", "/", "123 == 1") +} + +func testCookieValueWithEqualAndSpaceChars(t *testing.T, expectedName, expectedPath, expectedValue string) { + var c Cookie + c.SetKey(expectedName) + c.SetPath(expectedPath) + c.SetValue(expectedValue) + + s := c.String() + + var c1 Cookie + if err := c1.Parse(s); err != nil { + t.Fatalf("unexpected error: %s", err) + } + name := c1.Key() + if string(name) != expectedName { + t.Fatalf("unexpected name %q. Expecting %q", name, expectedName) + } + path := c1.Path() + if string(path) != expectedPath { + t.Fatalf("unexpected path %q. Expecting %q", path, expectedPath) + } + value := c1.Value() + if string(value) != expectedValue { + t.Fatalf("unexpected value %q. Expecting %q", value, expectedValue) + } +} + func TestCookieSecureHttpOnly(t *testing.T) { var c Cookie |