Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Connector APIs] Enforce index prefix for managed connectors #117778

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ tests:
- class: org.elasticsearch.search.SearchServiceTests
method: testParseSourceValidation
issue: https://github.com/elastic/elasticsearch/issues/115936
- class: org.elasticsearch.xpack.application.connector.ConnectorIndexServiceTests
issue: https://github.com/elastic/elasticsearch/issues/116087
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
method: test {p0=cat.shards/10_basic/Help}
issue: https://github.com/elastic/elasticsearch/issues/116110
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ setup:
connector.put:
connector_id: test-connector-native
body:
index_name: search-test
index_name: content-search-test
is_native: true

- match: { result: 'created' }
Expand All @@ -68,7 +68,7 @@ setup:
connector_id: test-connector-native

- match: { id: test-connector-native }
- match: { index_name: search-test }
- match: { index_name: content-search-test }
- match: { is_native: true }
- match: { sync_now: false }
- match: { status: needs_configuration }
Expand Down Expand Up @@ -151,6 +151,19 @@ setup:
is_native: false
service_type: super-connector

---
'Create Connector - Invalid Managed Connector Index Prefix':
- do:
catch: "bad_request"
connector.put:
connector_id: test-connector-test-managed
body:
index_name: wrong-prefix-index
name: my-connector
language: pl
is_native: true
service_type: super-connector

---
'Create Connector - Id returned as part of response':
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,45 @@ setup:
connector_id: test-connector

- match: { index_name: search-1-test }


---
"Update Managed Connector Index Name":
- do:
connector.put:
connector_id: test-connector-1
body:
is_native: true
service_type: super-connector

- do:
connector.update_index_name:
connector_id: test-connector-1
body:
index_name: content-search-2-test


- match: { result: updated }

- do:
connector.get:
connector_id: test-connector-1

- match: { index_name: content-search-2-test }


---
"Update Managed Connector Index Name - Bad Prefix":
- do:
connector.put:
connector_id: test-connector-2
body:
is_native: true
service_type: super-connector

- do:
catch: "bad_request"
connector.update_index_name:
connector_id: test-connector-2
body:
index_name: wrong-prefix-search-2-test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ setup:
connector.put:
connector_id: test-connector
body:
index_name: search-1-test
index_name: content-search-1-test
name: my-connector
language: pl
is_native: false
Expand All @@ -29,7 +29,6 @@ setup:
connector_id: test-connector

- match: { is_native: true }
- match: { status: configured }

- do:
connector.update_native:
Expand All @@ -44,7 +43,6 @@ setup:
connector_id: test-connector

- match: { is_native: false }
- match: { status: configured }

---
"Update Connector Native - 404 when connector doesn't exist":
Expand Down Expand Up @@ -75,3 +73,43 @@ setup:
field_1: test
field_2: something

---
"Update Connector Native - changing connector to Elastic-managed wrong index name":

- do:
connector.put:
connector_id: test-connector-1
body:
is_native: false
index_name: super-connector

- do:
catch: "bad_request"
connector.update_native:
connector_id: test-connector-1
body:
is_native: true

---
"Update Connector Native - changing connector to Elastic-managed correct index name":

- do:
connector.put:
connector_id: test-connector-1
body:
is_native: false
index_name: content-super-connector

- do:
connector.update_native:
connector_id: test-connector-1
body:
is_native: true

- match: { result: updated }

- do:
connector.get:
connector_id: test-connector-1

- match: { is_native: true }
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ setup:
- do:
connector.post:
body:
index_name: search-test
index_name: content-search-test
is_native: true

- set: { id: id }
Expand All @@ -82,7 +82,7 @@ setup:
connector_id: $id

- match: { id: $id }
- match: { index_name: search-test }
- match: { index_name: content-search-test }
- match: { is_native: true }
- match: { sync_now: false }
- match: { status: needs_configuration }
Expand All @@ -102,6 +102,18 @@ setup:
is_native: false
service_type: super-connector

---
'Create Connector - Invalid Managed Connector Index Prefix':
- do:
catch: "bad_request"
connector.post:
body:
index_name: wrong-prefix-index
name: my-connector
language: pl
is_native: true
service_type: super-connector

---
'Create Connector - Index name used by another connector':
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ setup:
connector.put:
connector_id: connector-b
body:
index_name: search-2-test
index_name: content-search-2-test
name: my-connector-2
language: en
is_native: true
Expand All @@ -40,13 +40,13 @@ setup:
- match: { count: 3 }

# Alphabetical order by index_name for results
- match: { results.0.id: "connector-a" }
- match: { results.0.index_name: "search-1-test" }
- match: { results.0.language: "pl" }
- match: { results.0.id: "connector-b" }
Copy link
Member Author

