mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 09:57:33 +00:00
fix(sessions): add an expiration date filter to list sessions api (#10384)
# Which Problems Are Solved The deletion of expired sessions does not go through even though a success response is returned to the user. These expired and supposedly deleted (to the user) sessions are then returned when the `ListSessions` API is called. This PR fixes this issue by: 1. Allowing deletion of expired sessions 2. Providing an `expiration_date` filter in `ListSession` API to filter sessions by expiration date # How the Problems Are Solved 1. Remove expired session check during deletion 2. Add an `expiration_date` filter to the `ListSession` API # Additional Changes N/A # Additional Context - Closes #10045 --------- Co-authored-by: Marco A. <marco@zitadel.com>
This commit is contained in:

committed by
Stefan Benz

parent
a2938416d5
commit
f13380954f
@@ -930,6 +930,27 @@ func TestServer_DeleteSession_with_permission(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestServer_DeleteSession_expired(t *testing.T) {
|
||||
createResp, err := Client.CreateSession(LoginCTX, &session.CreateSessionRequest{
|
||||
Lifetime: durationpb.New(5 * time.Second),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// wait until the token expires
|
||||
time.Sleep(10 * time.Second)
|
||||
_, err = Client.DeleteSession(Instance.WithAuthorizationToken(context.Background(), integration.UserTypeOrgOwner), &session.DeleteSessionRequest{
|
||||
SessionId: createResp.GetSessionId(),
|
||||
SessionToken: gu.Ptr(createResp.GetSessionToken()),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// get session should return an error
|
||||
sessionResp, err := Client.GetSession(Instance.WithAuthorizationToken(context.Background(), integration.UserTypeOrgOwner),
|
||||
&session.GetSessionRequest{SessionId: createResp.GetSessionId()})
|
||||
require.Error(t, err)
|
||||
require.Nil(t, sessionResp)
|
||||
}
|
||||
|
||||
func Test_ZITADEL_API_missing_authentication(t *testing.T) {
|
||||
// create new, empty session
|
||||
createResp, err := Client.CreateSession(LoginCTX, &session.CreateSessionRequest{})
|
||||
|
Reference in New Issue
Block a user