mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
a18e09b613
* Simplify fleetctl implementation and improve testing * Add a few more * Handle not founds better * Fix tests * Check that logout ds func is called
30 lines
628 B
Go
30 lines
628 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLogout(t *testing.T) {
|
|
_, ds := runServerWithMockedDS(t)
|
|
|
|
ds.SessionByIDFunc = func(ctx context.Context, id uint) (*fleet.Session, error) {
|
|
return &fleet.Session{
|
|
ID: 333,
|
|
AccessedAt: time.Now(),
|
|
UserID: 123,
|
|
Key: "12344321",
|
|
}, nil
|
|
}
|
|
ds.DestroySessionFunc = func(ctx context.Context, session *fleet.Session) error {
|
|
return nil
|
|
}
|
|
|
|
assert.Equal(t, "", runAppForTest(t, []string{"logout"}))
|
|
assert.True(t, ds.DestroySessionFuncInvoked)
|
|
}
|