@jedrazb jedrazb Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content- index is first alphabetically so order of list API results changes (we sort by index_name by default)

- match: { results.0.index_name: "content-search-2-test" }
- match: { results.0.language: "en" }

- match: { results.1.id: "connector-b" }
- match: { results.1.index_name: "search-2-test" }
- match: { results.1.language: "en" }
- match: { results.1.id: "connector-a" }
- match: { results.1.index_name: "search-1-test" }
- match: { results.1.language: "pl" }

- match: { results.2.id: "connector-c" }
- match: { results.2.index_name: "search-3-test" }
Expand All @@ -62,9 +62,9 @@ setup:
- match: { count: 3 }

# Alphabetical order by index_name for results
- match: { results.0.id: "connector-b" }
- match: { results.0.index_name: "search-2-test" }
- match: { results.0.language: "en" }
- match: { results.0.id: "connector-a" }
- match: { results.0.index_name: "search-1-test" }
- match: { results.0.language: "pl" }

- match: { results.1.id: "connector-c" }
- match: { results.1.index_name: "search-3-test" }
Expand All @@ -79,13 +79,13 @@ setup:
- match: { count: 3 }

# Alphabetical order by index_name for results
- match: { results.0.id: "connector-a" }
- match: { results.0.index_name: "search-1-test" }
- match: { results.0.language: "pl" }
- match: { results.0.id: "connector-b" }
- match: { results.0.index_name: "content-search-2-test" }
- match: { results.0.language: "en" }

- match: { results.1.id: "connector-b" }
- match: { results.1.index_name: "search-2-test" }
- match: { results.1.language: "en" }
- match: { results.1.id: "connector-a" }
- match: { results.1.index_name: "search-1-test" }
- match: { results.1.language: "pl" }

---
"List Connector - empty":
Expand Down Expand Up @@ -118,11 +118,11 @@ setup:

- do:
connector.list:
index_name: search-1-test,search-2-test
index_name: search-1-test,content-search-2-test

- match: { count: 2 }
- match: { results.0.index_name: "search-1-test" }
- match: { results.1.index_name: "search-2-test" }
- match: { results.0.index_name: "content-search-2-test" }
- match: { results.1.index_name: "search-1-test" }


---
Expand All @@ -147,19 +147,19 @@ setup:
connector_name: my-connector-1,my-connector-2

- match: { count: 2 }
- match: { results.0.name: "my-connector-1" }
- match: { results.1.name: "my-connector-2" }
- match: { results.0.name: "my-connector-2" }
- match: { results.1.name: "my-connector-1" }


---
"List Connector - filter by index name and name":
- do:
connector.list:
connector_name: my-connector-1,my-connector-2
index_name: search-2-test
index_name: content-search-2-test

- match: { count: 1 }
- match: { results.0.index_name: "search-2-test" }
- match: { results.0.index_name: "content-search-2-test" }
- match: { results.0.name: "my-connector-2" }


Expand Down Expand Up @@ -230,13 +230,13 @@ setup:
- match: { count: 3 }

# Alphabetical order by index_name for results
- match: { results.0.id: "connector-a" }
- match: { results.0.index_name: "search-1-test" }
- match: { results.0.language: "pl" }
- match: { results.0.id: "connector-b" }
- match: { results.0.index_name: "content-search-2-test" }
- match: { results.0.language: "en" }

- match: { results.1.id: "connector-b" }
- match: { results.1.index_name: "search-2-test" }
- match: { results.1.language: "en" }
- match: { results.1.id: "connector-a" }
- match: { results.1.index_name: "search-1-test" }
- match: { results.1.language: "pl" }

- match: { results.2.id: "connector-c" }
- match: { results.2.index_name: "search-3-test" }
Expand All @@ -255,13 +255,13 @@ setup:
- match: { count: 3 }

# Alphabetical order by index_name for results
- match: { results.0.id: "connector-a" }
- match: { results.0.index_name: "search-1-test" }
- match: { results.0.language: "pl" }
- match: { results.0.id: "connector-b" }
- match: { results.0.index_name: "content-search-2-test" }
- match: { results.0.language: "en" }

- match: { results.1.id: "connector-b" }
- match: { results.1.index_name: "search-2-test" }
- match: { results.1.language: "en" }
- match: { results.1.id: "connector-a" }
- match: { results.1.index_name: "search-1-test" }
- match: { results.1.language: "pl" }

- match: { results.2.id: "connector-c" }
- match: { results.2.index_name: "search-3-test" }
Expand Down
Loading