diff --git a/nextcloud_mcp_server/client/sharing.py b/nextcloud_mcp_server/client/sharing.py index d20499a..593804f 100644 --- a/nextcloud_mcp_server/client/sharing.py +++ b/nextcloud_mcp_server/client/sharing.py @@ -124,7 +124,11 @@ class SharingClient(BaseNextcloudClient): f"OCS API error: {data['ocs']['meta'].get('message', 'Unknown error')}" ) - return data["ocs"]["data"] + share_data = data["ocs"]["data"] + # The API returns a list with a single share, extract the first element + if isinstance(share_data, list) and len(share_data) > 0: + return share_data[0] + return share_data @retry_on_429 async def list_shares( diff --git a/tests/client/test_sharing_api.py b/tests/client/test_sharing_api.py index 4f916b5..0733c19 100644 --- a/tests/client/test_sharing_api.py +++ b/tests/client/test_sharing_api.py @@ -15,7 +15,9 @@ async def test_create_and_delete_share(nc_client): # Create a test user to share with test_user = "testuser3" try: - await nc_client.users.create_user(userid=test_user, password="password123") + await nc_client.users.create_user( + userid=test_user, password="SecureP@ssw0rd!2024TestUser" + ) except Exception: pass # User might already exist @@ -72,7 +74,9 @@ async def test_update_share_permissions(nc_client): # Create a test user to share with test_user = "testuser3" try: - await nc_client.users.create_user(userid=test_user, password="password123") + await nc_client.users.create_user( + userid=test_user, password="SecureP@ssw0rd!2024TestUser" + ) except Exception: pass # User might already exist @@ -122,7 +126,9 @@ async def test_list_shares(nc_client): # Create a test user to share with test_user = "testuser3" try: - await nc_client.users.create_user(userid=test_user, password="password123") + await nc_client.users.create_user( + userid=test_user, password="SecureP@ssw0rd!2024TestUser" + ) except Exception: pass # User might already exist diff --git a/tests/conftest.py b/tests/conftest.py index 1e599e8..9325544 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -760,9 +760,9 @@ async def interactive_oauth_token(oauth_callback_server) -> str: client_info = await load_or_register_client( nextcloud_url=nextcloud_host, registration_endpoint=registration_endpoint, - storage_path=".nextcloud_oauth_test_client.json", + storage_path=".nextcloud_oauth_shared_test_client.json", redirect_uris=[callback_url], - force_register=True, + force_register=False, # Reuse existing credentials if valid ) # First, open Nextcloud login page to establish session