13
13
import static org .opensearch .ml .common .CommonValue .ML_CONNECTOR_INDEX ;
14
14
import static org .opensearch .ml .settings .MLCommonsSettings .ML_COMMONS_CONNECTOR_ACCESS_CONTROL_ENABLED ;
15
15
import static org .opensearch .ml .settings .MLCommonsSettings .ML_COMMONS_TRUSTED_CONNECTOR_ENDPOINTS_REGEX ;
16
+ import static org .opensearch .ml .settings .MLCommonsSettings .REKOGNITION_TRUST_ENDPOINT_REGEX ;
16
17
import static org .opensearch .ml .task .MLPredictTaskRunnerTests .USER_STRING ;
17
18
import static org .opensearch .ml .utils .TestHelper .clusterSetting ;
18
19
@@ -122,6 +123,7 @@ public class TransportCreateConnectorActionTests extends OpenSearchTestCase {
122
123
"^https://runtime\\ .sagemaker\\ ..*\\ .amazonaws\\ .com/.*$" ,
123
124
"^https://api\\ .openai\\ .com/.*$" ,
124
125
"^https://api\\ .cohere\\ .ai/.*$" ,
126
+ REKOGNITION_TRUST_ENDPOINT_REGEX ,
125
127
"^https://api\\ .deepseek\\ .com/.*$"
126
128
);
127
129
@@ -559,6 +561,56 @@ public void test_connector_creation_success_deepseek() {
559
561
mlModelManager ,
560
562
mlFeatureEnabledSetting
561
563
);
564
+ doAnswer (invocation -> {
565
+ ActionListener <Boolean > listener = invocation .getArgument (0 );
566
+ listener .onResponse (true );
567
+ return null ;
568
+ }).when (mlIndicesHandler ).initMLConnectorIndex (isA (ActionListener .class ));
569
+ doAnswer (invocation -> {
570
+ ActionListener <IndexResponse > listener = invocation .getArgument (1 );
571
+ listener .onResponse (indexResponse );
572
+ return null ;
573
+ }).when (client ).index (any (IndexRequest .class ), isA (ActionListener .class ));
574
+ List <ConnectorAction > actions = new ArrayList <>();
575
+ actions
576
+ .add (
577
+ ConnectorAction
578
+ .builder ()
579
+ .actionType (ConnectorAction .ActionType .PREDICT )
580
+ .method ("POST" )
581
+ .url ("https://api.deepseek.com/v1/chat/completions" )
582
+ .build ()
583
+ );
584
+ Map <String , String > credential = ImmutableMap .of ("access_key" , "mockKey" , "secret_key" , "mockSecret" );
585
+ MLCreateConnectorInput mlCreateConnectorInput = MLCreateConnectorInput
586
+ .builder ()
587
+ .name (randomAlphaOfLength (5 ))
588
+ .description (randomAlphaOfLength (10 ))
589
+ .version ("1" )
590
+ .protocol (ConnectorProtocols .HTTP )
591
+ .credential (credential )
592
+ .actions (actions )
593
+ .build ();
594
+ MLCreateConnectorRequest request = new MLCreateConnectorRequest (mlCreateConnectorInput );
595
+ action .doExecute (task , request , actionListener );
596
+ verify (actionListener ).onResponse (any (MLCreateConnectorResponse .class ));
597
+ }
598
+
599
+ public void test_connector_creation_success_rekognition () {
600
+ TransportCreateConnectorAction action = new TransportCreateConnectorAction (
601
+ transportService ,
602
+ actionFilters ,
603
+ mlIndicesHandler ,
604
+ client ,
605
+ sdkClient ,
606
+ mlEngine ,
607
+ connectorAccessControlHelper ,
608
+ settings ,
609
+ clusterService ,
610
+ mlModelManager ,
611
+ mlFeatureEnabledSetting
612
+ );
613
+
562
614
doAnswer (invocation -> {
563
615
ActionListener <Boolean > listener = invocation .getArgument (0 );
564
616
listener .onResponse (true );
@@ -578,7 +630,16 @@ public void test_connector_creation_success_deepseek() {
578
630
.builder ()
579
631
.actionType (ConnectorAction .ActionType .PREDICT )
580
632
.method ("POST" )
581
- .url ("https://api.deepseek.com/v1/chat/completions" )
633
+ .url ("https://rekognition.test-region-1.amazonaws.com" )
634
+ .build ()
635
+ );
636
+ actions
637
+ .add (
638
+ ConnectorAction
639
+ .builder ()
640
+ .actionType (ConnectorAction .ActionType .PREDICT )
641
+ .method ("POST" )
642
+ .url ("https://rekognition-fips.test-region-1.amazonaws.com" )
582
643
.build ()
583
644
);
584
645
@@ -594,6 +655,7 @@ public void test_connector_creation_success_deepseek() {
594
655
.build ();
595
656
596
657
MLCreateConnectorRequest request = new MLCreateConnectorRequest (mlCreateConnectorInput );
658
+
597
659
action .doExecute (task , request , actionListener );
598
660
verify (actionListener ).onResponse (any (MLCreateConnectorResponse .class ));
599
661
}
0 commit comments