commit042130f11cAuthor: Stian Aune <post@stian-aune.com> Date: Wed Apr 10 22:16:14 2019 +0200 Done? commit3089c6f8beAuthor: Stian Aune <post@stian-aune.com> Date: Wed Mar 27 22:20:07 2019 +0100 Bugfix + some unit tests bc why not? commit38f874b553Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 26 22:14:22 2019 +0100 Front page. commit5bdf2a0c48Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:10:57 2019 +0100 Rename groups and stuff. commit3130710b19Merge:118a21afa98a0bAuthor: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:06:16 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit118a21ad42Author: Stian Aune <post@stian-aune.com> Date: Thu Mar 7 21:06:02 2019 +0100 I can a lot of things. commit089ee68169Merge:0a6cc16f27c0a3Author: Stian Aune <post@stian-aune.com> Date: Tue Mar 5 22:13:41 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit0a6cc16e0fAuthor: Stian Aune <post@stian-aune.com> Date: Tue Mar 5 22:13:31 2019 +0100 More stuff. commit1ef2623637Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:59:23 2019 +0100 Add/remove group. commit59240ce22dMerge:537e86ce11ba33Author: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:15:06 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit537e86ccedAuthor: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:14:55 2019 +0100 For reals. commitde5fb0d16dAuthor: Stian Aune <post@stian-aune.com> Date: Sun Mar 3 21:14:30 2019 +0100 Modal cleanup + light page. commit01daa28000Author: Stian Aune <post@stian-aune.com> Date: Sun Feb 24 00:27:36 2019 +0100 Hmm... commitbe2fe56e62Merge:99867a522dddc7Author: Stian Aune <post@stian-aune.com> Date: Sat Feb 23 15:16:07 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit99867a5fd6Author: Stian Aune <post@stian-aune.com> Date: Sat Feb 23 15:16:02 2019 +0100 WIP. commitd82bbf53f8Author: Stian Aune <post@stian-aune.com> Date: Tue Feb 19 21:37:59 2019 +0100 WIP. commit7ed6d2148dAuthor: Stian Aune <mail@stian-aune.com> Date: Sun Feb 10 13:30:53 2019 +0100 Stuffs. commitee9a3d485eAuthor: Stian Aune <mail@stian-aune.com> Date: Sun Feb 10 12:29:47 2019 +0100 Bleurgh. commit59ef68ad8fAuthor: Stian Aune <post@stian-aune.com> Date: Thu Feb 7 21:15:37 2019 +0100 Thursday night commit. commitee3ff50342Merge:daf071ae644f48Author: Stian Aune <post@stian-aune.com> Date: Wed Feb 6 22:02:37 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commitdaf071a442Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:56:45 2019 +0100 Rewrote light tests. commitedffa49d18Merge:83052a28c302ecAuthor: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:31:26 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit83052a2ab8Author: Stian Aune <post@stian-aune.com> Date: Mon Feb 4 20:31:22 2019 +0100 Blah. commitaec6cd0b7dMerge:e6fefb50503f79Author: Stian Aune <post@stian-aune.com> Date: Tue Jan 29 21:06:24 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commite6fefb5bd1Merge:97f7a78eca8a30Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 28 22:44:19 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit97f7a78f3fMerge:195738d174b818Author: Stian Aune <post@stian-aune.com> Date: Sun Jan 13 13:20:10 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commit195738d6edMerge:a2f2c2b2e3e120Author: Stian Aune <post@stian-aune.com> Date: Sat Jan 12 17:24:00 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commita2f2c2b0bcMerge:edd629e9004f2fAuthor: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 20:58:37 2019 +0100 Merge remote-tracking branch 'origin/master' into webui commitedd629eb39Author: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 20:58:32 2019 +0100 More stuff. commit206d5005dbAuthor: Stian Aune <post@stian-aune.com> Date: Mon Jan 7 19:11:03 2019 +0100 Cleanup.
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
package models_test
|
|
|
|
import (
|
|
"context"
|
|
"git.aiterp.net/lucifer/lucifer/models"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSession_GenerateID_Works(t *testing.T) {
|
|
session := &models.Session{}
|
|
|
|
err := session.GenerateID()
|
|
|
|
assert.Nil(t, err)
|
|
}
|
|
|
|
func TestSession_Cookie_IsCorrect(t *testing.T) {
|
|
sessID := "testId"
|
|
expiry := time.Now().AddDate(0, 0, 2)
|
|
|
|
session := &models.Session{
|
|
ID: sessID,
|
|
UserID: 0,
|
|
Expires: expiry,
|
|
}
|
|
|
|
cookie := session.Cookie()
|
|
|
|
assert.Equal(t, sessID, cookie.Value)
|
|
assert.Equal(t, expiry, cookie.Expires)
|
|
}
|
|
|
|
func TestSession_Expired_BeforeExpiry(t *testing.T) {
|
|
session := &models.Session{
|
|
ID: "12345",
|
|
UserID: 0,
|
|
Expires: time.Now().AddDate(0, 0, 1),
|
|
}
|
|
|
|
assert.False(t, session.Expired())
|
|
}
|
|
|
|
func TestSession_Expired_AfterExpiry(t *testing.T) {
|
|
session := &models.Session{
|
|
ID: "12345",
|
|
UserID: 0,
|
|
Expires: time.Now().AddDate(0, 0, -1),
|
|
}
|
|
|
|
assert.True(t, session.Expired())
|
|
}
|
|
|
|
func TestSessionFromContext_InContext(t *testing.T) {
|
|
session := &models.Session{
|
|
ID: "12345",
|
|
UserID: 0,
|
|
Expires: time.Now().AddDate(0, 0, 1),
|
|
}
|
|
|
|
ctx := session.InContext(context.Background())
|
|
|
|
session2 := models.SessionFromContext(ctx)
|
|
|
|
assert.Equal(t, session2, session)
|
|
}
|
|
|
|
func TestSessionFromContext_Empty(t *testing.T) {
|
|
session := models.SessionFromContext(context.Background())
|
|
|
|
assert.Nil(t, session)
|
|
} |