Skip to content
Snippets Groups Projects

Refactor the login handler

Merged ale requested to merge better-login into master
Files
23
+ 0
32
package httputil
import (
"encoding/gob"
"net/http"
"testing"
"time"
"github.com/gorilla/sessions"
)
type mySession struct {
Data string
}
func init() {
gob.Register(&mySession{})
}
func TestExpiringSession(t *testing.T) {
store := sessions.NewCookieStore()
req, _ := http.NewRequest("GET", "http://localhost/", nil)
httpsess, err := GetExpiringSession(req, store, "testkey", 60*time.Second)
if err != nil {
t.Errorf("store.Get error: %v", err)
}
if _, ok := httpsess.Values["mykey"].(*mySession); ok {
t.Fatal("got a session without any data")
}
}
Loading