@@ -135,7 +135,11 @@ Cypress.Commands.add('registerRootAgent', () => {
135135} ) ;
136136
137137Cypress . Commands . add ( 'putRootAgentId' , ( agentId ) => {
138- if ( Cypress . env ( 'SECURITY_ENABLED' ) ) {
138+ // When enabling the DATASOURCE-MANAGEment-ENABLED flag, we need to config the root agent ID in a no auth data source.
139+ if (
140+ Cypress . env ( 'SECURITY_ENABLED' ) &&
141+ ! Cypress . env ( 'DATASOURCE_MANAGEMENT_ENABLED' )
142+ ) {
139143 // The .plugins-ml-config index is a system index and need to call the API by using certificate file
140144 return cy . exec (
141145 `curl -k --cert <(cat <<EOF \n${ certPublicKeyContent } \nEOF\n) --key <(cat <<EOF\n${ certPrivateKeyContent } \nEOF\n) -XPUT '${ BACKEND_BASE_PATH } ${ ML_COMMONS_API . UPDATE_ROOT_AGENT_CONFIG } ' -H 'Content-Type: application/json' -d '{"type":"os_chat_root_agent","configuration":{"agent_id":"${ agentId } "}}'`
@@ -193,13 +197,33 @@ Cypress.Commands.add('stopDummyServer', () => {
193197 } ) ;
194198} ) ;
195199
196- Cypress . Commands . add ( 'sendAssistantMessage' , ( body ) =>
197- apiRequest ( `${ BASE_PATH } ${ ASSISTANT_API . SEND_MESSAGE } ` , 'POST' , body )
198- ) ;
200+ Cypress . Commands . add ( 'sendAssistantMessage' , ( body , dataSourceId ) => {
201+ const url = `${ BASE_PATH } ${ ASSISTANT_API . SEND_MESSAGE } ` ;
202+ const qs = { dataSourceId : dataSourceId } ;
203+ apiRequest ( url , 'POST' , body , qs ) ;
204+ } ) ;
199205
200- Cypress . Commands . add ( 'deleteConversation' , ( conversationId ) =>
201- apiRequest (
202- `${ BASE_PATH } ${ ASSISTANT_API . CONVERSATION } /${ conversationId } ` ,
203- 'DELETE'
204- )
205- ) ;
206+ Cypress . Commands . add ( 'deleteConversation' , ( conversationId , dataSourceId ) => {
207+ const url = `${ BASE_PATH } ${ ASSISTANT_API . CONVERSATION } /${ conversationId } ` ;
208+ const qs = { dataSourceId : dataSourceId } ;
209+ apiRequest ( url , 'DELETE' , undefined , qs ) ;
210+ } ) ;
211+
212+ Cypress . Commands . add ( 'setDefaultDataSourceForAssistant' , ( ) => {
213+ if ( Cypress . env ( 'DATASOURCE_MANAGEMENT_ENABLED' ) ) {
214+ cy . deleteAllDataSources ( ) ;
215+ // create data source
216+ cy . createDataSourceNoAuth ( ) . then ( ( result ) => {
217+ const dataSourceId = result [ 0 ] ;
218+ // set default data source
219+ cy . setDefaultDataSource ( dataSourceId ) ;
220+ return cy . wrap ( dataSourceId ) ;
221+ } ) ;
222+ }
223+ } ) ;
224+
225+ Cypress . Commands . add ( 'clearDataSourceForAssistant' , ( ) => {
226+ if ( Cypress . env ( 'DATASOURCE_MANAGEMENT_ENABLED' ) ) {
227+ cy . deleteAllDataSources ( ) ;
228+ }
229+ } ) ;
0 commit comments