Skip to content

Commit cb30130

Browse files
authored
Merge branch 'main' into test/update-multi-tenant-scenarios
2 parents 14208e8 + 98a02b1 commit cb30130

11 files changed

Lines changed: 87 additions & 18 deletions

File tree

.env_integration_tests.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ CLOUD_SDK_CFG_ADMS_DEFAULT_URI=https://your-adm-host.cfapps.eu20.hana.ondemand.c
88
CLOUD_SDK_CFG_ADMS_DEFAULT_RESOURCE=urn:sap:identity:application:provider:name:your-adm-app-name
99

1010
# AGENT GATEWAY
11-
APPFND_CONHOS_LANDSCAPE=your-landscape-here
12-
TENANT_SUBDOMAIN=your-tenant-subdomain-here
11+
CLOUD_SDK_CFG_AGW_DEFAULT_LANDSCAPE=your-landscape-here
12+
CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN=your-tenant-subdomain-here
1313
AGW_USER_TOKEN=your-user-jwt-here
1414

1515
# AGENT MEMORY

docs/INTEGRATION_TESTS.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ CLOUD_SDK_CFG_DESTINATION_DEFAULT_URI=https://your-destination-configuration-uri
5454
CLOUD_SDK_CFG_DESTINATION_DEFAULT_IDENTITYZONE=your-identity-zone-here
5555

5656
# Landscape suffix used to resolve the IAS destination name
57-
APPFND_CONHOS_LANDSCAPE=your-landscape-here
57+
CLOUD_SDK_CFG_AGW_DEFAULT_LANDSCAPE=your-landscape-here
5858

5959
# Tenant subdomain for multi-tenant lookup
60-
TENANT_SUBDOMAIN=your-tenant-subdomain-here
60+
CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN=your-tenant-subdomain-here
6161

6262
# User JWT for token exchange scenarios (get_user_auth)
6363
# If not set, user auth scenarios are automatically skipped
@@ -121,6 +121,18 @@ CLOUD_SDK_CFG_DESTINATION_DEFAULT_URI=https://your-destination-configuration-uri
121121
CLOUD_SDK_CFG_DESTINATION_DEFAULT_IDENTITYZONE=your-identity-zone-here
122122
```
123123

124+
### DMS Integration Tests
125+
126+
For DMS (Document Management Service) integration tests, configure the following variables in `.env_integration_tests`:
127+
128+
```bash
129+
# DMS Configuration
130+
CLOUD_SDK_CFG_SDM_DEFAULT_URI=https://your-sdm-api-uri-here
131+
CLOUD_SDK_CFG_SDM_DEFAULT_UAA='{"url":"https://your-auth-url","clientid":"your-client-id","clientsecret":"your-client-secret","identityzone":"your-identity-zone"}'
132+
```
133+
134+
**Note**: The test fixture automatically onboards test repositories (standard and version-enabled) at session start and cleans them up on teardown. No pre-existing repositories are required.
135+
124136
### ObjectStore Integration Tests
125137

126138
For ObjectStore integration tests, configure the following variables in `.env_integration_tests`:
@@ -147,6 +159,7 @@ uv run pytest tests/agent_memory/integration/ -v
147159
uv run pytest tests/core/integration/auditlog -v
148160
uv run pytest tests/core/integration/data_anonymization -v
149161
uv run pytest tests/destination/integration/ -v
162+
uv run pytest tests/dms/integration/ -v
150163
uv run pytest tests/objectstore/integration/ -v
151164
```
152165

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sap-cloud-sdk"
3-
version = "0.26.0"
3+
version = "0.26.1"
44
description = "SAP Cloud SDK for Python"
55
readme = "README.md"
66
license = "Apache-2.0"

src/sap_cloud_sdk/dms/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ def __init__(
110110
read_timeout=read_timeout,
111111
)
112112
self._telemetry_source: Optional[Module] = None
113-
logger.debug(
114-
"DMSClient initialized for instance '%s'", credentials.instance_name
115-
)
113+
logger.debug("DMSClient initialized")
116114

