@@ -192,6 +192,61 @@ void afterEach() {
192192 }
193193 """ ;
194194
195+ private static final String GET_INTEGRATIONS_BODY = """
196+ {
197+ "jsonrpc": "2.0",
198+ "method": "tools/call",
199+ "id": 9,
200+ "params": {
201+ "name": "getIntegrations",
202+ "arguments": {}
203+ }
204+ }
205+ """ ;
206+
207+ private static final String GET_INTEGRATION_BODY = """
208+ {
209+ "jsonrpc": "2.0",
210+ "method": "tools/call",
211+ "id": 10,
212+ "params": {
213+ "name": "getIntegration",
214+ "arguments": {
215+ "id": "12345678-abcd-1234-abcd-1234567890ab"
216+ }
217+ }
218+ }
219+ """ ;
220+
221+ private static final String GET_INTEGRATION_HISTORY_BODY = """
222+ {
223+ "jsonrpc": "2.0",
224+ "method": "tools/call",
225+ "id": 11,
226+ "params": {
227+ "name": "getIntegrationHistory",
228+ "arguments": {
229+ "id": "12345678-abcd-1234-abcd-1234567890ab"
230+ }
231+ }
232+ }
233+ """ ;
234+
235+ private static final String GET_INTEGRATION_HISTORY_DETAILS_BODY = """
236+ {
237+ "jsonrpc": "2.0",
238+ "method": "tools/call",
239+ "id": 12,
240+ "params": {
241+ "name": "getIntegrationHistoryDetails",
242+ "arguments": {
243+ "integrationId": "12345678-abcd-1234-abcd-1234567890ab",
244+ "historyId": "abcd1234-abcd-1234-abcd-1234567890ab"
245+ }
246+ }
247+ }
248+ """ ;
249+
195250 // --- Helpers ---
196251
197252 private static String validIdentity () {
@@ -311,9 +366,10 @@ public void testMcpInitializeWithEmptyUsernameIsRejected() {
311366 public void testToolsListWithValidIdentity () {
312367 postMcp (validIdentity (), TOOLS_LIST_BODY )
313368 .statusCode (200 )
314- .body ("result.tools.size()" , greaterThanOrEqualTo (6 ))
369+ .body ("result.tools.size()" , greaterThanOrEqualTo (10 ))
315370 .body ("result.tools.name" , hasItems ("serverInfo" , "whoami" , "getSeverities" ,
316- "getBundle" , "getApplication" , "getEventType" ));
371+ "getBundle" , "getApplication" , "getEventType" ,
372+ "getIntegrations" , "getIntegration" , "getIntegrationHistory" , "getIntegrationHistoryDetails" ));
317373 }
318374
319375 @ Test
@@ -554,6 +610,182 @@ public void testGetEventTypeWhenBackendReturns404() {
554610 micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
555611 }
556612
613+ // --- getIntegrations tool tests ---
614+
615+ @ Test
616+ public void testGetIntegrationsWithValidIdentity () {
617+ String integrationsJson = "{\" data\" :[{\" id\" :\" 12345678-abcd-1234-abcd-1234567890ab\" ,\" name\" :\" My Webhook\" ,\" type\" :\" webhook\" }],\" meta\" :{\" count\" :1},\" links\" :{}}" ;
618+ MockServerLifecycleManager .getClient ().stubFor (
619+ get (urlPathEqualTo ("/api/integrations/v2.0/endpoints" ))
620+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
621+ .willReturn (aResponse ()
622+ .withHeader ("Content-Type" , "application/json" )
623+ .withBody (integrationsJson ))
624+ );
625+
626+ postMcp (validIdentity (), GET_INTEGRATIONS_BODY )
627+ .statusCode (200 )
628+ .body ("result.content[0].text" , containsString ("My Webhook" ))
629+ .body ("result.content[0].text" , containsString ("webhook" ));
630+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
631+
632+ MockServerLifecycleManager .getClient ().verify (
633+ getRequestedFor (urlPathEqualTo ("/api/integrations/v2.0/endpoints" ))
634+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
635+ );
636+ }
637+
638+ @ Test
639+ public void testGetIntegrationsWithoutIdentityIsRejected () {
640+ postMcp (null , GET_INTEGRATIONS_BODY ).statusCode (401 );
641+ }
642+
643+ @ Test
644+ public void testGetIntegrationsWhenBackendReturns404 () {
645+ MockServerLifecycleManager .getClient ().stubFor (
646+ get (urlPathEqualTo ("/api/integrations/v2.0/endpoints" ))
647+ .willReturn (aResponse ().withStatus (404 ))
648+ );
649+
650+ postMcp (validIdentity (), GET_INTEGRATIONS_BODY )
651+ .statusCode (200 )
652+ .body ("result.isError" , is (true ))
653+ .body ("result.content[0].text" , containsString ("Resource not found" ));
654+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
655+ }
656+
657+ // --- getIntegration tool tests ---
658+
659+ @ Test
660+ public void testGetIntegrationWithValidIdentity () {
661+ String integrationJson = "{\" id\" :\" 12345678-abcd-1234-abcd-1234567890ab\" ,\" name\" :\" My Webhook\" ,\" type\" :\" webhook\" ,\" enabled\" :true}" ;
662+ MockServerLifecycleManager .getClient ().stubFor (
663+ get (urlPathEqualTo ("/api/integrations/v2.0/endpoints/12345678-abcd-1234-abcd-1234567890ab" ))
664+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
665+ .willReturn (aResponse ()
666+ .withHeader ("Content-Type" , "application/json" )
667+ .withBody (integrationJson ))
668+ );
669+
670+ postMcp (validIdentity (), GET_INTEGRATION_BODY )
671+ .statusCode (200 )
672+ .body ("result.content[0].text" , containsString ("My Webhook" ))
673+ .body ("result.content[0].text" , containsString ("12345678-abcd-1234-abcd-1234567890ab" ));
674+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
675+
676+ MockServerLifecycleManager .getClient ().verify (
677+ getRequestedFor (urlPathEqualTo ("/api/integrations/v2.0/endpoints/12345678-abcd-1234-abcd-1234567890ab" ))
678+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
679+ );
680+ }
681+
682+ @ Test
683+ public void testGetIntegrationWithoutIdentityIsRejected () {
684+ postMcp (null , GET_INTEGRATION_BODY ).statusCode (401 );
685+ }
686+
687+ @ Test
688+ public void testGetIntegrationWhenBackendReturns404 () {
689+ MockServerLifecycleManager .getClient ().stubFor (
690+ get (urlPathEqualTo ("/api/integrations/v2.0/endpoints/12345678-abcd-1234-abcd-1234567890ab" ))
691+ .willReturn (aResponse ().withStatus (404 ))
692+ );
693+
694+ postMcp (validIdentity (), GET_INTEGRATION_BODY )
695+ .statusCode (200 )
696+ .body ("result.isError" , is (true ))
697+ .body ("result.content[0].text" , containsString ("Resource not found" ));
698+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
699+ }
700+
701+ // --- getIntegrationHistory tool tests ---
702+
703+ @ Test
704+ public void testGetIntegrationHistoryWithValidIdentity () {
705+ String historyJson = "{\" data\" :[{\" id\" :\" abcd1234-abcd-1234-abcd-1234567890ab\" ,\" status\" :\" SUCCESS\" }],\" meta\" :{\" count\" :1},\" links\" :{}}" ;
706+ MockServerLifecycleManager .getClient ().stubFor (
707+ get (urlPathEqualTo ("/api/integrations/v2.0/endpoints/12345678-abcd-1234-abcd-1234567890ab/history" ))
708+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
709+ .willReturn (aResponse ()
710+ .withHeader ("Content-Type" , "application/json" )
711+ .withBody (historyJson ))
712+ );
713+
714+ postMcp (validIdentity (), GET_INTEGRATION_HISTORY_BODY )
715+ .statusCode (200 )
716+ .body ("result.content[0].text" , containsString ("SUCCESS" ))
717+ .body ("result.content[0].text" , containsString ("abcd1234" ));
718+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
719+
720+ MockServerLifecycleManager .getClient ().verify (
721+ getRequestedFor (urlPathEqualTo ("/api/integrations/v2.0/endpoints/12345678-abcd-1234-abcd-1234567890ab/history" ))
722+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
723+ );
724+ }
725+
726+ @ Test
727+ public void testGetIntegrationHistoryWithoutIdentityIsRejected () {
728+ postMcp (null , GET_INTEGRATION_HISTORY_BODY ).statusCode (401 );
729+ }
730+
731+ @ Test
732+ public void testGetIntegrationHistoryWhenBackendReturns404 () {
733+ MockServerLifecycleManager .getClient ().stubFor (
734+ get (urlPathEqualTo ("/api/integrations/v2.0/endpoints/12345678-abcd-1234-abcd-1234567890ab/history" ))
735+ .willReturn (aResponse ().withStatus (404 ))
736+ );
737+
738+ postMcp (validIdentity (), GET_INTEGRATION_HISTORY_BODY )
739+ .statusCode (200 )
740+ .body ("result.isError" , is (true ))
741+ .body ("result.content[0].text" , containsString ("Resource not found" ));
742+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
743+ }
744+
745+ // --- getIntegrationHistoryDetails tool tests ---
746+
747+ @ Test
748+ public void testGetIntegrationHistoryDetailsWithValidIdentity () {
749+ String detailsJson = "{\" type\" :\" com.redhat.console.notification.toCamel.webhook\" ,\" target\" :\" https://example.com/hook\" ,\" outcome\" :\" SUCCESS\" }" ;
750+ MockServerLifecycleManager .getClient ().stubFor (
751+ get (urlPathEqualTo ("/api/integrations/v1.0/endpoints/12345678-abcd-1234-abcd-1234567890ab/history/abcd1234-abcd-1234-abcd-1234567890ab/details" ))
752+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
753+ .willReturn (aResponse ()
754+ .withHeader ("Content-Type" , "application/json" )
755+ .withBody (detailsJson ))
756+ );
757+
758+ postMcp (validIdentity (), GET_INTEGRATION_HISTORY_DETAILS_BODY )
759+ .statusCode (200 )
760+ .body ("result.content[0].text" , containsString ("webhook" ))
761+ .body ("result.content[0].text" , containsString ("SUCCESS" ));
762+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
763+
764+ MockServerLifecycleManager .getClient ().verify (
765+ getRequestedFor (urlPathEqualTo ("/api/integrations/v1.0/endpoints/12345678-abcd-1234-abcd-1234567890ab/history/abcd1234-abcd-1234-abcd-1234567890ab/details" ))
766+ .withHeader ("x-rh-identity" , equalTo (validIdentity ()))
767+ );
768+ }
769+
770+ @ Test
771+ public void testGetIntegrationHistoryDetailsWithoutIdentityIsRejected () {
772+ postMcp (null , GET_INTEGRATION_HISTORY_DETAILS_BODY ).statusCode (401 );
773+ }
774+
775+ @ Test
776+ public void testGetIntegrationHistoryDetailsWhenBackendReturns404 () {
777+ MockServerLifecycleManager .getClient ().stubFor (
778+ get (urlPathEqualTo ("/api/integrations/v1.0/endpoints/12345678-abcd-1234-abcd-1234567890ab/history/abcd1234-abcd-1234-abcd-1234567890ab/details" ))
779+ .willReturn (aResponse ().withStatus (404 ))
780+ );
781+
782+ postMcp (validIdentity (), GET_INTEGRATION_HISTORY_DETAILS_BODY )
783+ .statusCode (200 )
784+ .body ("result.isError" , is (true ))
785+ .body ("result.content[0].text" , containsString ("Resource not found" ));
786+ micrometerAssertionHelper .assertCounterIncrement (AUTH_SUCCESS_COUNTER , 1 );
787+ }
788+
557789 // --- Health/metrics bypass tests ---
558790
559791 @ Test
0 commit comments