Skip to content

Expose token in Share objects#427

Merged
oleksandr-nc merged 1 commit intocloud-py-api:mainfrom
GDATAAdvancedAnalytics:add-share-token
Apr 24, 2026
Merged

Expose token in Share objects#427
oleksandr-nc merged 1 commit intocloud-py-api:mainfrom
GDATAAdvancedAnalytics:add-share-token

Conversation

@meck-gd
Copy link
Copy Markdown
Contributor

@meck-gd meck-gd commented Apr 24, 2026

Some use cases require passing the token to external applications that access NextCloud shares via WebDAV.

Summary by CodeRabbit

  • New Features

    • File shares now include a read-only token property so users can access share token information directly when working with shared files.
  • Tests

    • Test coverage expanded to assert that newly created shares provide a non-empty token and that token values returned by share lookups match the original creation token.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 776aeb4c-442b-4fc7-9f5e-01293ea3a040

📥 Commits

Reviewing files that changed from the base of the PR and between 716094b and fcfacb7.

📒 Files selected for processing (2)
  • nc_py_api/files/__init__.py
  • tests/actual_tests/files_sharing_test.py

📝 Walkthrough

Walkthrough

Introduced a read-only token property on the Share class that returns the optional share token from underlying _raw_data (defaults to empty string). Tests updated to assert the created share exposes a non-empty token and that retrieval returns the same token.

Changes

Cohort / File(s) Summary
Share Class Enhancement
nc_py_api/files/__init__.py
Added Share.token(self) -> str property that reads optional token from _raw_data, normalizing missing/falsey values to "".
Sharing Tests
tests/actual_tests/files_sharing_test.py
Extended _test_share_fields to assert the created share's token is non-empty and that files.sharing.get_by_id() returns the same token.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: exposing a new token property in Share objects.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/actual_tests/files_sharing_test.py`:
- Line 53: The current equality assert between get_by_id.token and
new_share.token is vacuous for empty tokens; ensure the test actually exercises
a non-empty token by asserting the created share has a token before comparing.
In _test_share_fields (invoked with ShareType.TYPE_LINK) add an explicit check
like asserting new_share.token is truthy/non-empty (e.g., assert
new_share.token) and then keep the existing assert get_by_id.token ==
new_share.token to validate the round-trip from the OCS get_by_id endpoint.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f23d66ac-f847-49f0-bb79-60ab9bb91914

📥 Commits

Reviewing files that changed from the base of the PR and between c834931 and 716094b.

📒 Files selected for processing (2)
  • nc_py_api/files/__init__.py
  • tests/actual_tests/files_sharing_test.py

Comment thread tests/actual_tests/files_sharing_test.py Outdated
Comment thread nc_py_api/files/__init__.py Outdated
Comment thread tests/actual_tests/files_sharing_test.py Outdated
Some use cases require passing the token to external applications
that access NextCloud shares via WebDAV.
Copy link
Copy Markdown
Contributor

@oleksandr-nc oleksandr-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these changes!

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.67%. Comparing base (c834931) to head (fcfacb7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #427   +/-   ##
=======================================
  Coverage   94.67%   94.67%           
=======================================
  Files          48       48           
  Lines        5633     5636    +3     
=======================================
+ Hits         5333     5336    +3     
  Misses        300      300           
Files with missing lines Coverage Δ
nc_py_api/files/__init__.py 99.71% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oleksandr-nc oleksandr-nc merged commit d365c45 into cloud-py-api:main Apr 24, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants