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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
)

- repo: https://github.com/psf/black
rev: 23.10.1
rev: 23.11.0
hooks:
- id: black
files: >-
Expand All @@ -36,17 +36,17 @@ repos:
)

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.4.1
rev: 1.5.1
hooks:
- id: pyproject-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.5
hooks:
- id: ruff

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.7.0
hooks:
- id: mypy
files: nc_py_api/
Expand Down
1 change: 1 addition & 0 deletions nc_py_api/_deffered_error.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""DeferredError class taken from PIL._util.py file."""


class DeferredError: # pylint: disable=too-few-public-methods
"""Allow failing import when using it in the client mode, without `app` dependencies."""

Expand Down
12 changes: 5 additions & 7 deletions nc_py_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,11 @@ def _dav_stream(self, method: str, path: str, headers: dict, data: Optional[byte

def _create_adapter(self) -> Client:
adapter = Client(follow_redirects=True, limits=self.limits, verify=self.cfg.options.nc_cert)
adapter.headers.update(
{
"AA-VERSION": self.cfg.aa_version,
"EX-APP-ID": self.cfg.app_name,
"EX-APP-VERSION": self.cfg.app_version,
}
)
adapter.headers.update({
"AA-VERSION": self.cfg.aa_version,
"EX-APP-ID": self.cfg.app_name,
"EX-APP-VERSION": self.cfg.app_version,
})
return adapter

def sign_request(self, headers: dict) -> None:
Expand Down
6 changes: 3 additions & 3 deletions nc_py_api/ex_app/integration_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

def nc_app(request: Request) -> NextcloudApp:
"""Authentication handler for requests from Nextcloud to the application."""
user = get_username_secret_from_headers(
{"AUTHORIZATION-APP-API": request.headers.get("AUTHORIZATION-APP-API", "")}
)[0]
user = get_username_secret_from_headers({
"AUTHORIZATION-APP-API": request.headers.get("AUTHORIZATION-APP-API", "")
})[0]
request_id = request.headers.get("AA-REQUEST-ID", None)
headers = {"AA-REQUEST-ID": request_id} if request_id else {}
nextcloud_app = NextcloudApp(user=user, headers=headers)
Expand Down
12 changes: 5 additions & 7 deletions tests/_app_security_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ def sign_request(req_headers: dict, secret=None, user: str = ""):
headers = {}
result = requests.put(request_url, headers=headers)
assert result.status_code == 401 # Missing headers
headers.update(
{
"AA-VERSION": environ.get("AA_VERSION", "1.0.0"),
"EX-APP-ID": environ.get("APP_ID", "nc_py_api"),
"EX-APP-VERSION": environ.get("APP_VERSION", "1.0.0"),
}
)
headers.update({
"AA-VERSION": environ.get("AA_VERSION", "1.0.0"),
"EX-APP-ID": environ.get("APP_ID", "nc_py_api"),
"EX-APP-VERSION": environ.get("APP_VERSION", "1.0.0"),
})
sign_request(headers)
result = requests.put(request_url, headers=headers)
assert result.status_code == 200
Expand Down