117115
@record_metrics(Module.DMS, Operation.DMS_ONBOARD_REPOSITORY)
118116
def onboard_repository(

src/sap_cloud_sdk/dms/config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class BindingData:
1919
uaa: JSON string containing XSUAA authentication credentials
2020
"""
2121

22-
instance_name: str
2322
uri: str
2423
uaa: str
2524

@@ -91,7 +90,6 @@ def to_credentials(self) -> DMSCredentials:
9190
token_url = uaa_data["url"].rstrip("/") + "/oauth/token"
9291

9392
return DMSCredentials(
94-
instance_name=self.instance_name,
9593
uri=self.uri,
9694
client_id=uaa_data["clientid"],
9795
client_secret=uaa_data["clientsecret"],
@@ -114,7 +112,7 @@ def load_sdm_config_from_env_or_mount(instance: Optional[str] = None) -> DMSCred
114112
"""
115113
inst = instance or "default"
116114
binding = BindingData(
117-
uri="", uaa="", instance_name=""
115+
uri="", uaa=""
118116
) # Initialize with empty values; will be populated by resolver
119117

120118
try:

src/sap_cloud_sdk/dms/model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def _to_dict_drop_none(obj: Any) -> dict[str, Any]:
3030
class DMSCredentials:
3131
"""Credentials for authenticating with the DMS service."""
3232

33-
instance_name: str
3433
uri: str
3534
client_id: str
3635
client_secret: str

tests/agentgateway/integration/conftest.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from dotenv import load_dotenv
88

99
from sap_cloud_sdk.agentgateway import create_client, AgentGatewayClient
10+
from sap_cloud_sdk.agentgateway.exceptions import MCPServerNotFoundError
1011

1112

1213
def _setup_cloud_mode():
@@ -21,12 +22,18 @@ def agw_client() -> AgentGatewayClient:
2122
"""Create an AgentGatewayClient from environment variables."""
2223
_setup_cloud_mode()
2324

24-
tenant_subdomain = os.environ.get("TENANT_SUBDOMAIN")
25+
tenant_subdomain = os.environ.get("CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN")
2526
if not tenant_subdomain:
26-
pytest.fail("TENANT_SUBDOMAIN environment variable is not set")
27+
pytest.skip("CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN is not set — skipping AGW integration tests")
28+
29+
landscape = os.environ.get("CLOUD_SDK_CFG_AGW_DEFAULT_LANDSCAPE")
30+
if landscape:
31+
os.environ.setdefault("APPFND_CONHOS_LANDSCAPE", landscape)
2732

2833
try:
2934
return create_client(tenant_subdomain=tenant_subdomain)
35+
except MCPServerNotFoundError as e:
36+
pytest.skip(f"AGW not subscribed for this tenant — skipping AGW integration tests: {e}")
3037
except Exception as e:
3138
pytest.fail(f"Failed to create Agent Gateway client for integration tests: {e}")
3239

@@ -45,3 +52,11 @@ def pytest_collection_modifyitems(config, items):
4552
for item in items:
4653
if "integration" in str(item.fspath):
4754
item.add_marker(pytest.mark.integration)
55+
56+
57+
def pytest_runtest_call(item):
58+
"""Skip AGW tests that fail due to missing subscription."""
59+
try:
60+
item.runtest()
61+
except MCPServerNotFoundError as e:
62+
pytest.skip(f"AGW not subscribed for this tenant — skipping: {e}")

tests/agentgateway/integration/test_agw_bdd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
Run against a live BTP tenant:
44
5-
APPFND_CONHOS_LANDSCAPE=<landscape> \\
6-
TENANT_SUBDOMAIN=<tenant-subdomain> \\
5+
CLOUD_SDK_CFG_AGW_DEFAULT_TENANT_SUBDOMAIN=<tenant-subdomain> \\
6+
CLOUD_SDK_CFG_AGW_DEFAULT_LANDSCAPE=<landscape> \\
77
CLOUD_SDK_CFG_DESTINATION_DEFAULT_CLIENTID=... \\
88
CLOUD_SDK_CFG_DESTINATION_DEFAULT_CLIENTSECRET=... \\
99
CLOUD_SDK_CFG_DESTINATION_DEFAULT_URL=... \\

tests/dms/integration/conftest.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
from sap_cloud_sdk.dms import create_client
2+
from sap_cloud_sdk.dms.exceptions import DMSError
3+
from sap_cloud_sdk.dms.model import InternalRepoRequest
24
import pytest
5+
import logging
36
from pathlib import Path
47
from dotenv import load_dotenv
58

9+
logger = logging.getLogger(__name__)
10+
11+
_SDK_TEST_REPO_PREFIX = "sdk-integration-test-"
12+
613

714
@pytest.fixture(scope="session")
815
def dms_client():
@@ -17,6 +24,47 @@ def dms_client():
1724
pytest.skip(f"DMS integration tests require credentials: {e}")
1825

1926

27+
@pytest.fixture(scope="session", autouse=True)
28+
def _setup_test_repositories(dms_client):
29+
"""Create test repositories for integration tests and clean up after.
30+
31+
Always onboards a standard and a version-enabled repository for the test
32+
session, then deletes them on teardown.
33+
"""
34+
created_repos = []
35+
36+
logger.info("Onboarding test repositories")
37+
try:
38+
repo = dms_client.onboard_repository(
39+
InternalRepoRequest(
40+
displayName=f"{_SDK_TEST_REPO_PREFIX}standard",
41+
description="Auto-created by SDK integration tests",
42+
)
43+
)
44+
created_repos.append(repo.id)
45+
46+
repo = dms_client.onboard_repository(
47+
InternalRepoRequest(
48+
displayName=f"{_SDK_TEST_REPO_PREFIX}versioned",
49+
description="Auto-created by SDK integration tests (versioning)",
50+
isVersionEnabled=True,
51+
)
52+
)
53+
created_repos.append(repo.id)
54+
except DMSError as e:
55+
pytest.skip(f"DMS ECM repository connection not available — skipping DMS integration tests: {e}")
56+
57+
yield
58+
59+
# Cleanup: delete repositories we created
60+
for repo_id in created_repos:
61+
try:
62+
dms_client.delete_repository(repo_id)
63+
logger.info("Cleaned up test repository %s", repo_id)
64+
except Exception as e:
65+
logger.warning("Failed to clean up test repository %s: %s", repo_id, e)
66+
67+
2068
def _setup_cloud_mode():
2169
"""Common setup for cloud mode integration tests."""
2270
env_file = Path(__file__).parents[3] / ".env_integration_tests"

tests/dms/unit/test_client_admin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def client():
7272
mock_http = Mock()
7373
MockHttp.return_value = mock_http
7474
creds = DMSCredentials(
75-
instance_name="test-instance",
7675
uri="https://api.example.com",
7776
client_id="test-client",
7877
client_secret="test-secret",

0 commit comments

Comments
 (0)