@@ -118,7 +118,12 @@ public class TransportCreateConnectorActionTests extends OpenSearchTestCase {
118
118
private ArgumentCaptor <PutDataObjectRequest > putDataObjectRequestArgumentCaptor ;
119
119
120
120
private static final List <String > TRUSTED_CONNECTOR_ENDPOINTS_REGEXES = ImmutableList
121
- .of ("^https://runtime\\ .sagemaker\\ ..*\\ .amazonaws\\ .com/.*$" , "^https://api\\ .openai\\ .com/.*$" , "^https://api\\ .cohere\\ .ai/.*$" );
121
+ .of (
122
+ "^https://runtime\\ .sagemaker\\ ..*\\ .amazonaws\\ .com/.*$" ,
123
+ "^https://api\\ .openai\\ .com/.*$" ,
124
+ "^https://api\\ .cohere\\ .ai/.*$" ,
125
+ "^https://api\\ .deepseek\\ .com/.*$"
126
+ );
122
127
123
128
@ Before
124
129
public void setup () {
@@ -539,4 +544,57 @@ public void test_execute_URL_notMatchingExpression_exception() {
539
544
argumentCaptor .getValue ().getMessage ()
540
545
);
541
546
}
547
+
548
+ public void test_connector_creation_success_deepseek () {
549
+ TransportCreateConnectorAction action = new TransportCreateConnectorAction (
550
+ transportService ,
551
+ actionFilters ,
552
+ mlIndicesHandler ,
553
+ client ,
554
+ sdkClient ,
555
+ mlEngine ,
556
+ connectorAccessControlHelper ,
557
+ settings ,
558
+ clusterService ,
559
+ mlModelManager ,
560
+ mlFeatureEnabledSetting
561
+ );
562
+ doAnswer (invocation -> {
563
+ ActionListener <Boolean > listener = invocation .getArgument (0 );
564
+ listener .onResponse (true );
565
+ return null ;
566
+ }).when (mlIndicesHandler ).initMLConnectorIndex (isA (ActionListener .class ));
567
+
568
+ doAnswer (invocation -> {
569
+ ActionListener <IndexResponse > listener = invocation .getArgument (1 );
570
+ listener .onResponse (indexResponse );
571
+ return null ;
572
+ }).when (client ).index (any (IndexRequest .class ), isA (ActionListener .class ));
573
+
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
+
585
+ Map <String , String > credential = ImmutableMap .of ("access_key" , "mockKey" , "secret_key" , "mockSecret" );
586
+ MLCreateConnectorInput mlCreateConnectorInput = MLCreateConnectorInput
587
+ .builder ()
588
+ .name (randomAlphaOfLength (5 ))
589
+ .description (randomAlphaOfLength (10 ))
590
+ .version ("1" )
591
+ .protocol (ConnectorProtocols .HTTP )
592
+ .credential (credential )
593
+ .actions (actions )
594
+ .build ();
595
+
596
+ MLCreateConnectorRequest request = new MLCreateConnectorRequest (mlCreateConnectorInput );
597
+ action .doExecute (task , request , actionListener );
598
+ verify (actionListener ).onResponse (any (MLCreateConnectorResponse .class ));
599
+ }
542
600
}
0 commit comments