@@ -247,6 +247,57 @@ void afterEach() {
247247 }
248248 """ ;
249249
250+ private static final String GET_EVENTS_BODY = """
251+ {
252+ "jsonrpc": "2.0",
253+ "method": "tools/call",
254+ "id": 13,
255+ "params": {
256+ "name": "getEvents",
257+ "arguments": {}
258+ }
259+ }
260+ """ ;
261+
262+ private static final String GET_DAILY_DIGEST_TIME_PREFERENCE_BODY = """
263+ {
264+ "jsonrpc": "2.0",
265+ "method": "tools/call",
266+ "id": 14,
267+ "params": {
268+ "name": "getDailyDigestTimePreference",
269+ "arguments": {}
270+ }
271+ }
272+ """ ;
273+
274+ private static final String GET_USER_NOTIFICATION_PREFERENCES_BODY = """
275+ {
276+ "jsonrpc": "2.0",
277+ "method": "tools/call",
278+ "id": 15,
279+ "params": {
280+ "name": "getUserNotificationPreferences",
281+ "arguments": {}
282+ }
283+ }
284+ """ ;
285+
286+ private static final String GET_USER_NOTIFICATION_PREFERENCES_BY_APP_BODY = """
287+ {
288+ "jsonrpc": "2.0",
289+ "method": "tools/call",
290+ "id": 16,
291+ "params": {
292+ "name": "getUserNotificationPreferencesByApplication",
293+ "arguments": {
294+ "bundleName": "rhel",
295+ "applicationName": "patch"
296+ }
297+ }
298+ }
299+ """ ;
300+
250301 // --- Helpers ---
251302
252303 private static String validIdentity () {
@@ -366,10 +417,12 @@ public void testMcpInitializeWithEmptyUsernameIsRejected() {
366417 public void testToolsListWithValidIdentity () {
367418 postMcp (validIdentity (), TOOLS_LIST_BODY )
368419 .statusCode (200 )
369- .body ("result.tools.size()" , greaterThanOrEqualTo (10 ))
420+ .body ("result.tools.size()" , greaterThanOrEqualTo (14 ))
370421 .body ("result.tools.name" , hasItems ("serverInfo" , "whoami" , "getSeverities" ,
371422 "getBundle" , "getApplication" , "getEventType" ,
372- "getIntegrations" , "getIntegration" , "getIntegrationHistory" , "getIntegrationHistoryDetails" ));
423+ "getIntegrations" , "getIntegration" , "getIntegrationHistory" , "getIntegrationHistoryDetails" ,
424+ "getEvents" , "getDailyDigestTimePreference" ,
425+ "getUserNotificationPreferences" , "getUserNotificationPreferencesByApplication" ));
373426 }
374427
375428 @ Test
@@ -786,6 +839,182 @@ public void testGetIntegrationHistoryDetailsWhenBackendReturns404() {
786839 micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
787840 }
788841
842+ // --- getEvents tool tests ---
843+
844+ @ Test
845+ public void testGetEventsWithValidIdentity () {
846+ String eventsJson = "{\" data\" :[{\" id\" :\" 11111111-1111-1111-1111-111111111111\" ,\" bundle\" :\" rhel\" ,\" application\" :\" patch\" ,\" event_type\" :\" New advisory\" ,\" created\" :\" 2026-05-12T10:00:00\" }],\" meta\" :{\" count\" :1},\" links\" :{}}" ;
847+ MockServerLifecycleManager .getClient ().stubFor (
848+ get (urlPathEqualTo ("/api/notifications/v1.0/notifications/events" ))
849+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
850+ .willReturn (aResponse ()
851+ .withHeader ("Content-Type" , "application/json" )
852+ .withBody (eventsJson ))
853+ );
854+
855+ postMcp (validIdentity (), GET_EVENTS_BODY )
856+ .statusCode (200 )
857+ .body ("result.content[0].text" , containsString ("rhel" ))
858+ .body ("result.content[0].text" , containsString ("patch" ))
859+ .body ("result.content[0].text" , containsString ("New advisory" ));
860+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
861+
862+ MockServerLifecycleManager .getClient ().verify (
863+ getRequestedFor (urlPathEqualTo ("/api/notifications/v1.0/notifications/events" ))
864+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
865+ );
866+ }
867+
868+ @ Test
869+ public void testGetEventsWithoutIdentityIsRejected () {
870+ postMcp (null , GET_EVENTS_BODY ).statusCode (401 );
871+ }
872+
873+ @ Test
874+ public void testGetEventsWhenBackendReturns404 () {
875+ MockServerLifecycleManager .getClient ().stubFor (
876+ get (urlPathEqualTo ("/api/notifications/v1.0/notifications/events" ))
877+ .willReturn (aResponse ().withStatus (404 ))
878+ );
879+
880+ postMcp (validIdentity (), GET_EVENTS_BODY )
881+ .statusCode (200 )
882+ .body ("result.isError" , is (true ))
883+ .body ("result.content[0].text" , containsString ("Resource not found" ));
884+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
885+ }
886+
887+ // --- getDailyDigestTimePreference tool tests ---
888+
889+ @ Test
890+ public void testGetDailyDigestTimePreferenceWithValidIdentity () {
891+ String timeJson = "\" 09:00\" " ;
892+ MockServerLifecycleManager .getClient ().stubFor (
893+ get (urlPathEqualTo ("/api/notifications/v1.0/org-config/daily-digest/time-preference" ))
894+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
895+ .willReturn (aResponse ()
896+ .withHeader ("Content-Type" , "application/json" )
897+ .withBody (timeJson ))
898+ );
899+
900+ postMcp (validIdentity (), GET_DAILY_DIGEST_TIME_PREFERENCE_BODY )
901+ .statusCode (200 )
902+ .body ("result.content[0].text" , containsString ("09:00" ));
903+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
904+
905+ MockServerLifecycleManager .getClient ().verify (
906+ getRequestedFor (urlPathEqualTo ("/api/notifications/v1.0/org-config/daily-digest/time-preference" ))
907+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
908+ );
909+ }
910+
911+ @ Test
912+ public void testGetDailyDigestTimePreferenceWithoutIdentityIsRejected () {
913+ postMcp (null , GET_DAILY_DIGEST_TIME_PREFERENCE_BODY ).statusCode (401 );
914+ }
915+
916+ @ Test
917+ public void testGetDailyDigestTimePreferenceWhenBackendReturns404 () {
918+ MockServerLifecycleManager .getClient ().stubFor (
919+ get (urlPathEqualTo ("/api/notifications/v1.0/org-config/daily-digest/time-preference" ))
920+ .willReturn (aResponse ().withStatus (404 ))
921+ );
922+
923+ postMcp (validIdentity (), GET_DAILY_DIGEST_TIME_PREFERENCE_BODY )
924+ .statusCode (200 )
925+ .body ("result.isError" , is (true ))
926+ .body ("result.content[0].text" , containsString ("Resource not found" ));
927+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
928+ }
929+
930+ // --- getUserNotificationPreferences tool tests ---
931+
932+ @ Test
933+ public void testGetUserNotificationPreferencesWithValidIdentity () {
934+ String prefsJson = "{\" bundles\" :{\" rhel\" :{\" display_name\" :\" Red Hat Enterprise Linux\" ,\" applications\" :{}}}}" ;
935+ MockServerLifecycleManager .getClient ().stubFor (
936+ get (urlPathEqualTo ("/api/notifications/v1.0/user-config/notification-event-type-preference" ))
937+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
938+ .willReturn (aResponse ()
939+ .withHeader ("Content-Type" , "application/json" )
940+ .withBody (prefsJson ))
941+ );
942+
943+ postMcp (validIdentity (), GET_USER_NOTIFICATION_PREFERENCES_BODY )
944+ .statusCode (200 )
945+ .body ("result.content[0].text" , containsString ("rhel" ))
946+ .body ("result.content[0].text" , containsString ("Red Hat Enterprise Linux" ));
947+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
948+
949+ MockServerLifecycleManager .getClient ().verify (
950+ getRequestedFor (urlPathEqualTo ("/api/notifications/v1.0/user-config/notification-event-type-preference" ))
951+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
952+ );
953+ }
954+
955+ @ Test
956+ public void testGetUserNotificationPreferencesWithoutIdentityIsRejected () {
957+ postMcp (null , GET_USER_NOTIFICATION_PREFERENCES_BODY ).statusCode (401 );
958+ }
959+
960+ @ Test
961+ public void testGetUserNotificationPreferencesWhenBackendReturns404 () {
962+ MockServerLifecycleManager .getClient ().stubFor (
963+ get (urlPathEqualTo ("/api/notifications/v1.0/user-config/notification-event-type-preference" ))
964+ .willReturn (aResponse ().withStatus (404 ))
965+ );
966+
967+ postMcp (validIdentity (), GET_USER_NOTIFICATION_PREFERENCES_BODY )
968+ .statusCode (200 )
969+ .body ("result.isError" , is (true ))
970+ .body ("result.content[0].text" , containsString ("Resource not found" ));
971+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
972+ }
973+
974+ // --- getUserNotificationPreferencesByApplication tool tests ---
975+
976+ @ Test
977+ public void testGetUserNotificationPreferencesByApplicationWithValidIdentity () {
978+ String appPrefsJson = "{\" display_name\" :\" Patch\" ,\" event_types\" :{\" new-advisory\" :{\" display_name\" :\" New advisory\" }}}" ;
979+ MockServerLifecycleManager .getClient ().stubFor (
980+ get (urlPathEqualTo ("/api/notifications/v1.0/user-config/notification-event-type-preference/rhel/patch" ))
981+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
982+ .willReturn (aResponse ()
983+ .withHeader ("Content-Type" , "application/json" )
984+ .withBody (appPrefsJson ))
985+ );
986+
987+ postMcp (validIdentity (), GET_USER_NOTIFICATION_PREFERENCES_BY_APP_BODY )
988+ .statusCode (200 )
989+ .body ("result.content[0].text" , containsString ("Patch" ))
990+ .body ("result.content[0].text" , containsString ("New advisory" ));
991+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
992+
993+ MockServerLifecycleManager .getClient ().verify (
994+ getRequestedFor (urlPathEqualTo ("/api/notifications/v1.0/user-config/notification-event-type-preference/rhel/patch" ))
995+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
996+ );
997+ }
998+
999+ @ Test
1000+ public void testGetUserNotificationPreferencesByApplicationWithoutIdentityIsRejected () {
1001+ postMcp (null , GET_USER_NOTIFICATION_PREFERENCES_BY_APP_BODY ).statusCode (401 );
1002+ }
1003+
1004+ @ Test
1005+ public void testGetUserNotificationPreferencesByApplicationWhenBackendReturns404 () {
1006+ MockServerLifecycleManager .getClient ().stubFor (
1007+ get (urlPathEqualTo ("/api/notifications/v1.0/user-config/notification-event-type-preference/rhel/patch" ))
1008+ .willReturn (aResponse ().withStatus (404 ))
1009+ );
1010+
1011+ postMcp (validIdentity (), GET_USER_NOTIFICATION_PREFERENCES_BY_APP_BODY )
1012+ .statusCode (200 )
1013+ .body ("result.isError" , is (true ))
1014+ .body ("result.content[0].text" , containsString ("Resource not found" ));
1015+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
1016+ }
1017+
7891018 // --- Health/metrics bypass tests ---
7901019
7911020 @ Test
0 commit comments