Skip to content
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "sap-cloud-sdk"
version = "0.45.2"
version = "0.45.3"
description = "SAP Cloud SDK for Python"
readme = "README.md"
license = "Apache-2.0"
Expand Down
7 changes: 6 additions & 1 deletion src/sap_cloud_sdk/agentgateway/_lob.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ def get_ias_client_id_lob() -> str:
)
if not dest:
raise AgentGatewaySDKError(f"IAS destination '{dest_name}' not found")
return dest.properties.get("clientId", "")
client_id = dest.properties.get("clientId", "")
if not client_id:
raise AgentGatewaySDKError(
f"IAS destination '{dest_name}' does not contain a 'clientId' property"
)
return client_id


async def fetch_system_auth(
Expand Down
4 changes: 4 additions & 0 deletions src/sap_cloud_sdk/agentgateway/agw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ def get_ias_client_id(self) -> str:
"Customer agent credentials detected at '%s'", credentials_path
)
credentials = load_customer_credentials(credentials_path)
if not credentials.client_id:
raise AgentGatewaySDKError(
"Customer agent credentials file does not contain a 'client_id'"
)
return credentials.client_id

# LoB flow — read clientId from the IAS destination properties
Expand Down
20 changes: 15 additions & 5 deletions tests/agentgateway/unit/test_agw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,17 @@ def test_customer_raises_on_load_failure(self):
with pytest.raises(AgentGatewaySDKError, match="Could not resolve IAS client ID"):
create_client().get_ias_client_id()

def test_customer_raises_when_client_id_empty(self):
mock_creds = MagicMock()
mock_creds.client_id = ""

with (
patch(_DETECT_CREDS_PATCH, return_value="/etc/ums/credentials/credentials"),
patch(_LOAD_CREDS_PATCH, return_value=mock_creds),
):
with pytest.raises(AgentGatewaySDKError, match="client_id"):
create_client().get_ias_client_id()

# --- LoB flow ---

@_NO_CUSTOMER_CREDS
Expand All @@ -1225,11 +1236,10 @@ def test_lob_raises_when_destination_not_found(self, _mock_detect):
create_client(tenant_subdomain="my-tenant").get_ias_client_id()

@_NO_CUSTOMER_CREDS
def test_lob_returns_empty_string_when_property_absent(self, _mock_detect):
with patch(_GET_IAS_CLIENT_ID_LOB_PATCH, return_value=""):
result = create_client(tenant_subdomain="my-tenant").get_ias_client_id()

assert result == ""
def test_lob_raises_when_client_id_property_absent(self, _mock_detect):
with patch(_GET_IAS_CLIENT_ID_LOB_PATCH, side_effect=AgentGatewaySDKError("does not contain a 'clientId' property")):
with pytest.raises(AgentGatewaySDKError, match="clientId"):
create_client(tenant_subdomain="my-tenant").get_ias_client_id()

@_NO_CUSTOMER_CREDS
def test_lob_raises_on_exception(self, _mock_detect):
Expand Down
7 changes: 3 additions & 4 deletions tests/agentgateway/unit/test_lob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ def test_raises_when_destination_not_found(self):
with pytest.raises(AgentGatewaySDKError, match="sap-managed-runtime-ias-eu10"):
get_ias_client_id_lob()

def test_returns_empty_string_when_property_absent(self):
def test_raises_when_client_id_property_absent(self):
mock_dest = MagicMock()
mock_dest.properties = {}
mock_dest_client = MagicMock()
Expand All @@ -1262,9 +1262,8 @@ def test_returns_empty_string_when_property_absent(self):
patch("sap_cloud_sdk.agentgateway._lob._ias_dest_name", return_value="sap-managed-runtime-ias-eu10"),
patch("sap_cloud_sdk.agentgateway._lob.create_destination_client", return_value=mock_dest_client),
):
result = get_ias_client_id_lob()

assert result == ""
with pytest.raises(AgentGatewaySDKError, match="clientId"):
get_ias_client_id_lob()

def test_raises_when_landscape_env_not_set(self):
with patch("sap_cloud_sdk.agentgateway._lob._ias_dest_name", side_effect=EnvironmentError("APPFND_CONHOS_LANDSCAPE not set")):
Expand Down
Loading