bug(session): Allow only valid state transitions

This commit is contained in:
Irena Rindos committed 2022-01-12 16:01:49 -05:00
1 parent f8b2e99e11
commit edae7c899f
15 files changed
+441 -11

No files matched your search

+6 -5
View File
@@ -22,6 +22,7 @@ func TestState_Create(t *testing.T) {
sessionId string
status Status
}
tests := []struct {
name string
args args
@@ -35,11 +36,11 @@ func TestState_Create(t *testing.T) {
name: "valid",
args: args{
sessionId: session.PublicId,
status: StatusPending,
status: StatusActive,
},
want: &State{
SessionId: session.PublicId,
Status: StatusPending,
Status: StatusActive,
},
create: true,
},
@@ -161,7 +162,7 @@ func TestState_Clone(t *testing.T) {
t.Run("valid", func(t *testing.T) {
assert := assert.New(t)
s := TestDefaultSession(t, conn, wrapper, iamRepo)
state := TestState(t, conn, s.PublicId, StatusPending)
state := TestState(t, conn, s.PublicId, StatusActive)
cp := state.Clone()
assert.Equal(cp.(*State), state)
})
@@ -169,8 +170,8 @@ func TestState_Clone(t *testing.T) {
assert := assert.New(t)
s := TestDefaultSession(t, conn, wrapper, iamRepo)
s2 := TestDefaultSession(t, conn, wrapper, iamRepo)
state := TestState(t, conn, s.PublicId, StatusPending)
state2 := TestState(t, conn, s2.PublicId, StatusPending)
state := TestState(t, conn, s.PublicId, StatusActive)
state2 := TestState(t, conn, s2.PublicId, StatusActive)
cp := state.Clone()
assert.NotEqual(cp.(*State), state2)