mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-31 23:41:09 +02:00
wip
This commit is contained in:
parent
a6577fd570
commit
a80ef11763
11 changed files with 574 additions and 949 deletions
|
@ -15,32 +15,32 @@ func TestDataStore(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
ds := newDataStore()
|
||||
s, u := ds.GetSessionAndUser("S1")
|
||||
s, u := ds.getSessionAndUser("S1")
|
||||
assert.Nil(t, s, "should return a nil session when none exists")
|
||||
assert.Nil(t, u, "should return a nil user when none exists")
|
||||
|
||||
u, ss := ds.GetUserAndSessions("U1")
|
||||
u, ss := ds.getUserAndSessions("U1")
|
||||
assert.Nil(t, u, "should return a nil user when none exists")
|
||||
assert.Empty(t, ss, "should return an empty list of sessions when no user exists")
|
||||
|
||||
s = &session.Session{Id: "S1", UserId: "U1"}
|
||||
ds.PutSession(s)
|
||||
s1, u1 := ds.GetSessionAndUser("S1")
|
||||
ds.putSession(s)
|
||||
s1, u1 := ds.getSessionAndUser("S1")
|
||||
assert.NotNil(t, s1, "should return a non-nil session")
|
||||
assert.False(t, s == s1, "should return different pointers")
|
||||
assert.Empty(t, cmp.Diff(s, s1, protocmp.Transform()), "should be the same as was entered")
|
||||
assert.Nil(t, u1, "should return a nil user when only the session exists")
|
||||
|
||||
ds.PutUser(&user.User{
|
||||
ds.putUser(&user.User{
|
||||
Id: "U1",
|
||||
})
|
||||
_, u1 = ds.GetSessionAndUser("S1")
|
||||
_, u1 = ds.getSessionAndUser("S1")
|
||||
assert.NotNil(t, u1, "should return a user now that it has been added")
|
||||
|
||||
ds.PutSession(&session.Session{Id: "S4", UserId: "U1"})
|
||||
ds.PutSession(&session.Session{Id: "S3", UserId: "U1"})
|
||||
ds.PutSession(&session.Session{Id: "S2", UserId: "U1"})
|
||||
u, ss = ds.GetUserAndSessions("U1")
|
||||
ds.putSession(&session.Session{Id: "S4", UserId: "U1"})
|
||||
ds.putSession(&session.Session{Id: "S3", UserId: "U1"})
|
||||
ds.putSession(&session.Session{Id: "S2", UserId: "U1"})
|
||||
u, ss = ds.getUserAndSessions("U1")
|
||||
assert.NotNil(t, u)
|
||||
assert.Empty(t, cmp.Diff(ss, []*session.Session{
|
||||
{Id: "S1", UserId: "U1"},
|
||||
|
@ -49,9 +49,9 @@ func TestDataStore(t *testing.T) {
|
|||
{Id: "S4", UserId: "U1"},
|
||||
}, protocmp.Transform()), "should return all sessions in id order")
|
||||
|
||||
ds.DeleteSession("S4")
|
||||
ds.deleteSession("S4")
|
||||
|
||||
u, ss = ds.GetUserAndSessions("U1")
|
||||
u, ss = ds.getUserAndSessions("U1")
|
||||
assert.NotNil(t, u)
|
||||
assert.Empty(t, cmp.Diff(ss, []*session.Session{
|
||||
{Id: "S1", UserId: "U1"},
|
||||
|
@ -59,8 +59,8 @@ func TestDataStore(t *testing.T) {
|
|||
{Id: "S3", UserId: "U1"},
|
||||
}, protocmp.Transform()), "should return all sessions in id order")
|
||||
|
||||
ds.DeleteUser("U1")
|
||||
u, ss = ds.GetUserAndSessions("U1")
|
||||
ds.deleteUser("U1")
|
||||
u, ss = ds.getUserAndSessions("U1")
|
||||
assert.Nil(t, u)
|
||||
assert.Empty(t, cmp.Diff(ss, []*session.Session{
|
||||
{Id: "S1", UserId: "U1"},
|
||||
|
@ -68,11 +68,11 @@ func TestDataStore(t *testing.T) {
|
|||
{Id: "S3", UserId: "U1"},
|
||||
}, protocmp.Transform()), "should still return all sessions in id order")
|
||||
|
||||
ds.DeleteSession("S1")
|
||||
ds.DeleteSession("S2")
|
||||
ds.DeleteSession("S3")
|
||||
ds.deleteSession("S1")
|
||||
ds.deleteSession("S2")
|
||||
ds.deleteSession("S3")
|
||||
|
||||
u, ss = ds.GetUserAndSessions("U1")
|
||||
u, ss = ds.getUserAndSessions("U1")
|
||||
assert.Nil(t, u)
|
||||
assert.Empty(t, ss)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue