From a5f5009f9db77ef6921711bd15698fb8c640173e Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Tue, 17 Feb 2026 11:13:05 +0100 Subject: [PATCH] chore: change naming --- .../internal/backchannellogout/backchannellogout.go | 11 ++++++++--- .../backchannellogout/backchannellogout_test.go | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout.go b/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout.go index 306febd0c..fb5c15ff3 100644 --- a/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout.go +++ b/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout.go @@ -26,13 +26,17 @@ var ErrInvalidSessionOrSubject = errors.New("invalid session or subject") func NewSuSe(key string) (SuSe, error) { var subject, session string switch keys := strings.Split(strings.Join(strings.Fields(key), ""), "."); { + // key: '.session' case len(keys) == 2 && keys[0] == "" && keys[1] != "": session = keys[1] + // key: 'subject.' case len(keys) == 2 && keys[0] != "" && keys[1] == "": subject = keys[0] + // key: 'subject.session' case len(keys) == 2 && keys[0] != "" && keys[1] != "": subject = keys[0] session = keys[1] + // key: 'session' case len(keys) == 1 && keys[0] != "": session = keys[0] default: @@ -46,8 +50,8 @@ func NewSuSe(key string) (SuSe, error) { type LogoutMode int const ( - // LogoutModeUnknown is used when the logout mode cannot be determined - LogoutModeUnknown LogoutMode = iota + // LogoutModeUndefined is used when the logout mode cannot be determined + LogoutModeUndefined LogoutMode = iota // LogoutModeSession is used when the logout mode is determined by the session id LogoutModeSession // LogoutModeSubject is used when the logout mode is determined by the subject @@ -62,7 +66,7 @@ func GetLogoutMode(suse SuSe) LogoutMode { case suse.Subject != "": return LogoutModeSubject default: - return LogoutModeUnknown + return LogoutModeUndefined } } @@ -91,6 +95,7 @@ func GetLogoutRecords(suse SuSe, mode LogoutMode, store microstore.Store) ([]*mi return nil, fmt.Errorf("%w: cannot determine logout mode", ErrSuspiciousCacheResult) } + // the go micro memory store requires a limit to work, why??? records, err := store.Read(key, append(opts, microstore.ReadLimit(1000))...) if err != nil { return nil, err diff --git a/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout_test.go b/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout_test.go index 238323c72..d442f0618 100644 --- a/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout_test.go +++ b/services/proxy/pkg/staticroutes/internal/backchannellogout/backchannellogout_test.go @@ -107,7 +107,7 @@ func TestGetLogoutMode(t *testing.T) { { name: "key variation: 'empty'", suSe: SuSe{Session: "", Subject: ""}, - want: LogoutModeUnknown, + want: LogoutModeUndefined, }, } @@ -155,7 +155,7 @@ func TestGetLogoutRecords(t *testing.T) { { name: "fails if mode is unknown", suSe: SuSe{Session: "session-a"}, - mode: LogoutModeUnknown, + mode: LogoutModeUndefined, store: func(t *testing.T) store.Store { return sessionStore }, @@ -192,7 +192,7 @@ func TestGetLogoutRecords(t *testing.T) { store: func(t *testing.T) store.Store { s := mocks.NewStore(t) s.EXPECT().Read(mock.Anything, mock.Anything).Return([]*store.Record{ - &store.Record{Key: "invalid.record.key"}, + {Key: "invalid.record.key"}, }, nil) return s },