Skip to content

Commit

Permalink
fixed CI for NC30, last adjustments for webhooks
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Jul 19, 2024
1 parent 35ffed2 commit 8748dd8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

All notable changes to this project will be documented in this file.

## [0.14.0 - 2024-07-0X]
## [0.15.0 - 2024-07-19]

### Added

- Initial Webhooks API support for the upcoming Nextcloud 30. #272

### Changed

- NextcloudApp: `fetch_models_task` function now saves paths to downloaded models. #274 Thanks to @kyteinsky

## [0.14.0 - 2024-07-09]

### Added

Expand Down
10 changes: 10 additions & 0 deletions docs/reference/Webhooks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. py:currentmodule:: nc_py_api.webhooks
Webhooks API
============

.. autoclass:: nc_py_api.webhooks.WebhookInfo
:members:

.. autoclass:: nc_py_api.webhooks._WebhooksAPI
:members:
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Reference
Notes
Session
LoginFlowV2
Webhooks
8 changes: 4 additions & 4 deletions nc_py_api/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def app_id(self) -> str:
@property
def user_id(self) -> str:
"""`UserID` if webhook was registered in user context."""
return self._raw_data["userId"]
return self._raw_data["userId"] if self._raw_data["userId"] else ""

@property
def http_method(self) -> str:
Expand All @@ -45,7 +45,7 @@ def event(self) -> str:

@property
def event_filter(self):
"""Currently unknown."""
"""Mongo filter to apply to the serialized data to decide if firing."""
return self._raw_data["eventFilter"]

@property
Expand Down Expand Up @@ -138,7 +138,7 @@ def update(
return WebhookInfo(self._session.ocs("POST", f"{self._ep_base}/{webhook_id}", json=params))

def unregister(self, webhook_id: int) -> bool:
return self._session.ocs("DELETE", f"{self._session.ae_url}/{webhook_id}")
return self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")


class _AsyncWebhooksAPI:
Expand Down Expand Up @@ -207,4 +207,4 @@ async def update(
return WebhookInfo(await self._session.ocs("POST", f"{self._ep_base}/{webhook_id}", json=params))

async def unregister(self, webhook_id: int) -> bool:
return await self._session.ocs("DELETE", f"{self._session.ae_url}/{webhook_id}")
return await self._session.ocs("DELETE", f"{self._ep_base}/{webhook_id}")
6 changes: 6 additions & 0 deletions tests/actual_tests/files_sharing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ async def test_share_fields_async(anc_any):
def test_create_permissions(nc_any):
new_share = nc_any.files.sharing.create("test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_CREATE)
nc_any.files.sharing.delete(new_share)
# starting from Nextcloud 30 permissions are: FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
# https://github.com/nextcloud/server/commit/0bde47a39256dfad3baa8d3ffa275ac3d113a9d5#diff-dbbe017dd357504abc442a6f1d0305166520ebf80353f42814b3f879a3e241bc
assert (
new_share.permissions
== FilePermissions.PERMISSION_READ | FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
or new_share.permissions == FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
)
new_share = nc_any.files.sharing.create("test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_DELETE)
nc_any.files.sharing.delete(new_share)
Expand All @@ -107,9 +110,12 @@ async def test_create_permissions_async(anc_any):
"test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_CREATE
)
await anc_any.files.sharing.delete(new_share)
# starting from Nextcloud 30 permissions are: FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
# https://github.com/nextcloud/server/commit/0bde47a39256dfad3baa8d3ffa275ac3d113a9d5#diff-dbbe017dd357504abc442a6f1d0305166520ebf80353f42814b3f879a3e241bc
assert (
new_share.permissions
== FilePermissions.PERMISSION_READ | FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
or new_share.permissions == FilePermissions.PERMISSION_CREATE | FilePermissions.PERMISSION_SHARE
)
new_share = await anc_any.files.sharing.create(
"test_empty_dir", ShareType.TYPE_LINK, FilePermissions.PERMISSION_DELETE
Expand Down
4 changes: 2 additions & 2 deletions tests/gfixture_set_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
if not environ.get("CI", False): # For local tests
environ["NC_AUTH_USER"] = "admin"
environ["NC_AUTH_PASS"] = "admin" # "MrtGY-KfY24-iiDyg-cr4n4-GLsNZ"
environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable27.local")
# environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable28.local")
environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable29.local")
# environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://stable30.local")
# environ["NEXTCLOUD_URL"] = environ.get("NEXTCLOUD_URL", "http://nextcloud.local")
environ["APP_ID"] = "nc_py_api"
environ["APP_VERSION"] = "1.0.0"
Expand Down

0 comments on commit 8748dd8

Please sign in to comment.