Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
rudream committed Jul 26, 2024
1 parent 20c6e11 commit 8af275c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions tool/tsh/common/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,25 @@ func TestAppCommands(t *testing.T) {
assert.Equal(t, app.name, resp.Header.Get("Server"))

// Verify that the app.session.start event was emitted.
require.EventuallyWithT(t, func(t *assert.CollectT) {
now := time.Now()
ctx := context.Background()
es, _, err := rootAuthServer.SearchEvents(ctx, events.SearchEventsRequest{
From: now.Add(-time.Hour),
To: now.Add(time.Hour),
Order: types.EventOrderDescending,
})
assert.NoError(t, err)

for _, e := range es {
if e.GetCode() == events.AppSessionStartCode {
if app.cluster == "root" && requireMFAType == types.RequireMFAType_OFF {
require.EventuallyWithT(t, func(t *assert.CollectT) {
now := time.Now()
ctx := context.Background()
es, _, err := rootAuthServer.SearchEvents(ctx, events.SearchEventsRequest{
From: now.Add(-time.Hour),
To: now.Add(time.Hour),
Order: types.EventOrderDescending,
EventTypes: []string{events.AppSessionStartEvent},
})
assert.NoError(t, err)

for _, e := range es {
assert.Equal(t, e.(*apievents.AppSessionStart).AppName, app.name)
return
}
}
t.Errorf("failed to find AppSessionStartCode event (0/%d events matched)", len(es))
}, 300*time.Millisecond, 100*time.Millisecond)
t.Errorf("failed to find AppSessionStartCode event (0/%d events matched)", len(es))
}, 100*time.Millisecond, 10*time.Millisecond)
}
// app logout.
err = Run(ctx, []string{
"app",
Expand Down

0 comments on commit 8af275c

Please sign in to comment.