Skip to content

Commit

Permalink
pam/client-dummy: Add support for cancelling isAuthenticated request
Browse files Browse the repository at this point in the history
When waiting we may want to be able to cancel it, so support it
  • Loading branch information
3v1n0 committed Jul 2, 2024
1 parent 3ddd5fe commit 16606b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pam/internal/pam_test/pam-client-dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,14 @@ func (dc *DummyClient) IsAuthenticated(ctx context.Context, in *authd.IARequest,
if dc.isAuthenticatedWantWait == 0 {
return nil, errors.New("no wanted wait provided")
}
time.Sleep(dc.isAuthenticatedWantWait)
select {
case <-time.After(dc.isAuthenticatedWantWait):
case <-ctx.Done():
return &authd.IAResponse{
Access: brokers.AuthCancelled,
Msg: fmt.Sprintf(`{"message": "Cancelled: %s"}`, dc.isAuthenticatedMessage),
}, nil
}
return &authd.IAResponse{
Access: brokers.AuthGranted,
Msg: msg,
Expand Down

0 comments on commit 16606b3

Please sign in to comment.