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

set sentinel value for connection string if it is empty #12129

Merged
merged 1 commit into from
Jun 19, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,12 @@ def pack_search_indexer_data_source(search_indexer_data_source):
# type: (SearchIndexerDataSourceConnection) -> _SearchIndexerDataSource
if not search_indexer_data_source:
return None
if search_indexer_data_source.connection_string is None or search_indexer_data_source.connection_string == "":
heaths marked this conversation as resolved.
Show resolved Hide resolved
connection_string = "<unchanged>"
else:
connection_string = search_indexer_data_source.connection_string
credentials = DataSourceCredentials(
connection_string=search_indexer_data_source.connection_string
connection_string=connection_string
)
return _SearchIndexerDataSource(
name=search_indexer_data_source.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
from azure.search.documents.indexes import SearchIndexClient, SearchIndexerClient
from azure.search.documents.indexes.models import SearchIndexerDataContainer, SearchIndexerDataSourceConnection
from azure.search.documents.indexes._internal._utils import pack_search_indexer_data_source

CREDENTIAL = AzureKeyCredential(key="test_api_key")

Expand Down Expand Up @@ -103,3 +105,14 @@ def test_indexer_endpoint_https(self):

with pytest.raises(ValueError):
client = SearchIndexerClient(12345, credential)

def test_datasource_with_empty_connection_string(self):
container = SearchIndexerDataContainer(name='searchcontainer')
data_source_connection = SearchIndexerDataSourceConnection(
name="test",
type="azureblob",
connection_string="",
container=container
)
packed_data_source_connection = pack_search_indexer_data_source(data_source_connection)
assert packed_data_source_connection.credentials.connection_string == "<unchanged>"