summaryrefslogtreecommitdiff
path: root/store_test.go
diff options
context:
space:
mode:
authorswh <swhbox@foxmail.com>2017-04-20 09:44:54 +0300
committerswh <swhbox@foxmail.com>2017-04-20 09:44:54 +0300
commit793a11a5b02a3dded19b557be93d2732c3aad9f0 (patch)
tree17696eced7a03f9de2a068110df0fc7c4c6520d9 /store_test.go
parent7ce48c6de5e67f5ec9aa46e6cad2432addb49149 (diff)
update
Diffstat (limited to 'store_test.go')
-rw-r--r--store_test.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/store_test.go b/store_test.go
deleted file mode 100644
index 022acba..0000000
--- a/store_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package sessions
-
-import (
- "encoding/base64"
- "net/http"
- "net/http/httptest"
- "testing"
-)
-
-// Test for GH-8 for CookieStore
-func TestGH8CookieStore(t *testing.T) {
- originalPath := "/"
- store := NewCookieStore()
- store.Options.Path = originalPath
- req, err := http.NewRequest("GET", "http://www.example.com", nil)
- if err != nil {
- t.Fatal("failed to create request", err)
- }
-
- session, err := store.New(req, "hello")
- if err != nil {
- t.Fatal("failed to create session", err)
- }
-
- store.Options.Path = "/foo"
- if session.Options.Path != originalPath {
- t.Fatalf("bad session path: got %q, want %q", session.Options.Path, originalPath)
- }
-}
-
-// Test for GH-8 for FilesystemStore
-func TestGH8FilesystemStore(t *testing.T) {
- originalPath := "/"
- store := NewFilesystemStore("")
- store.Options.Path = originalPath
- req, err := http.NewRequest("GET", "http://www.example.com", nil)
- if err != nil {
- t.Fatal("failed to create request", err)
- }
-
- session, err := store.New(req, "hello")
- if err != nil {
- t.Fatal("failed to create session", err)
- }
-
- store.Options.Path = "/foo"
- if session.Options.Path != originalPath {
- t.Fatalf("bad session path: got %q, want %q", session.Options.Path, originalPath)
- }
-}
-
-// Test for GH-2.
-func TestGH2MaxLength(t *testing.T) {
- store := NewFilesystemStore("", []byte("some key"))
- req, err := http.NewRequest("GET", "http://www.example.com", nil)
- if err != nil {
- t.Fatal("failed to create request", err)
- }
- w := httptest.NewRecorder()
-
- session, err := store.New(req, "my session")
- session.Values["big"] = make([]byte, base64.StdEncoding.DecodedLen(4096*2))
- err = session.Save(req, w)
- if err == nil {
- t.Fatal("expected an error, got nil")
- }
-
- store.MaxLength(4096 * 3) // A bit more than the value size to account for encoding overhead.
- err = session.Save(req, w)
- if err != nil {
- t.Fatal("failed to Save:", err)
- }
-}