From 27c87617f142fc2361a29b484aa78c5263613404 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 6 Jun 2024 20:58:27 -0400 Subject: [PATCH] consolidate OServiceService --- .mockery.yaml | 12 - cmd/server/main.go | 50 +- config/config.go | 2 +- foodgroup/oservice.go | 243 ++++----- foodgroup/oservice_test.go | 62 ++- server/oscar/bos.go | 2 +- .../mock_oservice_alert_service_test.go | 402 -------------- .../oscar/handler/mock_oservice_bos_test.go | 509 ------------------ .../handler/mock_oservice_chat_nav_test.go | 402 -------------- .../oscar/handler/mock_oservice_chat_test.go | 449 --------------- server/oscar/handler/mock_oservice_test.go | 152 ++++++ server/oscar/handler/oservice.go | 143 +---- server/oscar/handler/oservice_test.go | 30 +- server/oscar/handler/routes.go | 61 +-- wire/snacs.go | 4 - 15 files changed, 378 insertions(+), 2145 deletions(-) delete mode 100644 server/oscar/handler/mock_oservice_alert_service_test.go delete mode 100644 server/oscar/handler/mock_oservice_bos_test.go delete mode 100644 server/oscar/handler/mock_oservice_chat_nav_test.go delete mode 100644 server/oscar/handler/mock_oservice_chat_test.go diff --git a/.mockery.yaml b/.mockery.yaml index 77b4e976..c21fef0e 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -48,18 +48,6 @@ packages: OServiceService: config: filename: "mock_oservice_test.go" - OServiceBOSService: - config: - filename: "mock_oservice_bos_test.go" - OServiceChatService: - config: - filename: "mock_oservice_chat_test.go" - OServiceChatNavService: - config: - filename: "mock_oservice_chat_nav_test.go" - OServiceAlertService: - config: - filename: "mock_oservice_alert_service_test.go" LocateService: config: filename: "mock_locate_test.go" diff --git a/cmd/server/main.go b/cmd/server/main.go index 4099bf10..d2a69fc4 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -55,8 +55,7 @@ func main() { buddyService := foodgroup.NewBuddyService(sessionManager, feedbagStore, adjListBuddyListStore) authService := foodgroup.NewAuthService(cfg, sessionManager, feedbagStore, chatRegistry, adjListBuddyListStore, cookieBaker, buddyService) bartService := foodgroup.NewBARTService(logger, feedbagStore, buddyService) - oServiceService := foodgroup.NewOServiceService(cfg, sessionManager, adjListBuddyListStore, logger, cookieBaker, buddyService) - oServiceServiceForBOS := foodgroup.NewOServiceServiceForBOS(*oServiceService, chatRegistry) + oServiceService := foodgroup.NewOServiceServiceForBOS(cfg, sessionManager, adjListBuddyListStore, logger, cookieBaker, buddyService, chatRegistry) locateService := foodgroup.NewLocateService(sessionManager, feedbagStore, feedbagStore, buddyService) newChatSessMgr := func() foodgroup.SessionManager { return state.NewInMemorySessionManager(logger) } chatNavService := foodgroup.NewChatNavService(logger, chatRegistry, state.NewChatRoom, newChatSessMgr) @@ -68,19 +67,19 @@ func main() { AuthService: authService, Config: cfg, Handler: handler.NewBOSRouter(handler.Handlers{ - AlertHandler: handler.NewAlertHandler(logger), - BARTHandler: handler.NewBARTHandler(logger, bartService), - BuddyHandler: handler.NewBuddyHandler(logger, buddyService), - ChatNavHandler: handler.NewChatNavHandler(chatNavService, logger), - FeedbagHandler: handler.NewFeedbagHandler(logger, feedbagService), - ICBMHandler: handler.NewICBMHandler(logger, icbmService), - LocateHandler: handler.NewLocateHandler(locateService, logger), - OServiceBOSHandler: handler.NewOServiceHandlerForBOS(logger, oServiceService, oServiceServiceForBOS), - PermitDenyHandler: handler.NewPermitDenyHandler(logger, foodgroupService), + AlertHandler: handler.NewAlertHandler(logger), + BARTHandler: handler.NewBARTHandler(logger, bartService), + BuddyHandler: handler.NewBuddyHandler(logger, buddyService), + ChatNavHandler: handler.NewChatNavHandler(chatNavService, logger), + FeedbagHandler: handler.NewFeedbagHandler(logger, feedbagService), + ICBMHandler: handler.NewICBMHandler(logger, icbmService), + LocateHandler: handler.NewLocateHandler(locateService, logger), + OServiceHandler: handler.NewOServiceHandler(logger, oServiceService), + PermitDenyHandler: handler.NewPermitDenyHandler(logger, foodgroupService), }), CookieCracker: cookieBaker, Logger: logger, - OnlineNotifier: oServiceServiceForBOS, + OnlineNotifier: oServiceService, ListenAddr: net.JoinHostPort("", cfg.BOSPort), }.Start() wg.Done() @@ -89,19 +88,18 @@ func main() { logger = logger.With("svc", "CHAT") buddyService := foodgroup.NewBuddyService(nil, feedbagStore, adjListBuddyListStore) authService := foodgroup.NewAuthService(cfg, sessionManager, feedbagStore, chatRegistry, adjListBuddyListStore, cookieBaker, buddyService) - oServiceService := foodgroup.NewOServiceService(cfg, sessionManager, adjListBuddyListStore, logger, cookieBaker, buddyService) chatService := foodgroup.NewChatService(chatRegistry) - oServiceServiceForChat := foodgroup.NewOServiceServiceForChat(*oServiceService, chatRegistry) + oServiceService := foodgroup.NewOServiceServiceForChat(cfg, logger, buddyService, chatRegistry) oscar.ChatServer{ AuthService: authService, Config: cfg, Handler: handler.NewChatRouter(handler.Handlers{ - ChatHandler: handler.NewChatHandler(logger, chatService), - OServiceChatHandler: handler.NewOServiceHandlerForChat(logger, oServiceService, oServiceServiceForChat), + ChatHandler: handler.NewChatHandler(logger, chatService), + OServiceHandler: handler.NewOServiceHandler(logger, oServiceService), }), Logger: logger, - OnlineNotifier: oServiceServiceForChat, + OnlineNotifier: oServiceService, CookieCracker: cookieBaker, }.Start() wg.Done() @@ -111,8 +109,7 @@ func main() { sessionManager := state.NewInMemorySessionManager(logger) buddyService := foodgroup.NewBuddyService(sessionManager, feedbagStore, adjListBuddyListStore) authService := foodgroup.NewAuthService(cfg, sessionManager, feedbagStore, chatRegistry, adjListBuddyListStore, cookieBaker, buddyService) - oServiceService := foodgroup.NewOServiceService(cfg, sessionManager, adjListBuddyListStore, logger, cookieBaker, buddyService) - oServiceServiceForChatNav := foodgroup.NewOServiceServiceForChatNav(*oServiceService, chatRegistry) + oServiceService := foodgroup.NewOServiceServiceForChatNav(cfg, logger, buddyService) newChatSessMgr := func() foodgroup.SessionManager { return state.NewInMemorySessionManager(logger) } chatNavService := foodgroup.NewChatNavService(logger, chatRegistry, state.NewChatRoom, newChatSessMgr) @@ -120,11 +117,11 @@ func main() { AuthService: authService, Config: cfg, Handler: handler.NewChatNavRouter(handler.Handlers{ - ChatNavHandler: handler.NewChatNavHandler(chatNavService, logger), - OServiceChatNavHandler: handler.NewOServiceHandlerForChatNav(logger, oServiceService, oServiceServiceForChatNav), + ChatNavHandler: handler.NewChatNavHandler(chatNavService, logger), + OServiceHandler: handler.NewOServiceHandler(logger, oServiceService), }), Logger: logger, - OnlineNotifier: oServiceServiceForChatNav, + OnlineNotifier: oServiceService, ListenAddr: net.JoinHostPort("", cfg.ChatNavPort), CookieCracker: cookieBaker, }.Start() @@ -135,19 +132,18 @@ func main() { sessionManager := state.NewInMemorySessionManager(logger) buddyService := foodgroup.NewBuddyService(sessionManager, feedbagStore, adjListBuddyListStore) authService := foodgroup.NewAuthService(cfg, sessionManager, feedbagStore, chatRegistry, adjListBuddyListStore, cookieBaker, buddyService) - oServiceService := foodgroup.NewOServiceService(cfg, sessionManager, adjListBuddyListStore, logger, cookieBaker, buddyService) - oServiceServiceForAlert := foodgroup.NewOServiceServiceForAlert(*oServiceService) + oServiceService := foodgroup.NewOServiceServiceForAlert(cfg, logger, buddyService) oscar.BOSServer{ AuthService: authService, Config: cfg, Handler: handler.NewAlertRouter(handler.Handlers{ - AlertHandler: handler.NewAlertHandler(logger), - OServiceAlertHandler: handler.NewOServiceHandlerForAlert(logger, oServiceService, oServiceServiceForAlert), + AlertHandler: handler.NewAlertHandler(logger), + OServiceHandler: handler.NewOServiceHandler(logger, oServiceService), }), CookieCracker: cookieBaker, Logger: logger, - OnlineNotifier: oServiceServiceForAlert, + OnlineNotifier: oServiceService, ListenAddr: net.JoinHostPort("", cfg.AlertPort), }.Start() wg.Done() diff --git a/config/config.go b/config/config.go index 8f07a3ea..3d576f6c 100644 --- a/config/config.go +++ b/config/config.go @@ -3,7 +3,7 @@ package config //go:generate go run github.com/mk6i/retro-aim-server/cmd/config_generator windows settings.bat //go:generate go run github.com/mk6i/retro-aim-server/cmd/config_generator unix settings.env type Config struct { - ApiHost string `envconfig:"API_HOST" require:"true" val:"127.0.0.1" description:"The hostname or address at which the management API listens."` + ApiHost string `envconfig:"API_HOST" require:"true" val:"127.0.0.1" description:"The hostname or address at which the management API listens."` ApiPort string `envconfig:"API_PORT" required:"true" val:"8080" description:"The port that the management API service binds to."` AlertPort string `envconfig:"ALERT_PORT" required:"true" val:"5194" description:"The port that the Alert service binds to."` AuthPort string `envconfig:"AUTH_PORT" required:"true" val:"5190" description:"The port that the auth service binds to."` diff --git a/foodgroup/oservice.go b/foodgroup/oservice.go index 6a0b7fba..f0de2bfa 100644 --- a/foodgroup/oservice.go +++ b/foodgroup/oservice.go @@ -14,34 +14,13 @@ import ( "github.com/mk6i/retro-aim-server/wire" ) -// NewOServiceService creates a new instance of OServiceService. -func NewOServiceService( - cfg config.Config, - messageRelayer MessageRelayer, - legacyBuddyListManager LegacyBuddyListManager, - logger *slog.Logger, - cookieIssuer CookieIssuer, - buddyUpdateBroadcaster BuddyBroadcaster, -) *OServiceService { - return &OServiceService{ - buddyUpdateBroadcaster: buddyUpdateBroadcaster, - cfg: cfg, - cookieIssuer: cookieIssuer, - legacyBuddyListManager: legacyBuddyListManager, - logger: logger, - messageRelayer: messageRelayer, - } -} - // OServiceService provides functionality for the OService food group, which // provides an assortment of services useful across multiple food groups. type OServiceService struct { buddyUpdateBroadcaster BuddyBroadcaster cfg config.Config - cookieIssuer CookieIssuer - legacyBuddyListManager LegacyBuddyListManager logger *slog.Logger - messageRelayer MessageRelayer + foodGroups []uint16 } // ClientVersions informs the server what food group versions the client @@ -490,11 +469,74 @@ func (s OServiceService) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0 func (s OServiceService) RateParamsSubAdd(context.Context, wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd) { } +func (s OServiceService) ServiceRequest(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error) { + return wire.SNACMessage{ + Frame: wire.SNACFrame{ + FoodGroup: wire.OService, + SubGroup: wire.OServiceErr, + RequestID: frame.RequestID, + }, + Body: wire.SNACError{ + Code: wire.ErrorCodeNotSupportedByHost, + }, + }, nil +} + +// ClientOnline informs the server that the client is ready. +func (s OServiceService) ClientOnline(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session) error { + s.logger.DebugContext(ctx, "client is online", "group_versions", bodyIn.GroupVersions) + return nil +} + +// HostOnline initiates the Alert protocol sequence. +// It returns SNAC wire.OServiceHostOnline containing the list of food groups +// supported by the Alert service. +// Alert is provided by BOS in addition to the standalone Alert service. +// AIM 4.x always creates a secondary TCP connection for Alert, whereas 5.x +// can use the existing BOS connection for Alert services. +func (s OServiceService) HostOnline() wire.SNACMessage { + return wire.SNACMessage{ + Frame: wire.SNACFrame{ + FoodGroup: wire.OService, + SubGroup: wire.OServiceHostOnline, + }, + Body: wire.SNAC_0x01_0x03_OServiceHostOnline{ + FoodGroups: s.foodGroups, + }, + } +} + // NewOServiceServiceForBOS creates a new instance of OServiceServiceForBOS. -func NewOServiceServiceForBOS(oserviceService OServiceService, cr *state.ChatRegistry) *OServiceServiceForBOS { +func NewOServiceServiceForBOS( + cfg config.Config, + messageRelayer MessageRelayer, + legacyBuddyListManager LegacyBuddyListManager, + logger *slog.Logger, + cookieIssuer CookieIssuer, + buddyUpdateBroadcaster BuddyBroadcaster, + cr *state.ChatRegistry, +) *OServiceServiceForBOS { return &OServiceServiceForBOS{ - OServiceService: oserviceService, - chatRegistry: cr, + chatRegistry: cr, + cookieIssuer: cookieIssuer, + legacyBuddyListManager: legacyBuddyListManager, + messageRelayer: messageRelayer, + OServiceService: OServiceService{ + buddyUpdateBroadcaster: buddyUpdateBroadcaster, + cfg: cfg, + logger: logger, + foodGroups: []uint16{ + wire.Alert, + wire.Buddy, + wire.ChatNav, + wire.Feedbag, + wire.ICBM, + wire.Locate, + wire.OService, + wire.BART, + wire.PermitDeny, + }, + }, } } @@ -502,7 +544,10 @@ func NewOServiceServiceForBOS(oserviceService OServiceService, cr *state.ChatReg // running on the BOS server. type OServiceServiceForBOS struct { OServiceService - chatRegistry *state.ChatRegistry + chatRegistry *state.ChatRegistry + cookieIssuer CookieIssuer + legacyBuddyListManager LegacyBuddyListManager + messageRelayer MessageRelayer } // chatLoginCookie represents credentials used to authenticate a user chat @@ -622,34 +667,6 @@ func (s OServiceServiceForBOS) ServiceRequest(_ context.Context, sess *state.Ses } } -// HostOnline initiates the BOS protocol sequence. -// It returns SNAC wire.OServiceHostOnline containing the list food groups -// supported by the BOS service. -// ChatNav is provided by BOS in addition to the standalone ChatNav service. -// AIM 4.x always creates a secondary TCP connection for ChatNav, whereas 5.x -// can use the existing BOS connection for ChatNav services. -func (s OServiceServiceForBOS) HostOnline() wire.SNACMessage { - return wire.SNACMessage{ - Frame: wire.SNACFrame{ - FoodGroup: wire.OService, - SubGroup: wire.OServiceHostOnline, - }, - Body: wire.SNAC_0x01_0x03_OServiceHostOnline{ - FoodGroups: []uint16{ - wire.Alert, - wire.Buddy, - wire.ChatNav, - wire.Feedbag, - wire.ICBM, - wire.Locate, - wire.OService, - wire.BART, - wire.PermitDeny, - }, - }, - } -} - // ClientOnline runs when the current user is ready to join. // It announces current user's arrival to users who have the current user on // their buddy list. @@ -674,11 +691,19 @@ func (s OServiceServiceForBOS) ClientOnline(ctx context.Context, _ wire.SNAC_0x0 return nil } -// NewOServiceServiceForChat creates a new instance of OServiceServiceForChat. -func NewOServiceServiceForChat(oserviceService OServiceService, chatRegistry *state.ChatRegistry) *OServiceServiceForChat { +// NewOServiceServiceForChat creates a new instance of NewOServiceServiceForChat. +func NewOServiceServiceForChat(cfg config.Config, logger *slog.Logger, buddyUpdateBroadcaster BuddyBroadcaster, cr *state.ChatRegistry) *OServiceServiceForChat { return &OServiceServiceForChat{ - OServiceService: oserviceService, - chatRegistry: chatRegistry, + chatRegistry: cr, + OServiceService: OServiceService{ + buddyUpdateBroadcaster: buddyUpdateBroadcaster, + cfg: cfg, + logger: logger, + foodGroups: []uint16{ + wire.OService, + wire.Chat, + }, + }, } } @@ -689,30 +714,12 @@ type OServiceServiceForChat struct { chatRegistry *state.ChatRegistry } -// HostOnline initiates the Chat protocol sequence. -// It returns SNAC wire.OServiceHostOnline containing the list of food groups -// supported by the Chat service. -func (s OServiceServiceForChat) HostOnline() wire.SNACMessage { - return wire.SNACMessage{ - Frame: wire.SNACFrame{ - FoodGroup: wire.OService, - SubGroup: wire.OServiceHostOnline, - }, - Body: wire.SNAC_0x01_0x03_OServiceHostOnline{ - FoodGroups: []uint16{ - wire.OService, - wire.Chat, - }, - }, - } -} - // ClientOnline runs when the current user is ready to join the chat. // Trigger the following actions: // - Send current user the chat room metadata // - Announce current user's arrival to other chat room participants // - Send current user the chat room participant list -func (s OServiceServiceForChat) ClientOnline(ctx context.Context, sess *state.Session) error { +func (s OServiceServiceForChat) ClientOnline(ctx context.Context, _ wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session) error { room, chatSessMgr, err := s.chatRegistry.Retrieve(sess.ChatRoomCookie()) if err != nil { return err @@ -723,72 +730,30 @@ func (s OServiceServiceForChat) ClientOnline(ctx context.Context, sess *state.Se return nil } -// NewOServiceServiceForChatNav creates a new instance of OServiceServiceForChat. -func NewOServiceServiceForChatNav(oserviceService OServiceService, chatRegistry *state.ChatRegistry) *OServiceServiceForChatNav { - return &OServiceServiceForChatNav{ - OServiceService: oserviceService, - chatRegistry: chatRegistry, - } -} - -// OServiceServiceForChatNav provides functionality for the OService food group -// running on the Chat server. -type OServiceServiceForChatNav struct { - OServiceService - chatRegistry *state.ChatRegistry -} - -// HostOnline initiates the ChatNav protocol sequence. -// It returns SNAC wire.OServiceHostOnline containing the list of food groups -// supported by the ChatNav service. -// ChatNav is provided by BOS in addition to the standalone ChatNav service. -// AIM 4.x always creates a secondary TCP connection for ChatNav, whereas 5.x -// can use the existing BOS connection for ChatNav services. -func (s OServiceServiceForChatNav) HostOnline() wire.SNACMessage { - return wire.SNACMessage{ - Frame: wire.SNACFrame{ - FoodGroup: wire.OService, - SubGroup: wire.OServiceHostOnline, - }, - Body: wire.SNAC_0x01_0x03_OServiceHostOnline{ - FoodGroups: []uint16{ - wire.ChatNav, - wire.OService, - }, +// NewOServiceServiceForChatNav creates a new instance of OServiceService for +// ChatNav. +func NewOServiceServiceForChatNav(cfg config.Config, logger *slog.Logger, buddyUpdateBroadcaster BuddyBroadcaster) *OServiceService { + return &OServiceService{ + buddyUpdateBroadcaster: buddyUpdateBroadcaster, + cfg: cfg, + logger: logger, + foodGroups: []uint16{ + wire.ChatNav, + wire.OService, }, } } -// NewOServiceServiceForAlert creates a new instance of OServiceServiceForAlert. -func NewOServiceServiceForAlert(oserviceService OServiceService) *OServiceServiceForAlert { - return &OServiceServiceForAlert{ - OServiceService: oserviceService, - } -} - -// OServiceServiceForAlert provides functionality for the OService food group -// running on the Alert server. -type OServiceServiceForAlert struct { - OServiceService -} - -// HostOnline initiates the Alert protocol sequence. -// It returns SNAC wire.OServiceHostOnline containing the list of food groups -// supported by the Alert service. -// Alert is provided by BOS in addition to the standalone Alert service. -// AIM 4.x always creates a secondary TCP connection for Alert, whereas 5.x -// can use the existing BOS connection for Alert services. -func (s OServiceServiceForAlert) HostOnline() wire.SNACMessage { - return wire.SNACMessage{ - Frame: wire.SNACFrame{ - FoodGroup: wire.OService, - SubGroup: wire.OServiceHostOnline, - }, - Body: wire.SNAC_0x01_0x03_OServiceHostOnline{ - FoodGroups: []uint16{ - wire.Alert, - wire.OService, - }, +// NewOServiceServiceForAlert creates a new instance of OServiceService for the Alert +// server. +func NewOServiceServiceForAlert(cfg config.Config, logger *slog.Logger, buddyUpdateBroadcaster BuddyBroadcaster) *OServiceService { + return &OServiceService{ + buddyUpdateBroadcaster: buddyUpdateBroadcaster, + cfg: cfg, + logger: logger, + foodGroups: []uint16{ + wire.Alert, + wire.OService, }, } } diff --git a/foodgroup/oservice_test.go b/foodgroup/oservice_test.go index e989c3e1..bfbc33c1 100644 --- a/foodgroup/oservice_test.go +++ b/foodgroup/oservice_test.go @@ -250,10 +250,7 @@ func TestOServiceServiceForBOS_ServiceRequest(t *testing.T) { // // send input SNAC // - svc := NewOServiceServiceForBOS(OServiceService{ - cfg: tc.cfg, - cookieIssuer: cookieIssuer, - }, chatRegistry) + svc := NewOServiceServiceForBOS(tc.cfg, nil, nil, slog.Default(), cookieIssuer, nil, chatRegistry) outputSNAC, err := svc.ServiceRequest(nil, tc.userSession, tc.inputSNAC.Frame, tc.inputSNAC.Body.(wire.SNAC_0x01_0x04_OServiceServiceRequest)) @@ -385,7 +382,11 @@ func TestSetUserInfoFields(t *testing.T) { })). Return(nil) } - svc := NewOServiceService(config.Config{}, nil, nil, slog.Default(), nil, buddyUpdateBroadcaster) + svc := OServiceService{ + cfg: config.Config{}, + logger: slog.Default(), + buddyUpdateBroadcaster: buddyUpdateBroadcaster, + } outputSNAC, err := svc.SetUserInfoFields(nil, tc.userSession, tc.inputSNAC.Frame, tc.inputSNAC.Body.(wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) assert.ErrorIs(t, err, tc.expectErr) @@ -398,8 +399,10 @@ func TestSetUserInfoFields(t *testing.T) { } func TestOServiceService_RateParamsQuery(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil) + svc := OServiceService{ + cfg: config.Config{}, + logger: slog.Default(), + } have := svc.RateParamsQuery(nil, wire.SNACFrame{RequestID: 1234}) want := wire.SNACMessage{ @@ -1325,7 +1328,7 @@ func TestOServiceService_RateParamsQuery(t *testing.T) { func TestOServiceServiceForBOS_OServiceHostOnline(t *testing.T) { cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceServiceForBOS(*NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil), nil) + svc := NewOServiceServiceForBOS(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil, nil) want := wire.SNACMessage{ Frame: wire.SNACFrame{ @@ -1352,8 +1355,7 @@ func TestOServiceServiceForBOS_OServiceHostOnline(t *testing.T) { } func TestOServiceServiceForChat_OServiceHostOnline(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceServiceForChat(*NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil), nil) + svc := NewOServiceServiceForChat(config.Config{}, slog.Default(), nil, nil) want := wire.SNACMessage{ Frame: wire.SNACFrame{ @@ -1373,8 +1375,10 @@ func TestOServiceServiceForChat_OServiceHostOnline(t *testing.T) { } func TestOServiceService_ClientVersions(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil) + svc := OServiceService{ + cfg: config.Config{}, + logger: slog.Default(), + } want := wire.SNACMessage{ Frame: wire.SNACFrame{ @@ -1397,8 +1401,10 @@ func TestOServiceService_ClientVersions(t *testing.T) { } func TestOServiceService_UserInfoQuery(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil) + svc := OServiceService{ + cfg: config.Config{}, + logger: slog.Default(), + } sess := newTestSession("test-user") want := wire.SNACMessage{ @@ -1471,8 +1477,11 @@ func TestOServiceService_IdleNotification(t *testing.T) { })). Return(nil) } - svc := NewOServiceService(config.Config{}, nil, nil, slog.Default(), nil, buddyUpdateBroadcaster) - + svc := OServiceService{ + cfg: config.Config{}, + logger: slog.Default(), + buddyUpdateBroadcaster: buddyUpdateBroadcaster, + } haveErr := svc.IdleNotification(nil, tt.sess, tt.bodyIn) assert.ErrorIs(t, tt.wantErr, haveErr) }) @@ -1616,9 +1625,8 @@ func TestOServiceServiceForBOS_ClientOnline(t *testing.T) { })). Return(p.err) } - oservicesvc := NewOServiceService(config.Config{}, messageRelayer, legacyBuddyListManager, slog.Default(), nil, buddyUpdateBroadcaster) - svc := NewOServiceServiceForBOS(*oservicesvc, nil) + svc := NewOServiceServiceForBOS(config.Config{}, messageRelayer, legacyBuddyListManager, slog.Default(), nil, buddyUpdateBroadcaster, nil) haveErr := svc.ClientOnline(nil, tt.bodyIn, tt.sess) assert.ErrorIs(t, tt.wantErr, haveErr) }) @@ -1749,19 +1757,16 @@ func TestOServiceServiceForChat_ClientOnline(t *testing.T) { chatRegistry := state.NewChatRegistry() chatRegistry.Register(chatRoom, chatMessageRelayer) - svc := NewOServiceServiceForChat(OServiceService{ - messageRelayer: chatMessageRelayer, - }, chatRegistry) + svc := NewOServiceServiceForChat(config.Config{}, slog.Default(), nil, chatRegistry) - haveErr := svc.ClientOnline(nil, tt.joiningChatter) + haveErr := svc.ClientOnline(nil, wire.SNAC_0x01_0x02_OServiceClientOnline{}, tt.joiningChatter) assert.ErrorIs(t, tt.wantErr, haveErr) }) } } func TestOServiceServiceForChatNav_HostOnline(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceServiceForChatNav(*NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil), nil) + svc := NewOServiceServiceForChatNav(config.Config{}, slog.Default(), nil) want := wire.SNACMessage{ Frame: wire.SNACFrame{ @@ -1781,8 +1786,7 @@ func TestOServiceServiceForChatNav_HostOnline(t *testing.T) { } func TestOServiceServiceForAlert_HostOnline(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceServiceForAlert(*NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil)) + svc := NewOServiceServiceForAlert(config.Config{}, slog.Default(), nil) want := wire.SNACMessage{ Frame: wire.SNACFrame{ @@ -1802,8 +1806,10 @@ func TestOServiceServiceForAlert_HostOnline(t *testing.T) { } func TestOServiceService_SetPrivacyFlags(t *testing.T) { - cookieIssuer := newMockCookieIssuer(t) - svc := NewOServiceServiceForAlert(*NewOServiceService(config.Config{}, nil, nil, slog.Default(), cookieIssuer, nil)) + svc := OServiceService{ + cfg: config.Config{}, + logger: slog.Default(), + } body := wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags{ PrivacyFlags: wire.OServicePrivacyFlagMember | wire.OServicePrivacyFlagIdle, } diff --git a/server/oscar/bos.go b/server/oscar/bos.go index cc4f2f11..3b3b6baf 100644 --- a/server/oscar/bos.go +++ b/server/oscar/bos.go @@ -42,7 +42,7 @@ func (rt BOSServer) Start() { } defer listener.Close() - rt.Logger.Info("starting service", "host", net.JoinHostPort(rt.Config.OSCARHost, rt.Config.BOSPort)) + rt.Logger.Info("starting service", "host", rt.ListenAddr) for { conn, err := listener.Accept() diff --git a/server/oscar/handler/mock_oservice_alert_service_test.go b/server/oscar/handler/mock_oservice_alert_service_test.go deleted file mode 100644 index 7dfbf640..00000000 --- a/server/oscar/handler/mock_oservice_alert_service_test.go +++ /dev/null @@ -1,402 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package handler - -import ( - context "context" - - state "github.com/mk6i/retro-aim-server/state" - mock "github.com/stretchr/testify/mock" - - wire "github.com/mk6i/retro-aim-server/wire" -) - -// mockOServiceAlertService is an autogenerated mock type for the OServiceAlertService type -type mockOServiceAlertService struct { - mock.Mock -} - -type mockOServiceAlertService_Expecter struct { - mock *mock.Mock -} - -func (_m *mockOServiceAlertService) EXPECT() *mockOServiceAlertService_Expecter { - return &mockOServiceAlertService_Expecter{mock: &_m.Mock} -} - -// ClientVersions provides a mock function with given fields: ctx, frame, bodyIn -func (_m *mockOServiceAlertService) ClientVersions(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage { - ret := _m.Called(ctx, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for ClientVersions") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage); ok { - r0 = rf(ctx, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceAlertService_ClientVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientVersions' -type mockOServiceAlertService_ClientVersions_Call struct { - *mock.Call -} - -// ClientVersions is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions -func (_e *mockOServiceAlertService_Expecter) ClientVersions(ctx interface{}, frame interface{}, bodyIn interface{}) *mockOServiceAlertService_ClientVersions_Call { - return &mockOServiceAlertService_ClientVersions_Call{Call: _e.mock.On("ClientVersions", ctx, frame, bodyIn)} -} - -func (_c *mockOServiceAlertService_ClientVersions_Call) Run(run func(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions)) *mockOServiceAlertService_ClientVersions_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame), args[2].(wire.SNAC_0x01_0x17_OServiceClientVersions)) - }) - return _c -} - -func (_c *mockOServiceAlertService_ClientVersions_Call) Return(_a0 wire.SNACMessage) *mockOServiceAlertService_ClientVersions_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceAlertService_ClientVersions_Call) RunAndReturn(run func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage) *mockOServiceAlertService_ClientVersions_Call { - _c.Call.Return(run) - return _c -} - -// HostOnline provides a mock function with given fields: -func (_m *mockOServiceAlertService) HostOnline() wire.SNACMessage { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for HostOnline") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func() wire.SNACMessage); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceAlertService_HostOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HostOnline' -type mockOServiceAlertService_HostOnline_Call struct { - *mock.Call -} - -// HostOnline is a helper method to define mock.On call -func (_e *mockOServiceAlertService_Expecter) HostOnline() *mockOServiceAlertService_HostOnline_Call { - return &mockOServiceAlertService_HostOnline_Call{Call: _e.mock.On("HostOnline")} -} - -func (_c *mockOServiceAlertService_HostOnline_Call) Run(run func()) *mockOServiceAlertService_HostOnline_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *mockOServiceAlertService_HostOnline_Call) Return(_a0 wire.SNACMessage) *mockOServiceAlertService_HostOnline_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceAlertService_HostOnline_Call) RunAndReturn(run func() wire.SNACMessage) *mockOServiceAlertService_HostOnline_Call { - _c.Call.Return(run) - return _c -} - -// IdleNotification provides a mock function with given fields: ctx, sess, bodyIn -func (_m *mockOServiceAlertService) IdleNotification(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification) error { - ret := _m.Called(ctx, sess, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for IdleNotification") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error); ok { - r0 = rf(ctx, sess, bodyIn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockOServiceAlertService_IdleNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IdleNotification' -type mockOServiceAlertService_IdleNotification_Call struct { - *mock.Call -} - -// IdleNotification is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification -func (_e *mockOServiceAlertService_Expecter) IdleNotification(ctx interface{}, sess interface{}, bodyIn interface{}) *mockOServiceAlertService_IdleNotification_Call { - return &mockOServiceAlertService_IdleNotification_Call{Call: _e.mock.On("IdleNotification", ctx, sess, bodyIn)} -} - -func (_c *mockOServiceAlertService_IdleNotification_Call) Run(run func(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification)) *mockOServiceAlertService_IdleNotification_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNAC_0x01_0x11_OServiceIdleNotification)) - }) - return _c -} - -func (_c *mockOServiceAlertService_IdleNotification_Call) Return(_a0 error) *mockOServiceAlertService_IdleNotification_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceAlertService_IdleNotification_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error) *mockOServiceAlertService_IdleNotification_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsQuery provides a mock function with given fields: ctx, frame -func (_m *mockOServiceAlertService) RateParamsQuery(ctx context.Context, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, frame) - - if len(ret) == 0 { - panic("no return value specified for RateParamsQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceAlertService_RateParamsQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsQuery' -type mockOServiceAlertService_RateParamsQuery_Call struct { - *mock.Call -} - -// RateParamsQuery is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -func (_e *mockOServiceAlertService_Expecter) RateParamsQuery(ctx interface{}, frame interface{}) *mockOServiceAlertService_RateParamsQuery_Call { - return &mockOServiceAlertService_RateParamsQuery_Call{Call: _e.mock.On("RateParamsQuery", ctx, frame)} -} - -func (_c *mockOServiceAlertService_RateParamsQuery_Call) Run(run func(ctx context.Context, frame wire.SNACFrame)) *mockOServiceAlertService_RateParamsQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceAlertService_RateParamsQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceAlertService_RateParamsQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceAlertService_RateParamsQuery_Call) RunAndReturn(run func(context.Context, wire.SNACFrame) wire.SNACMessage) *mockOServiceAlertService_RateParamsQuery_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsSubAdd provides a mock function with given fields: _a0, _a1 -func (_m *mockOServiceAlertService) RateParamsSubAdd(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd) { - _m.Called(_a0, _a1) -} - -// mockOServiceAlertService_RateParamsSubAdd_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsSubAdd' -type mockOServiceAlertService_RateParamsSubAdd_Call struct { - *mock.Call -} - -// RateParamsSubAdd is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd -func (_e *mockOServiceAlertService_Expecter) RateParamsSubAdd(_a0 interface{}, _a1 interface{}) *mockOServiceAlertService_RateParamsSubAdd_Call { - return &mockOServiceAlertService_RateParamsSubAdd_Call{Call: _e.mock.On("RateParamsSubAdd", _a0, _a1)} -} - -func (_c *mockOServiceAlertService_RateParamsSubAdd_Call) Run(run func(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceAlertService_RateParamsSubAdd_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) - }) - return _c -} - -func (_c *mockOServiceAlertService_RateParamsSubAdd_Call) Return() *mockOServiceAlertService_RateParamsSubAdd_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceAlertService_RateParamsSubAdd_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceAlertService_RateParamsSubAdd_Call { - _c.Call.Return(run) - return _c -} - -// SetPrivacyFlags provides a mock function with given fields: ctx, bodyIn -func (_m *mockOServiceAlertService) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags) { - _m.Called(ctx, bodyIn) -} - -// mockOServiceAlertService_SetPrivacyFlags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPrivacyFlags' -type mockOServiceAlertService_SetPrivacyFlags_Call struct { - *mock.Call -} - -// SetPrivacyFlags is a helper method to define mock.On call -// - ctx context.Context -// - bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags -func (_e *mockOServiceAlertService_Expecter) SetPrivacyFlags(ctx interface{}, bodyIn interface{}) *mockOServiceAlertService_SetPrivacyFlags_Call { - return &mockOServiceAlertService_SetPrivacyFlags_Call{Call: _e.mock.On("SetPrivacyFlags", ctx, bodyIn)} -} - -func (_c *mockOServiceAlertService_SetPrivacyFlags_Call) Run(run func(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceAlertService_SetPrivacyFlags_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) - }) - return _c -} - -func (_c *mockOServiceAlertService_SetPrivacyFlags_Call) Return() *mockOServiceAlertService_SetPrivacyFlags_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceAlertService_SetPrivacyFlags_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceAlertService_SetPrivacyFlags_Call { - _c.Call.Return(run) - return _c -} - -// SetUserInfoFields provides a mock function with given fields: ctx, sess, frame, bodyIn -func (_m *mockOServiceAlertService) SetUserInfoFields(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error) { - ret := _m.Called(ctx, sess, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for SetUserInfoFields") - } - - var r0 wire.SNACMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)); ok { - return rf(ctx, sess, frame, bodyIn) - } - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - if rf, ok := ret.Get(1).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) error); ok { - r1 = rf(ctx, sess, frame, bodyIn) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockOServiceAlertService_SetUserInfoFields_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUserInfoFields' -type mockOServiceAlertService_SetUserInfoFields_Call struct { - *mock.Call -} - -// SetUserInfoFields is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields -func (_e *mockOServiceAlertService_Expecter) SetUserInfoFields(ctx interface{}, sess interface{}, frame interface{}, bodyIn interface{}) *mockOServiceAlertService_SetUserInfoFields_Call { - return &mockOServiceAlertService_SetUserInfoFields_Call{Call: _e.mock.On("SetUserInfoFields", ctx, sess, frame, bodyIn)} -} - -func (_c *mockOServiceAlertService_SetUserInfoFields_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) *mockOServiceAlertService_SetUserInfoFields_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame), args[3].(wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) - }) - return _c -} - -func (_c *mockOServiceAlertService_SetUserInfoFields_Call) Return(_a0 wire.SNACMessage, _a1 error) *mockOServiceAlertService_SetUserInfoFields_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockOServiceAlertService_SetUserInfoFields_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)) *mockOServiceAlertService_SetUserInfoFields_Call { - _c.Call.Return(run) - return _c -} - -// UserInfoQuery provides a mock function with given fields: ctx, sess, frame -func (_m *mockOServiceAlertService) UserInfoQuery(ctx context.Context, sess *state.Session, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, sess, frame) - - if len(ret) == 0 { - panic("no return value specified for UserInfoQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceAlertService_UserInfoQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UserInfoQuery' -type mockOServiceAlertService_UserInfoQuery_Call struct { - *mock.Call -} - -// UserInfoQuery is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -func (_e *mockOServiceAlertService_Expecter) UserInfoQuery(ctx interface{}, sess interface{}, frame interface{}) *mockOServiceAlertService_UserInfoQuery_Call { - return &mockOServiceAlertService_UserInfoQuery_Call{Call: _e.mock.On("UserInfoQuery", ctx, sess, frame)} -} - -func (_c *mockOServiceAlertService_UserInfoQuery_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame)) *mockOServiceAlertService_UserInfoQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceAlertService_UserInfoQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceAlertService_UserInfoQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceAlertService_UserInfoQuery_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage) *mockOServiceAlertService_UserInfoQuery_Call { - _c.Call.Return(run) - return _c -} - -// newMockOServiceAlertService creates a new instance of mockOServiceAlertService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockOServiceAlertService(t interface { - mock.TestingT - Cleanup(func()) -}) *mockOServiceAlertService { - mock := &mockOServiceAlertService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/oscar/handler/mock_oservice_bos_test.go b/server/oscar/handler/mock_oservice_bos_test.go deleted file mode 100644 index 81acd55c..00000000 --- a/server/oscar/handler/mock_oservice_bos_test.go +++ /dev/null @@ -1,509 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package handler - -import ( - context "context" - - state "github.com/mk6i/retro-aim-server/state" - mock "github.com/stretchr/testify/mock" - - wire "github.com/mk6i/retro-aim-server/wire" -) - -// mockOServiceBOSService is an autogenerated mock type for the OServiceBOSService type -type mockOServiceBOSService struct { - mock.Mock -} - -type mockOServiceBOSService_Expecter struct { - mock *mock.Mock -} - -func (_m *mockOServiceBOSService) EXPECT() *mockOServiceBOSService_Expecter { - return &mockOServiceBOSService_Expecter{mock: &_m.Mock} -} - -// ClientOnline provides a mock function with given fields: ctx, bodyIn, sess -func (_m *mockOServiceBOSService) ClientOnline(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session) error { - ret := _m.Called(ctx, bodyIn, sess) - - if len(ret) == 0 { - panic("no return value specified for ClientOnline") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, wire.SNAC_0x01_0x02_OServiceClientOnline, *state.Session) error); ok { - r0 = rf(ctx, bodyIn, sess) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockOServiceBOSService_ClientOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientOnline' -type mockOServiceBOSService_ClientOnline_Call struct { - *mock.Call -} - -// ClientOnline is a helper method to define mock.On call -// - ctx context.Context -// - bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline -// - sess *state.Session -func (_e *mockOServiceBOSService_Expecter) ClientOnline(ctx interface{}, bodyIn interface{}, sess interface{}) *mockOServiceBOSService_ClientOnline_Call { - return &mockOServiceBOSService_ClientOnline_Call{Call: _e.mock.On("ClientOnline", ctx, bodyIn, sess)} -} - -func (_c *mockOServiceBOSService_ClientOnline_Call) Run(run func(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session)) *mockOServiceBOSService_ClientOnline_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x02_OServiceClientOnline), args[2].(*state.Session)) - }) - return _c -} - -func (_c *mockOServiceBOSService_ClientOnline_Call) Return(_a0 error) *mockOServiceBOSService_ClientOnline_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceBOSService_ClientOnline_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x02_OServiceClientOnline, *state.Session) error) *mockOServiceBOSService_ClientOnline_Call { - _c.Call.Return(run) - return _c -} - -// ClientVersions provides a mock function with given fields: ctx, frame, bodyIn -func (_m *mockOServiceBOSService) ClientVersions(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage { - ret := _m.Called(ctx, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for ClientVersions") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage); ok { - r0 = rf(ctx, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceBOSService_ClientVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientVersions' -type mockOServiceBOSService_ClientVersions_Call struct { - *mock.Call -} - -// ClientVersions is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions -func (_e *mockOServiceBOSService_Expecter) ClientVersions(ctx interface{}, frame interface{}, bodyIn interface{}) *mockOServiceBOSService_ClientVersions_Call { - return &mockOServiceBOSService_ClientVersions_Call{Call: _e.mock.On("ClientVersions", ctx, frame, bodyIn)} -} - -func (_c *mockOServiceBOSService_ClientVersions_Call) Run(run func(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions)) *mockOServiceBOSService_ClientVersions_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame), args[2].(wire.SNAC_0x01_0x17_OServiceClientVersions)) - }) - return _c -} - -func (_c *mockOServiceBOSService_ClientVersions_Call) Return(_a0 wire.SNACMessage) *mockOServiceBOSService_ClientVersions_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceBOSService_ClientVersions_Call) RunAndReturn(run func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage) *mockOServiceBOSService_ClientVersions_Call { - _c.Call.Return(run) - return _c -} - -// HostOnline provides a mock function with given fields: -func (_m *mockOServiceBOSService) HostOnline() wire.SNACMessage { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for HostOnline") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func() wire.SNACMessage); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceBOSService_HostOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HostOnline' -type mockOServiceBOSService_HostOnline_Call struct { - *mock.Call -} - -// HostOnline is a helper method to define mock.On call -func (_e *mockOServiceBOSService_Expecter) HostOnline() *mockOServiceBOSService_HostOnline_Call { - return &mockOServiceBOSService_HostOnline_Call{Call: _e.mock.On("HostOnline")} -} - -func (_c *mockOServiceBOSService_HostOnline_Call) Run(run func()) *mockOServiceBOSService_HostOnline_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *mockOServiceBOSService_HostOnline_Call) Return(_a0 wire.SNACMessage) *mockOServiceBOSService_HostOnline_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceBOSService_HostOnline_Call) RunAndReturn(run func() wire.SNACMessage) *mockOServiceBOSService_HostOnline_Call { - _c.Call.Return(run) - return _c -} - -// IdleNotification provides a mock function with given fields: ctx, sess, bodyIn -func (_m *mockOServiceBOSService) IdleNotification(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification) error { - ret := _m.Called(ctx, sess, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for IdleNotification") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error); ok { - r0 = rf(ctx, sess, bodyIn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockOServiceBOSService_IdleNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IdleNotification' -type mockOServiceBOSService_IdleNotification_Call struct { - *mock.Call -} - -// IdleNotification is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification -func (_e *mockOServiceBOSService_Expecter) IdleNotification(ctx interface{}, sess interface{}, bodyIn interface{}) *mockOServiceBOSService_IdleNotification_Call { - return &mockOServiceBOSService_IdleNotification_Call{Call: _e.mock.On("IdleNotification", ctx, sess, bodyIn)} -} - -func (_c *mockOServiceBOSService_IdleNotification_Call) Run(run func(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification)) *mockOServiceBOSService_IdleNotification_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNAC_0x01_0x11_OServiceIdleNotification)) - }) - return _c -} - -func (_c *mockOServiceBOSService_IdleNotification_Call) Return(_a0 error) *mockOServiceBOSService_IdleNotification_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceBOSService_IdleNotification_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error) *mockOServiceBOSService_IdleNotification_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsQuery provides a mock function with given fields: ctx, frame -func (_m *mockOServiceBOSService) RateParamsQuery(ctx context.Context, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, frame) - - if len(ret) == 0 { - panic("no return value specified for RateParamsQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceBOSService_RateParamsQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsQuery' -type mockOServiceBOSService_RateParamsQuery_Call struct { - *mock.Call -} - -// RateParamsQuery is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -func (_e *mockOServiceBOSService_Expecter) RateParamsQuery(ctx interface{}, frame interface{}) *mockOServiceBOSService_RateParamsQuery_Call { - return &mockOServiceBOSService_RateParamsQuery_Call{Call: _e.mock.On("RateParamsQuery", ctx, frame)} -} - -func (_c *mockOServiceBOSService_RateParamsQuery_Call) Run(run func(ctx context.Context, frame wire.SNACFrame)) *mockOServiceBOSService_RateParamsQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceBOSService_RateParamsQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceBOSService_RateParamsQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceBOSService_RateParamsQuery_Call) RunAndReturn(run func(context.Context, wire.SNACFrame) wire.SNACMessage) *mockOServiceBOSService_RateParamsQuery_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsSubAdd provides a mock function with given fields: _a0, _a1 -func (_m *mockOServiceBOSService) RateParamsSubAdd(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd) { - _m.Called(_a0, _a1) -} - -// mockOServiceBOSService_RateParamsSubAdd_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsSubAdd' -type mockOServiceBOSService_RateParamsSubAdd_Call struct { - *mock.Call -} - -// RateParamsSubAdd is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd -func (_e *mockOServiceBOSService_Expecter) RateParamsSubAdd(_a0 interface{}, _a1 interface{}) *mockOServiceBOSService_RateParamsSubAdd_Call { - return &mockOServiceBOSService_RateParamsSubAdd_Call{Call: _e.mock.On("RateParamsSubAdd", _a0, _a1)} -} - -func (_c *mockOServiceBOSService_RateParamsSubAdd_Call) Run(run func(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceBOSService_RateParamsSubAdd_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) - }) - return _c -} - -func (_c *mockOServiceBOSService_RateParamsSubAdd_Call) Return() *mockOServiceBOSService_RateParamsSubAdd_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceBOSService_RateParamsSubAdd_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceBOSService_RateParamsSubAdd_Call { - _c.Call.Return(run) - return _c -} - -// ServiceRequest provides a mock function with given fields: ctx, sess, frame, bodyIn -func (_m *mockOServiceBOSService) ServiceRequest(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error) { - ret := _m.Called(ctx, sess, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for ServiceRequest") - } - - var r0 wire.SNACMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error)); ok { - return rf(ctx, sess, frame, bodyIn) - } - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - if rf, ok := ret.Get(1).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) error); ok { - r1 = rf(ctx, sess, frame, bodyIn) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockOServiceBOSService_ServiceRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ServiceRequest' -type mockOServiceBOSService_ServiceRequest_Call struct { - *mock.Call -} - -// ServiceRequest is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest -func (_e *mockOServiceBOSService_Expecter) ServiceRequest(ctx interface{}, sess interface{}, frame interface{}, bodyIn interface{}) *mockOServiceBOSService_ServiceRequest_Call { - return &mockOServiceBOSService_ServiceRequest_Call{Call: _e.mock.On("ServiceRequest", ctx, sess, frame, bodyIn)} -} - -func (_c *mockOServiceBOSService_ServiceRequest_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest)) *mockOServiceBOSService_ServiceRequest_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame), args[3].(wire.SNAC_0x01_0x04_OServiceServiceRequest)) - }) - return _c -} - -func (_c *mockOServiceBOSService_ServiceRequest_Call) Return(_a0 wire.SNACMessage, _a1 error) *mockOServiceBOSService_ServiceRequest_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockOServiceBOSService_ServiceRequest_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error)) *mockOServiceBOSService_ServiceRequest_Call { - _c.Call.Return(run) - return _c -} - -// SetPrivacyFlags provides a mock function with given fields: ctx, bodyIn -func (_m *mockOServiceBOSService) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags) { - _m.Called(ctx, bodyIn) -} - -// mockOServiceBOSService_SetPrivacyFlags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPrivacyFlags' -type mockOServiceBOSService_SetPrivacyFlags_Call struct { - *mock.Call -} - -// SetPrivacyFlags is a helper method to define mock.On call -// - ctx context.Context -// - bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags -func (_e *mockOServiceBOSService_Expecter) SetPrivacyFlags(ctx interface{}, bodyIn interface{}) *mockOServiceBOSService_SetPrivacyFlags_Call { - return &mockOServiceBOSService_SetPrivacyFlags_Call{Call: _e.mock.On("SetPrivacyFlags", ctx, bodyIn)} -} - -func (_c *mockOServiceBOSService_SetPrivacyFlags_Call) Run(run func(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceBOSService_SetPrivacyFlags_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) - }) - return _c -} - -func (_c *mockOServiceBOSService_SetPrivacyFlags_Call) Return() *mockOServiceBOSService_SetPrivacyFlags_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceBOSService_SetPrivacyFlags_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceBOSService_SetPrivacyFlags_Call { - _c.Call.Return(run) - return _c -} - -// SetUserInfoFields provides a mock function with given fields: ctx, sess, frame, bodyIn -func (_m *mockOServiceBOSService) SetUserInfoFields(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error) { - ret := _m.Called(ctx, sess, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for SetUserInfoFields") - } - - var r0 wire.SNACMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)); ok { - return rf(ctx, sess, frame, bodyIn) - } - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - if rf, ok := ret.Get(1).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) error); ok { - r1 = rf(ctx, sess, frame, bodyIn) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockOServiceBOSService_SetUserInfoFields_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUserInfoFields' -type mockOServiceBOSService_SetUserInfoFields_Call struct { - *mock.Call -} - -// SetUserInfoFields is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields -func (_e *mockOServiceBOSService_Expecter) SetUserInfoFields(ctx interface{}, sess interface{}, frame interface{}, bodyIn interface{}) *mockOServiceBOSService_SetUserInfoFields_Call { - return &mockOServiceBOSService_SetUserInfoFields_Call{Call: _e.mock.On("SetUserInfoFields", ctx, sess, frame, bodyIn)} -} - -func (_c *mockOServiceBOSService_SetUserInfoFields_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) *mockOServiceBOSService_SetUserInfoFields_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame), args[3].(wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) - }) - return _c -} - -func (_c *mockOServiceBOSService_SetUserInfoFields_Call) Return(_a0 wire.SNACMessage, _a1 error) *mockOServiceBOSService_SetUserInfoFields_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockOServiceBOSService_SetUserInfoFields_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)) *mockOServiceBOSService_SetUserInfoFields_Call { - _c.Call.Return(run) - return _c -} - -// UserInfoQuery provides a mock function with given fields: ctx, sess, frame -func (_m *mockOServiceBOSService) UserInfoQuery(ctx context.Context, sess *state.Session, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, sess, frame) - - if len(ret) == 0 { - panic("no return value specified for UserInfoQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceBOSService_UserInfoQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UserInfoQuery' -type mockOServiceBOSService_UserInfoQuery_Call struct { - *mock.Call -} - -// UserInfoQuery is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -func (_e *mockOServiceBOSService_Expecter) UserInfoQuery(ctx interface{}, sess interface{}, frame interface{}) *mockOServiceBOSService_UserInfoQuery_Call { - return &mockOServiceBOSService_UserInfoQuery_Call{Call: _e.mock.On("UserInfoQuery", ctx, sess, frame)} -} - -func (_c *mockOServiceBOSService_UserInfoQuery_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame)) *mockOServiceBOSService_UserInfoQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceBOSService_UserInfoQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceBOSService_UserInfoQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceBOSService_UserInfoQuery_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage) *mockOServiceBOSService_UserInfoQuery_Call { - _c.Call.Return(run) - return _c -} - -// newMockOServiceBOSService creates a new instance of mockOServiceBOSService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockOServiceBOSService(t interface { - mock.TestingT - Cleanup(func()) -}) *mockOServiceBOSService { - mock := &mockOServiceBOSService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/oscar/handler/mock_oservice_chat_nav_test.go b/server/oscar/handler/mock_oservice_chat_nav_test.go deleted file mode 100644 index 8b5d32c0..00000000 --- a/server/oscar/handler/mock_oservice_chat_nav_test.go +++ /dev/null @@ -1,402 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package handler - -import ( - context "context" - - state "github.com/mk6i/retro-aim-server/state" - mock "github.com/stretchr/testify/mock" - - wire "github.com/mk6i/retro-aim-server/wire" -) - -// mockOServiceChatNavService is an autogenerated mock type for the OServiceChatNavService type -type mockOServiceChatNavService struct { - mock.Mock -} - -type mockOServiceChatNavService_Expecter struct { - mock *mock.Mock -} - -func (_m *mockOServiceChatNavService) EXPECT() *mockOServiceChatNavService_Expecter { - return &mockOServiceChatNavService_Expecter{mock: &_m.Mock} -} - -// ClientVersions provides a mock function with given fields: ctx, frame, bodyIn -func (_m *mockOServiceChatNavService) ClientVersions(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage { - ret := _m.Called(ctx, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for ClientVersions") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage); ok { - r0 = rf(ctx, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatNavService_ClientVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientVersions' -type mockOServiceChatNavService_ClientVersions_Call struct { - *mock.Call -} - -// ClientVersions is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions -func (_e *mockOServiceChatNavService_Expecter) ClientVersions(ctx interface{}, frame interface{}, bodyIn interface{}) *mockOServiceChatNavService_ClientVersions_Call { - return &mockOServiceChatNavService_ClientVersions_Call{Call: _e.mock.On("ClientVersions", ctx, frame, bodyIn)} -} - -func (_c *mockOServiceChatNavService_ClientVersions_Call) Run(run func(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions)) *mockOServiceChatNavService_ClientVersions_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame), args[2].(wire.SNAC_0x01_0x17_OServiceClientVersions)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_ClientVersions_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatNavService_ClientVersions_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatNavService_ClientVersions_Call) RunAndReturn(run func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage) *mockOServiceChatNavService_ClientVersions_Call { - _c.Call.Return(run) - return _c -} - -// HostOnline provides a mock function with given fields: -func (_m *mockOServiceChatNavService) HostOnline() wire.SNACMessage { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for HostOnline") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func() wire.SNACMessage); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatNavService_HostOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HostOnline' -type mockOServiceChatNavService_HostOnline_Call struct { - *mock.Call -} - -// HostOnline is a helper method to define mock.On call -func (_e *mockOServiceChatNavService_Expecter) HostOnline() *mockOServiceChatNavService_HostOnline_Call { - return &mockOServiceChatNavService_HostOnline_Call{Call: _e.mock.On("HostOnline")} -} - -func (_c *mockOServiceChatNavService_HostOnline_Call) Run(run func()) *mockOServiceChatNavService_HostOnline_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *mockOServiceChatNavService_HostOnline_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatNavService_HostOnline_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatNavService_HostOnline_Call) RunAndReturn(run func() wire.SNACMessage) *mockOServiceChatNavService_HostOnline_Call { - _c.Call.Return(run) - return _c -} - -// IdleNotification provides a mock function with given fields: ctx, sess, bodyIn -func (_m *mockOServiceChatNavService) IdleNotification(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification) error { - ret := _m.Called(ctx, sess, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for IdleNotification") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error); ok { - r0 = rf(ctx, sess, bodyIn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockOServiceChatNavService_IdleNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IdleNotification' -type mockOServiceChatNavService_IdleNotification_Call struct { - *mock.Call -} - -// IdleNotification is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification -func (_e *mockOServiceChatNavService_Expecter) IdleNotification(ctx interface{}, sess interface{}, bodyIn interface{}) *mockOServiceChatNavService_IdleNotification_Call { - return &mockOServiceChatNavService_IdleNotification_Call{Call: _e.mock.On("IdleNotification", ctx, sess, bodyIn)} -} - -func (_c *mockOServiceChatNavService_IdleNotification_Call) Run(run func(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification)) *mockOServiceChatNavService_IdleNotification_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNAC_0x01_0x11_OServiceIdleNotification)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_IdleNotification_Call) Return(_a0 error) *mockOServiceChatNavService_IdleNotification_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatNavService_IdleNotification_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error) *mockOServiceChatNavService_IdleNotification_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsQuery provides a mock function with given fields: ctx, frame -func (_m *mockOServiceChatNavService) RateParamsQuery(ctx context.Context, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, frame) - - if len(ret) == 0 { - panic("no return value specified for RateParamsQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatNavService_RateParamsQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsQuery' -type mockOServiceChatNavService_RateParamsQuery_Call struct { - *mock.Call -} - -// RateParamsQuery is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -func (_e *mockOServiceChatNavService_Expecter) RateParamsQuery(ctx interface{}, frame interface{}) *mockOServiceChatNavService_RateParamsQuery_Call { - return &mockOServiceChatNavService_RateParamsQuery_Call{Call: _e.mock.On("RateParamsQuery", ctx, frame)} -} - -func (_c *mockOServiceChatNavService_RateParamsQuery_Call) Run(run func(ctx context.Context, frame wire.SNACFrame)) *mockOServiceChatNavService_RateParamsQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_RateParamsQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatNavService_RateParamsQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatNavService_RateParamsQuery_Call) RunAndReturn(run func(context.Context, wire.SNACFrame) wire.SNACMessage) *mockOServiceChatNavService_RateParamsQuery_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsSubAdd provides a mock function with given fields: _a0, _a1 -func (_m *mockOServiceChatNavService) RateParamsSubAdd(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd) { - _m.Called(_a0, _a1) -} - -// mockOServiceChatNavService_RateParamsSubAdd_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsSubAdd' -type mockOServiceChatNavService_RateParamsSubAdd_Call struct { - *mock.Call -} - -// RateParamsSubAdd is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd -func (_e *mockOServiceChatNavService_Expecter) RateParamsSubAdd(_a0 interface{}, _a1 interface{}) *mockOServiceChatNavService_RateParamsSubAdd_Call { - return &mockOServiceChatNavService_RateParamsSubAdd_Call{Call: _e.mock.On("RateParamsSubAdd", _a0, _a1)} -} - -func (_c *mockOServiceChatNavService_RateParamsSubAdd_Call) Run(run func(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceChatNavService_RateParamsSubAdd_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_RateParamsSubAdd_Call) Return() *mockOServiceChatNavService_RateParamsSubAdd_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceChatNavService_RateParamsSubAdd_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceChatNavService_RateParamsSubAdd_Call { - _c.Call.Return(run) - return _c -} - -// SetPrivacyFlags provides a mock function with given fields: ctx, bodyIn -func (_m *mockOServiceChatNavService) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags) { - _m.Called(ctx, bodyIn) -} - -// mockOServiceChatNavService_SetPrivacyFlags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPrivacyFlags' -type mockOServiceChatNavService_SetPrivacyFlags_Call struct { - *mock.Call -} - -// SetPrivacyFlags is a helper method to define mock.On call -// - ctx context.Context -// - bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags -func (_e *mockOServiceChatNavService_Expecter) SetPrivacyFlags(ctx interface{}, bodyIn interface{}) *mockOServiceChatNavService_SetPrivacyFlags_Call { - return &mockOServiceChatNavService_SetPrivacyFlags_Call{Call: _e.mock.On("SetPrivacyFlags", ctx, bodyIn)} -} - -func (_c *mockOServiceChatNavService_SetPrivacyFlags_Call) Run(run func(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceChatNavService_SetPrivacyFlags_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_SetPrivacyFlags_Call) Return() *mockOServiceChatNavService_SetPrivacyFlags_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceChatNavService_SetPrivacyFlags_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceChatNavService_SetPrivacyFlags_Call { - _c.Call.Return(run) - return _c -} - -// SetUserInfoFields provides a mock function with given fields: ctx, sess, frame, bodyIn -func (_m *mockOServiceChatNavService) SetUserInfoFields(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error) { - ret := _m.Called(ctx, sess, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for SetUserInfoFields") - } - - var r0 wire.SNACMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)); ok { - return rf(ctx, sess, frame, bodyIn) - } - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - if rf, ok := ret.Get(1).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) error); ok { - r1 = rf(ctx, sess, frame, bodyIn) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockOServiceChatNavService_SetUserInfoFields_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUserInfoFields' -type mockOServiceChatNavService_SetUserInfoFields_Call struct { - *mock.Call -} - -// SetUserInfoFields is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields -func (_e *mockOServiceChatNavService_Expecter) SetUserInfoFields(ctx interface{}, sess interface{}, frame interface{}, bodyIn interface{}) *mockOServiceChatNavService_SetUserInfoFields_Call { - return &mockOServiceChatNavService_SetUserInfoFields_Call{Call: _e.mock.On("SetUserInfoFields", ctx, sess, frame, bodyIn)} -} - -func (_c *mockOServiceChatNavService_SetUserInfoFields_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) *mockOServiceChatNavService_SetUserInfoFields_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame), args[3].(wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_SetUserInfoFields_Call) Return(_a0 wire.SNACMessage, _a1 error) *mockOServiceChatNavService_SetUserInfoFields_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockOServiceChatNavService_SetUserInfoFields_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)) *mockOServiceChatNavService_SetUserInfoFields_Call { - _c.Call.Return(run) - return _c -} - -// UserInfoQuery provides a mock function with given fields: ctx, sess, frame -func (_m *mockOServiceChatNavService) UserInfoQuery(ctx context.Context, sess *state.Session, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, sess, frame) - - if len(ret) == 0 { - panic("no return value specified for UserInfoQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatNavService_UserInfoQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UserInfoQuery' -type mockOServiceChatNavService_UserInfoQuery_Call struct { - *mock.Call -} - -// UserInfoQuery is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -func (_e *mockOServiceChatNavService_Expecter) UserInfoQuery(ctx interface{}, sess interface{}, frame interface{}) *mockOServiceChatNavService_UserInfoQuery_Call { - return &mockOServiceChatNavService_UserInfoQuery_Call{Call: _e.mock.On("UserInfoQuery", ctx, sess, frame)} -} - -func (_c *mockOServiceChatNavService_UserInfoQuery_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame)) *mockOServiceChatNavService_UserInfoQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceChatNavService_UserInfoQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatNavService_UserInfoQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatNavService_UserInfoQuery_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage) *mockOServiceChatNavService_UserInfoQuery_Call { - _c.Call.Return(run) - return _c -} - -// newMockOServiceChatNavService creates a new instance of mockOServiceChatNavService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockOServiceChatNavService(t interface { - mock.TestingT - Cleanup(func()) -}) *mockOServiceChatNavService { - mock := &mockOServiceChatNavService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/oscar/handler/mock_oservice_chat_test.go b/server/oscar/handler/mock_oservice_chat_test.go deleted file mode 100644 index dcbadcff..00000000 --- a/server/oscar/handler/mock_oservice_chat_test.go +++ /dev/null @@ -1,449 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package handler - -import ( - context "context" - - state "github.com/mk6i/retro-aim-server/state" - mock "github.com/stretchr/testify/mock" - - wire "github.com/mk6i/retro-aim-server/wire" -) - -// mockOServiceChatService is an autogenerated mock type for the OServiceChatService type -type mockOServiceChatService struct { - mock.Mock -} - -type mockOServiceChatService_Expecter struct { - mock *mock.Mock -} - -func (_m *mockOServiceChatService) EXPECT() *mockOServiceChatService_Expecter { - return &mockOServiceChatService_Expecter{mock: &_m.Mock} -} - -// ClientOnline provides a mock function with given fields: ctx, sess -func (_m *mockOServiceChatService) ClientOnline(ctx context.Context, sess *state.Session) error { - ret := _m.Called(ctx, sess) - - if len(ret) == 0 { - panic("no return value specified for ClientOnline") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session) error); ok { - r0 = rf(ctx, sess) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockOServiceChatService_ClientOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientOnline' -type mockOServiceChatService_ClientOnline_Call struct { - *mock.Call -} - -// ClientOnline is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -func (_e *mockOServiceChatService_Expecter) ClientOnline(ctx interface{}, sess interface{}) *mockOServiceChatService_ClientOnline_Call { - return &mockOServiceChatService_ClientOnline_Call{Call: _e.mock.On("ClientOnline", ctx, sess)} -} - -func (_c *mockOServiceChatService_ClientOnline_Call) Run(run func(ctx context.Context, sess *state.Session)) *mockOServiceChatService_ClientOnline_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session)) - }) - return _c -} - -func (_c *mockOServiceChatService_ClientOnline_Call) Return(_a0 error) *mockOServiceChatService_ClientOnline_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatService_ClientOnline_Call) RunAndReturn(run func(context.Context, *state.Session) error) *mockOServiceChatService_ClientOnline_Call { - _c.Call.Return(run) - return _c -} - -// ClientVersions provides a mock function with given fields: ctx, frame, bodyIn -func (_m *mockOServiceChatService) ClientVersions(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage { - ret := _m.Called(ctx, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for ClientVersions") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage); ok { - r0 = rf(ctx, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatService_ClientVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientVersions' -type mockOServiceChatService_ClientVersions_Call struct { - *mock.Call -} - -// ClientVersions is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions -func (_e *mockOServiceChatService_Expecter) ClientVersions(ctx interface{}, frame interface{}, bodyIn interface{}) *mockOServiceChatService_ClientVersions_Call { - return &mockOServiceChatService_ClientVersions_Call{Call: _e.mock.On("ClientVersions", ctx, frame, bodyIn)} -} - -func (_c *mockOServiceChatService_ClientVersions_Call) Run(run func(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions)) *mockOServiceChatService_ClientVersions_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame), args[2].(wire.SNAC_0x01_0x17_OServiceClientVersions)) - }) - return _c -} - -func (_c *mockOServiceChatService_ClientVersions_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatService_ClientVersions_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatService_ClientVersions_Call) RunAndReturn(run func(context.Context, wire.SNACFrame, wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage) *mockOServiceChatService_ClientVersions_Call { - _c.Call.Return(run) - return _c -} - -// HostOnline provides a mock function with given fields: -func (_m *mockOServiceChatService) HostOnline() wire.SNACMessage { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for HostOnline") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func() wire.SNACMessage); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatService_HostOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HostOnline' -type mockOServiceChatService_HostOnline_Call struct { - *mock.Call -} - -// HostOnline is a helper method to define mock.On call -func (_e *mockOServiceChatService_Expecter) HostOnline() *mockOServiceChatService_HostOnline_Call { - return &mockOServiceChatService_HostOnline_Call{Call: _e.mock.On("HostOnline")} -} - -func (_c *mockOServiceChatService_HostOnline_Call) Run(run func()) *mockOServiceChatService_HostOnline_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *mockOServiceChatService_HostOnline_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatService_HostOnline_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatService_HostOnline_Call) RunAndReturn(run func() wire.SNACMessage) *mockOServiceChatService_HostOnline_Call { - _c.Call.Return(run) - return _c -} - -// IdleNotification provides a mock function with given fields: ctx, sess, bodyIn -func (_m *mockOServiceChatService) IdleNotification(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification) error { - ret := _m.Called(ctx, sess, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for IdleNotification") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error); ok { - r0 = rf(ctx, sess, bodyIn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// mockOServiceChatService_IdleNotification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IdleNotification' -type mockOServiceChatService_IdleNotification_Call struct { - *mock.Call -} - -// IdleNotification is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification -func (_e *mockOServiceChatService_Expecter) IdleNotification(ctx interface{}, sess interface{}, bodyIn interface{}) *mockOServiceChatService_IdleNotification_Call { - return &mockOServiceChatService_IdleNotification_Call{Call: _e.mock.On("IdleNotification", ctx, sess, bodyIn)} -} - -func (_c *mockOServiceChatService_IdleNotification_Call) Run(run func(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification)) *mockOServiceChatService_IdleNotification_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNAC_0x01_0x11_OServiceIdleNotification)) - }) - return _c -} - -func (_c *mockOServiceChatService_IdleNotification_Call) Return(_a0 error) *mockOServiceChatService_IdleNotification_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatService_IdleNotification_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNAC_0x01_0x11_OServiceIdleNotification) error) *mockOServiceChatService_IdleNotification_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsQuery provides a mock function with given fields: ctx, frame -func (_m *mockOServiceChatService) RateParamsQuery(ctx context.Context, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, frame) - - if len(ret) == 0 { - panic("no return value specified for RateParamsQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatService_RateParamsQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsQuery' -type mockOServiceChatService_RateParamsQuery_Call struct { - *mock.Call -} - -// RateParamsQuery is a helper method to define mock.On call -// - ctx context.Context -// - frame wire.SNACFrame -func (_e *mockOServiceChatService_Expecter) RateParamsQuery(ctx interface{}, frame interface{}) *mockOServiceChatService_RateParamsQuery_Call { - return &mockOServiceChatService_RateParamsQuery_Call{Call: _e.mock.On("RateParamsQuery", ctx, frame)} -} - -func (_c *mockOServiceChatService_RateParamsQuery_Call) Run(run func(ctx context.Context, frame wire.SNACFrame)) *mockOServiceChatService_RateParamsQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceChatService_RateParamsQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatService_RateParamsQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatService_RateParamsQuery_Call) RunAndReturn(run func(context.Context, wire.SNACFrame) wire.SNACMessage) *mockOServiceChatService_RateParamsQuery_Call { - _c.Call.Return(run) - return _c -} - -// RateParamsSubAdd provides a mock function with given fields: _a0, _a1 -func (_m *mockOServiceChatService) RateParamsSubAdd(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd) { - _m.Called(_a0, _a1) -} - -// mockOServiceChatService_RateParamsSubAdd_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RateParamsSubAdd' -type mockOServiceChatService_RateParamsSubAdd_Call struct { - *mock.Call -} - -// RateParamsSubAdd is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd -func (_e *mockOServiceChatService_Expecter) RateParamsSubAdd(_a0 interface{}, _a1 interface{}) *mockOServiceChatService_RateParamsSubAdd_Call { - return &mockOServiceChatService_RateParamsSubAdd_Call{Call: _e.mock.On("RateParamsSubAdd", _a0, _a1)} -} - -func (_c *mockOServiceChatService_RateParamsSubAdd_Call) Run(run func(_a0 context.Context, _a1 wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceChatService_RateParamsSubAdd_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) - }) - return _c -} - -func (_c *mockOServiceChatService_RateParamsSubAdd_Call) Return() *mockOServiceChatService_RateParamsSubAdd_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceChatService_RateParamsSubAdd_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd)) *mockOServiceChatService_RateParamsSubAdd_Call { - _c.Call.Return(run) - return _c -} - -// SetPrivacyFlags provides a mock function with given fields: ctx, bodyIn -func (_m *mockOServiceChatService) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags) { - _m.Called(ctx, bodyIn) -} - -// mockOServiceChatService_SetPrivacyFlags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetPrivacyFlags' -type mockOServiceChatService_SetPrivacyFlags_Call struct { - *mock.Call -} - -// SetPrivacyFlags is a helper method to define mock.On call -// - ctx context.Context -// - bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags -func (_e *mockOServiceChatService_Expecter) SetPrivacyFlags(ctx interface{}, bodyIn interface{}) *mockOServiceChatService_SetPrivacyFlags_Call { - return &mockOServiceChatService_SetPrivacyFlags_Call{Call: _e.mock.On("SetPrivacyFlags", ctx, bodyIn)} -} - -func (_c *mockOServiceChatService_SetPrivacyFlags_Call) Run(run func(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceChatService_SetPrivacyFlags_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) - }) - return _c -} - -func (_c *mockOServiceChatService_SetPrivacyFlags_Call) Return() *mockOServiceChatService_SetPrivacyFlags_Call { - _c.Call.Return() - return _c -} - -func (_c *mockOServiceChatService_SetPrivacyFlags_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags)) *mockOServiceChatService_SetPrivacyFlags_Call { - _c.Call.Return(run) - return _c -} - -// SetUserInfoFields provides a mock function with given fields: ctx, sess, frame, bodyIn -func (_m *mockOServiceChatService) SetUserInfoFields(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error) { - ret := _m.Called(ctx, sess, frame, bodyIn) - - if len(ret) == 0 { - panic("no return value specified for SetUserInfoFields") - } - - var r0 wire.SNACMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)); ok { - return rf(ctx, sess, frame, bodyIn) - } - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame, bodyIn) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - if rf, ok := ret.Get(1).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) error); ok { - r1 = rf(ctx, sess, frame, bodyIn) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// mockOServiceChatService_SetUserInfoFields_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUserInfoFields' -type mockOServiceChatService_SetUserInfoFields_Call struct { - *mock.Call -} - -// SetUserInfoFields is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -// - bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields -func (_e *mockOServiceChatService_Expecter) SetUserInfoFields(ctx interface{}, sess interface{}, frame interface{}, bodyIn interface{}) *mockOServiceChatService_SetUserInfoFields_Call { - return &mockOServiceChatService_SetUserInfoFields_Call{Call: _e.mock.On("SetUserInfoFields", ctx, sess, frame, bodyIn)} -} - -func (_c *mockOServiceChatService_SetUserInfoFields_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) *mockOServiceChatService_SetUserInfoFields_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame), args[3].(wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields)) - }) - return _c -} - -func (_c *mockOServiceChatService_SetUserInfoFields_Call) Return(_a0 wire.SNACMessage, _a1 error) *mockOServiceChatService_SetUserInfoFields_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *mockOServiceChatService_SetUserInfoFields_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error)) *mockOServiceChatService_SetUserInfoFields_Call { - _c.Call.Return(run) - return _c -} - -// UserInfoQuery provides a mock function with given fields: ctx, sess, frame -func (_m *mockOServiceChatService) UserInfoQuery(ctx context.Context, sess *state.Session, frame wire.SNACFrame) wire.SNACMessage { - ret := _m.Called(ctx, sess, frame) - - if len(ret) == 0 { - panic("no return value specified for UserInfoQuery") - } - - var r0 wire.SNACMessage - if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage); ok { - r0 = rf(ctx, sess, frame) - } else { - r0 = ret.Get(0).(wire.SNACMessage) - } - - return r0 -} - -// mockOServiceChatService_UserInfoQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UserInfoQuery' -type mockOServiceChatService_UserInfoQuery_Call struct { - *mock.Call -} - -// UserInfoQuery is a helper method to define mock.On call -// - ctx context.Context -// - sess *state.Session -// - frame wire.SNACFrame -func (_e *mockOServiceChatService_Expecter) UserInfoQuery(ctx interface{}, sess interface{}, frame interface{}) *mockOServiceChatService_UserInfoQuery_Call { - return &mockOServiceChatService_UserInfoQuery_Call{Call: _e.mock.On("UserInfoQuery", ctx, sess, frame)} -} - -func (_c *mockOServiceChatService_UserInfoQuery_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame)) *mockOServiceChatService_UserInfoQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame)) - }) - return _c -} - -func (_c *mockOServiceChatService_UserInfoQuery_Call) Return(_a0 wire.SNACMessage) *mockOServiceChatService_UserInfoQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *mockOServiceChatService_UserInfoQuery_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame) wire.SNACMessage) *mockOServiceChatService_UserInfoQuery_Call { - _c.Call.Return(run) - return _c -} - -// newMockOServiceChatService creates a new instance of mockOServiceChatService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockOServiceChatService(t interface { - mock.TestingT - Cleanup(func()) -}) *mockOServiceChatService { - mock := &mockOServiceChatService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/oscar/handler/mock_oservice_test.go b/server/oscar/handler/mock_oservice_test.go index 477f2db2..be0732c6 100644 --- a/server/oscar/handler/mock_oservice_test.go +++ b/server/oscar/handler/mock_oservice_test.go @@ -24,6 +24,54 @@ func (_m *mockOServiceService) EXPECT() *mockOServiceService_Expecter { return &mockOServiceService_Expecter{mock: &_m.Mock} } +// ClientOnline provides a mock function with given fields: ctx, bodyIn, sess +func (_m *mockOServiceService) ClientOnline(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session) error { + ret := _m.Called(ctx, bodyIn, sess) + + if len(ret) == 0 { + panic("no return value specified for ClientOnline") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, wire.SNAC_0x01_0x02_OServiceClientOnline, *state.Session) error); ok { + r0 = rf(ctx, bodyIn, sess) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockOServiceService_ClientOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ClientOnline' +type mockOServiceService_ClientOnline_Call struct { + *mock.Call +} + +// ClientOnline is a helper method to define mock.On call +// - ctx context.Context +// - bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline +// - sess *state.Session +func (_e *mockOServiceService_Expecter) ClientOnline(ctx interface{}, bodyIn interface{}, sess interface{}) *mockOServiceService_ClientOnline_Call { + return &mockOServiceService_ClientOnline_Call{Call: _e.mock.On("ClientOnline", ctx, bodyIn, sess)} +} + +func (_c *mockOServiceService_ClientOnline_Call) Run(run func(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session)) *mockOServiceService_ClientOnline_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(wire.SNAC_0x01_0x02_OServiceClientOnline), args[2].(*state.Session)) + }) + return _c +} + +func (_c *mockOServiceService_ClientOnline_Call) Return(_a0 error) *mockOServiceService_ClientOnline_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockOServiceService_ClientOnline_Call) RunAndReturn(run func(context.Context, wire.SNAC_0x01_0x02_OServiceClientOnline, *state.Session) error) *mockOServiceService_ClientOnline_Call { + _c.Call.Return(run) + return _c +} + // ClientVersions provides a mock function with given fields: ctx, frame, bodyIn func (_m *mockOServiceService) ClientVersions(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage { ret := _m.Called(ctx, frame, bodyIn) @@ -72,6 +120,51 @@ func (_c *mockOServiceService_ClientVersions_Call) RunAndReturn(run func(context return _c } +// HostOnline provides a mock function with given fields: +func (_m *mockOServiceService) HostOnline() wire.SNACMessage { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HostOnline") + } + + var r0 wire.SNACMessage + if rf, ok := ret.Get(0).(func() wire.SNACMessage); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(wire.SNACMessage) + } + + return r0 +} + +// mockOServiceService_HostOnline_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HostOnline' +type mockOServiceService_HostOnline_Call struct { + *mock.Call +} + +// HostOnline is a helper method to define mock.On call +func (_e *mockOServiceService_Expecter) HostOnline() *mockOServiceService_HostOnline_Call { + return &mockOServiceService_HostOnline_Call{Call: _e.mock.On("HostOnline")} +} + +func (_c *mockOServiceService_HostOnline_Call) Run(run func()) *mockOServiceService_HostOnline_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *mockOServiceService_HostOnline_Call) Return(_a0 wire.SNACMessage) *mockOServiceService_HostOnline_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockOServiceService_HostOnline_Call) RunAndReturn(run func() wire.SNACMessage) *mockOServiceService_HostOnline_Call { + _c.Call.Return(run) + return _c +} + // IdleNotification provides a mock function with given fields: ctx, sess, bodyIn func (_m *mockOServiceService) IdleNotification(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification) error { ret := _m.Called(ctx, sess, bodyIn) @@ -201,6 +294,65 @@ func (_c *mockOServiceService_RateParamsSubAdd_Call) RunAndReturn(run func(conte return _c } +// ServiceRequest provides a mock function with given fields: ctx, sess, frame, bodyIn +func (_m *mockOServiceService) ServiceRequest(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error) { + ret := _m.Called(ctx, sess, frame, bodyIn) + + if len(ret) == 0 { + panic("no return value specified for ServiceRequest") + } + + var r0 wire.SNACMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error)); ok { + return rf(ctx, sess, frame, bodyIn) + } + if rf, ok := ret.Get(0).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) wire.SNACMessage); ok { + r0 = rf(ctx, sess, frame, bodyIn) + } else { + r0 = ret.Get(0).(wire.SNACMessage) + } + + if rf, ok := ret.Get(1).(func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) error); ok { + r1 = rf(ctx, sess, frame, bodyIn) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// mockOServiceService_ServiceRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ServiceRequest' +type mockOServiceService_ServiceRequest_Call struct { + *mock.Call +} + +// ServiceRequest is a helper method to define mock.On call +// - ctx context.Context +// - sess *state.Session +// - frame wire.SNACFrame +// - bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest +func (_e *mockOServiceService_Expecter) ServiceRequest(ctx interface{}, sess interface{}, frame interface{}, bodyIn interface{}) *mockOServiceService_ServiceRequest_Call { + return &mockOServiceService_ServiceRequest_Call{Call: _e.mock.On("ServiceRequest", ctx, sess, frame, bodyIn)} +} + +func (_c *mockOServiceService_ServiceRequest_Call) Run(run func(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest)) *mockOServiceService_ServiceRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*state.Session), args[2].(wire.SNACFrame), args[3].(wire.SNAC_0x01_0x04_OServiceServiceRequest)) + }) + return _c +} + +func (_c *mockOServiceService_ServiceRequest_Call) Return(_a0 wire.SNACMessage, _a1 error) *mockOServiceService_ServiceRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *mockOServiceService_ServiceRequest_Call) RunAndReturn(run func(context.Context, *state.Session, wire.SNACFrame, wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error)) *mockOServiceService_ServiceRequest_Call { + _c.Call.Return(run) + return _c +} + // SetPrivacyFlags provides a mock function with given fields: ctx, bodyIn func (_m *mockOServiceService) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags) { _m.Called(ctx, bodyIn) diff --git a/server/oscar/handler/oservice.go b/server/oscar/handler/oservice.go index 82b4fa1f..591a9e3e 100644 --- a/server/oscar/handler/oservice.go +++ b/server/oscar/handler/oservice.go @@ -13,36 +13,25 @@ import ( ) type OServiceService interface { + ClientOnline(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session) error ClientVersions(ctx context.Context, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x17_OServiceClientVersions) wire.SNACMessage + HostOnline() wire.SNACMessage IdleNotification(ctx context.Context, sess *state.Session, bodyIn wire.SNAC_0x01_0x11_OServiceIdleNotification) error RateParamsQuery(ctx context.Context, frame wire.SNACFrame) wire.SNACMessage RateParamsSubAdd(context.Context, wire.SNAC_0x01_0x08_OServiceRateParamsSubAdd) + ServiceRequest(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error) SetPrivacyFlags(ctx context.Context, bodyIn wire.SNAC_0x01_0x14_OServiceSetPrivacyFlags) SetUserInfoFields(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x1E_OServiceSetUserInfoFields) (wire.SNACMessage, error) UserInfoQuery(ctx context.Context, sess *state.Session, frame wire.SNACFrame) wire.SNACMessage } -type OServiceBOSService interface { - OServiceService - HostOnline() wire.SNACMessage - ServiceRequest(ctx context.Context, sess *state.Session, frame wire.SNACFrame, bodyIn wire.SNAC_0x01_0x04_OServiceServiceRequest) (wire.SNACMessage, error) - ClientOnline(ctx context.Context, bodyIn wire.SNAC_0x01_0x02_OServiceClientOnline, sess *state.Session) error -} - -type OServiceChatService interface { - OServiceService - HostOnline() wire.SNACMessage - ClientOnline(ctx context.Context, sess *state.Session) error -} - -type OServiceChatNavService interface { - OServiceService - HostOnline() wire.SNACMessage -} - -type OServiceAlertService interface { - OServiceService - HostOnline() wire.SNACMessage +func NewOServiceHandler(logger *slog.Logger, oServiceService OServiceService) OServiceHandler { + return OServiceHandler{ + OServiceService: oServiceService, + RouteLogger: middleware.RouteLogger{ + Logger: logger, + }, + } } type OServiceHandler struct { @@ -120,123 +109,25 @@ func (h OServiceHandler) SetPrivacyFlags(ctx context.Context, sess *state.Sessio return nil } -func NewOServiceHandlerForBOS(logger *slog.Logger, oServiceService OServiceService, oServiceBOSService OServiceBOSService) OServiceBOSHandler { - return OServiceBOSHandler{ - OServiceHandler: OServiceHandler{ - OServiceService: oServiceService, - RouteLogger: middleware.RouteLogger{ - Logger: logger, - }, - }, - OServiceBOSService: oServiceBOSService, - } -} - -type OServiceBOSHandler struct { - OServiceHandler - OServiceBOSService -} - -func (s OServiceBOSHandler) ServiceRequest(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, rw oscar.ResponseWriter) error { +func (h OServiceHandler) ServiceRequest(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, rw oscar.ResponseWriter) error { inBody := wire.SNAC_0x01_0x04_OServiceServiceRequest{} if err := wire.Unmarshal(&inBody, r); err != nil { return err } - outSNAC, err := s.OServiceBOSService.ServiceRequest(ctx, sess, inFrame, inBody) + outSNAC, err := h.OServiceService.ServiceRequest(ctx, sess, inFrame, inBody) if err != nil { return err } - s.LogRequestAndResponse(ctx, inFrame, inBody, outSNAC.Frame, outSNAC.Body) + h.LogRequestAndResponse(ctx, inFrame, inBody, outSNAC.Frame, outSNAC.Body) return rw.SendSNAC(outSNAC.Frame, outSNAC.Body) } -func (s OServiceBOSHandler) ClientOnline(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, _ oscar.ResponseWriter) error { +func (h OServiceHandler) ClientOnline(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, _ oscar.ResponseWriter) error { inBody := wire.SNAC_0x01_0x02_OServiceClientOnline{} if err := wire.Unmarshal(&inBody, r); err != nil { return err } - s.Logger.InfoContext(ctx, "user signed on") - s.LogRequest(ctx, inFrame, inBody) - return s.OServiceBOSService.ClientOnline(ctx, inBody, sess) -} - -func NewOServiceHandlerForChat(logger *slog.Logger, oServiceService OServiceService, oServiceChatService OServiceChatService) OServiceChatHandler { - return OServiceChatHandler{ - OServiceHandler: OServiceHandler{ - OServiceService: oServiceService, - RouteLogger: middleware.RouteLogger{ - Logger: logger, - }, - }, - OServiceChatService: oServiceChatService, - } -} - -type OServiceChatHandler struct { - OServiceHandler - OServiceChatService -} - -func (s OServiceChatHandler) ClientOnline(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, _ oscar.ResponseWriter) error { - inBody := wire.SNAC_0x01_0x02_OServiceClientOnline{} - if err := wire.Unmarshal(&inBody, r); err != nil { - return err - } - s.Logger.InfoContext(ctx, "user signed on") - s.LogRequest(ctx, inFrame, inBody) - return s.OServiceChatService.ClientOnline(ctx, sess) -} - -func NewOServiceHandlerForChatNav(logger *slog.Logger, oServiceService OServiceService, oServiceChatNavService OServiceChatNavService) OServiceChatNavHandler { - return OServiceChatNavHandler{ - OServiceHandler: OServiceHandler{ - OServiceService: oServiceService, - RouteLogger: middleware.RouteLogger{ - Logger: logger, - }, - }, - OServiceChatNavService: oServiceChatNavService, - } -} - -type OServiceChatNavHandler struct { - OServiceHandler - OServiceChatNavService -} - -func (s OServiceChatNavHandler) ClientOnline(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, _ oscar.ResponseWriter) error { - inBody := wire.SNAC_0x01_0x02_OServiceClientOnline{} - if err := wire.Unmarshal(&inBody, r); err != nil { - return err - } - s.Logger.InfoContext(ctx, "user signed on") - s.LogRequest(ctx, inFrame, inBody) - return nil -} - -func NewOServiceHandlerForAlert(logger *slog.Logger, oServiceService OServiceService, oServiceAlertService OServiceAlertService) OServiceAlertHandler { - return OServiceAlertHandler{ - OServiceHandler: OServiceHandler{ - OServiceService: oServiceService, - RouteLogger: middleware.RouteLogger{ - Logger: logger, - }, - }, - OServiceAlertService: oServiceAlertService, - } -} - -type OServiceAlertHandler struct { - OServiceHandler - OServiceAlertService -} - -func (s OServiceAlertHandler) ClientOnline(ctx context.Context, sess *state.Session, inFrame wire.SNACFrame, r io.Reader, _ oscar.ResponseWriter) error { - inBody := wire.SNAC_0x01_0x02_OServiceClientOnline{} - if err := wire.Unmarshal(&inBody, r); err != nil { - return err - } - s.Logger.InfoContext(ctx, "user signed on") - s.LogRequest(ctx, inFrame, inBody) - return nil + h.Logger.InfoContext(ctx, "user signed on") + h.LogRequest(ctx, inFrame, inBody) + return h.OServiceService.ClientOnline(ctx, inBody, sess) } diff --git a/server/oscar/handler/oservice_test.go b/server/oscar/handler/oservice_test.go index aeb4ffb8..55992a30 100644 --- a/server/oscar/handler/oservice_test.go +++ b/server/oscar/handler/oservice_test.go @@ -32,12 +32,12 @@ func TestOServiceBOSHandler_ClientOnline(t *testing.T) { }, } - svc := newMockOServiceBOSService(t) + svc := newMockOServiceService(t) svc.EXPECT(). ClientOnline(mock.Anything, input.Body, mock.Anything). Return(nil) - h := NewOServiceHandlerForBOS(slog.Default(), nil, svc) + h := NewOServiceHandler(slog.Default(), svc) responseWriter := newMockResponseWriter(t) @@ -71,12 +71,12 @@ func TestOServiceBOSHandler_ServiceRequest(t *testing.T) { }, } - svc := newMockOServiceBOSService(t) + svc := newMockOServiceService(t) svc.EXPECT(). ServiceRequest(mock.Anything, mock.Anything, input.Frame, input.Body). Return(output, nil) - h := NewOServiceHandlerForBOS(slog.Default(), nil, svc) + h := NewOServiceHandler(slog.Default(), svc) responseWriter := newMockResponseWriter(t) responseWriter.EXPECT(). @@ -109,12 +109,12 @@ func TestOServiceChatHandler_ClientOnline(t *testing.T) { }, } - svc := newMockOServiceChatService(t) + svc := newMockOServiceService(t) svc.EXPECT(). - ClientOnline(mock.Anything, mock.Anything). + ClientOnline(mock.Anything, mock.Anything, mock.Anything). Return(nil) - h := NewOServiceHandlerForChat(slog.Default(), nil, svc) + h := NewOServiceHandler(slog.Default(), svc) responseWriter := newMockResponseWriter(t) @@ -451,9 +451,11 @@ func TestOServiceChatNavHandler_ClientOnline(t *testing.T) { }, } - svc := newMockOServiceChatNavService(t) - - h := NewOServiceHandlerForChatNav(slog.Default(), nil, svc) + svc := newMockOServiceService(t) + svc.EXPECT(). + ClientOnline(mock.Anything, input.Body, mock.Anything). + Return(nil) + h := NewOServiceHandler(slog.Default(), svc) responseWriter := newMockResponseWriter(t) @@ -483,9 +485,11 @@ func TestOServiceAlertHandler_ClientOnline(t *testing.T) { }, } - svc := newMockOServiceAlertService(t) - - h := NewOServiceHandlerForAlert(slog.Default(), nil, svc) + svc := newMockOServiceService(t) + svc.EXPECT(). + ClientOnline(mock.Anything, input.Body, mock.Anything). + Return(nil) + h := NewOServiceHandler(slog.Default(), svc) responseWriter := newMockResponseWriter(t) diff --git a/server/oscar/handler/routes.go b/server/oscar/handler/routes.go index 41eec13d..0c670ece 100644 --- a/server/oscar/handler/routes.go +++ b/server/oscar/handler/routes.go @@ -18,10 +18,7 @@ type Handlers struct { FeedbagHandler ICBMHandler LocateHandler - OServiceAlertHandler - OServiceBOSHandler - OServiceChatHandler - OServiceChatNavHandler + OServiceHandler PermitDenyHandler } @@ -72,16 +69,16 @@ func NewBOSRouter(h Handlers) oscar.Router { router.Register(wire.PermitDeny, wire.PermitDenyRightsQuery, h.PermitDenyHandler.RightsQuery) - router.Register(wire.OService, wire.OServiceClientOnline, h.OServiceBOSHandler.ClientOnline) - router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceBOSHandler.OServiceHandler.ClientVersions) - router.Register(wire.OService, wire.OServiceIdleNotification, h.OServiceBOSHandler.OServiceHandler.IdleNotification) - router.Register(wire.OService, wire.OServiceNoop, h.OServiceBOSHandler.OServiceHandler.Noop) - router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceBOSHandler.OServiceHandler.RateParamsQuery) - router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceBOSHandler.OServiceHandler.RateParamsSubAdd) - router.Register(wire.OService, wire.OServiceServiceRequest, h.OServiceBOSHandler.ServiceRequest) - router.Register(wire.OService, wire.OServiceSetUserInfoFields, h.OServiceBOSHandler.OServiceHandler.SetUserInfoFields) - router.Register(wire.OService, wire.OServiceUserInfoQuery, h.OServiceBOSHandler.OServiceHandler.UserInfoQuery) - router.Register(wire.OService, wire.OServiceSetPrivacyFlags, h.OServiceBOSHandler.OServiceHandler.SetPrivacyFlags) + router.Register(wire.OService, wire.OServiceClientOnline, h.OServiceHandler.ClientOnline) + router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceHandler.ClientVersions) + router.Register(wire.OService, wire.OServiceIdleNotification, h.OServiceHandler.IdleNotification) + router.Register(wire.OService, wire.OServiceNoop, h.OServiceHandler.Noop) + router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceHandler.RateParamsQuery) + router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceHandler.RateParamsSubAdd) + router.Register(wire.OService, wire.OServiceServiceRequest, h.OServiceHandler.ServiceRequest) + router.Register(wire.OService, wire.OServiceSetUserInfoFields, h.OServiceHandler.SetUserInfoFields) + router.Register(wire.OService, wire.OServiceUserInfoQuery, h.OServiceHandler.UserInfoQuery) + router.Register(wire.OService, wire.OServiceSetPrivacyFlags, h.OServiceHandler.SetPrivacyFlags) return router } @@ -93,13 +90,13 @@ func NewChatRouter(h Handlers) oscar.Router { router.Register(wire.Chat, wire.ChatChannelMsgToHost, h.ChatHandler.ChannelMsgToHost) - router.Register(wire.OService, wire.OServiceClientOnline, h.OServiceChatHandler.ClientOnline) - router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceChatHandler.OServiceHandler.ClientVersions) - router.Register(wire.OService, wire.OServiceIdleNotification, h.OServiceChatHandler.OServiceHandler.IdleNotification) - router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceChatHandler.OServiceHandler.RateParamsQuery) - router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceChatHandler.OServiceHandler.RateParamsSubAdd) - router.Register(wire.OService, wire.OServiceSetUserInfoFields, h.OServiceChatHandler.OServiceHandler.SetUserInfoFields) - router.Register(wire.OService, wire.OServiceUserInfoQuery, h.OServiceChatHandler.OServiceHandler.UserInfoQuery) + router.Register(wire.OService, wire.OServiceClientOnline, h.ClientOnline) + router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceHandler.ClientVersions) + router.Register(wire.OService, wire.OServiceIdleNotification, h.OServiceHandler.IdleNotification) + router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceHandler.RateParamsQuery) + router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceHandler.RateParamsSubAdd) + router.Register(wire.OService, wire.OServiceSetUserInfoFields, h.OServiceHandler.SetUserInfoFields) + router.Register(wire.OService, wire.OServiceUserInfoQuery, h.OServiceHandler.UserInfoQuery) return router } @@ -114,13 +111,13 @@ func NewChatNavRouter(h Handlers) oscar.Router { router.Register(wire.ChatNav, wire.ChatNavRequestExchangeInfo, h.ChatNavHandler.RequestExchangeInfo) router.Register(wire.ChatNav, wire.ChatNavRequestRoomInfo, h.ChatNavHandler.RequestRoomInfo) - router.Register(wire.OService, wire.OServiceClientOnline, h.OServiceChatNavHandler.ClientOnline) - router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceChatNavHandler.OServiceHandler.ClientVersions) - router.Register(wire.OService, wire.OServiceIdleNotification, h.OServiceChatNavHandler.OServiceHandler.IdleNotification) - router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceChatNavHandler.OServiceHandler.RateParamsQuery) - router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceChatNavHandler.OServiceHandler.RateParamsSubAdd) - router.Register(wire.OService, wire.OServiceSetUserInfoFields, h.OServiceChatNavHandler.OServiceHandler.SetUserInfoFields) - router.Register(wire.OService, wire.OServiceUserInfoQuery, h.OServiceChatNavHandler.OServiceHandler.UserInfoQuery) + router.Register(wire.OService, wire.OServiceClientOnline, h.ClientOnline) + router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceHandler.ClientVersions) + router.Register(wire.OService, wire.OServiceIdleNotification, h.OServiceHandler.IdleNotification) + router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceHandler.RateParamsQuery) + router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceHandler.RateParamsSubAdd) + router.Register(wire.OService, wire.OServiceSetUserInfoFields, h.OServiceHandler.SetUserInfoFields) + router.Register(wire.OService, wire.OServiceUserInfoQuery, h.OServiceHandler.UserInfoQuery) return router } @@ -132,10 +129,10 @@ func NewAlertRouter(h Handlers) oscar.Router { router.Register(wire.Alert, wire.AlertNotifyDisplayCapabilities, h.AlertHandler.NotifyDisplayCapabilities) router.Register(wire.Alert, wire.AlertUserOnline, h.AlertHandler.NotifyDisplayCapabilities) - router.Register(wire.OService, wire.OServiceClientOnline, h.OServiceAlertHandler.ClientOnline) - router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceAlertHandler.OServiceHandler.ClientVersions) - router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceAlertHandler.OServiceHandler.RateParamsQuery) - router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceAlertHandler.OServiceHandler.RateParamsSubAdd) + router.Register(wire.OService, wire.OServiceClientOnline, h.ClientOnline) + router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceHandler.ClientVersions) + router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceHandler.RateParamsQuery) + router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceHandler.RateParamsSubAdd) return router } diff --git a/wire/snacs.go b/wire/snacs.go index 10494def..f9a855e2 100644 --- a/wire/snacs.go +++ b/wire/snacs.go @@ -1174,10 +1174,6 @@ const ( AlertUserOnline uint16 = 0x0017 ) -type SNACOServiceErr struct { - Code uint16 -} - type TLVUserInfo struct { ScreenName string `len_prefix:"uint8"` WarningLevel uint16