Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.0.21 #16

Merged
merged 2 commits into from
Jul 3, 2023
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
40 changes: 14 additions & 26 deletions .github/workflows/analysis-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ on:
- '.pre-commit-config.yaml'
workflow_dispatch:

env:
NEXTCLOUD_URL: "http://localhost:8080/index.php"
APP_ID: "nc_py_api"
APP_VERSION: "1.0.0"
APP_SECRET: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
NC_AUTH_USER: "admin"
NC_AUTH_PASS: "adminpassword"

jobs:
analysis:
runs-on: macos-12
Expand Down Expand Up @@ -52,13 +60,6 @@ jobs:
- nextcloud: "27.0.0"
python: "3.10"
php-version: "8.2"
env:
nextcloud_url: "http://localhost:8080/index.php"
app_name: "nc_py_api"
app_version: "1.0.0"
app_secret: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
nc_auth_user: "admin"
nc_auth_pass: "adminpassword"

services:
mariadb:
Expand Down Expand Up @@ -136,10 +137,10 @@ jobs:
sleep 5s
php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \
--net=host --host="127.0.0.1" --expose="local"
php occ app_ecosystem_v2:app:register $app_name $app_version "NcPyApi" \
php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \
--daemon-config-id 1 \
--port 9002 \
--secret $app_secret \
--secret $APP_SECRET \
-e --force-scopes --system-app
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand Down Expand Up @@ -187,12 +188,6 @@ jobs:
php-version: "8.2"
env:
NC_dbname: nextcloud_abz
nextcloud_url: "http://localhost:8080/index.php"
app_name: "nc_py_api"
app_version: "1.0.0"
app_secret: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
nc_auth_user: "admin"
nc_auth_pass: "adminpassword"

services:
postgres:
Expand Down Expand Up @@ -271,10 +266,10 @@ jobs:
sleep 5s
php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \
--net=host --host="127.0.0.1" --expose="local"
php occ app_ecosystem_v2:app:register $app_name $app_version "NcPyApi" \
php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \
--daemon-config-id 1 \
--port 9002 \
--secret $app_secret \
--secret $APP_SECRET \
-e --force-scopes --system-app
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand Down Expand Up @@ -316,13 +311,6 @@ jobs:
nextcloud: [ "27.0.0" ]
python: [ "3.11" ]
php-version: [ "8.2" ]
env:
nextcloud_url: "http://localhost:8080/index.php"
app_name: "nc_py_api"
app_version: "1.0.0"
app_secret: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
nc_auth_user: "admin"
nc_auth_pass: "adminpassword"

services:
oracle:
Expand Down Expand Up @@ -400,10 +388,10 @@ jobs:
sleep 5s
php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \
--net=host --host="127.0.0.1" --expose="local"
php occ app_ecosystem_v2:app:register $app_name $app_version "NcPyApi" \
php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \
--daemon-config-id 1 \
--port 9002 \
--secret $app_secret \
--secret $APP_SECRET \
-e --force-scopes --system-app
kill -15 $(cat /tmp/_install.pid)
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

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

## [0.0.21 - 2023-06-04]

### Added

- `app_cfg` property to `NextcloudApp` class.

### Fixed

- All input environment variables now in Upper Case.

## [0.0.20 - 2023-06-03]

- Written from the scratch new version of the Nextcloud Python Client. Deep Alpha.
2 changes: 1 addition & 1 deletion nc_py_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, **kwargs):
def _get_value(value_name: str, raise_not_found=True, **kwargs):
value = kwargs.get(value_name, None)
if not value:
value = environ.get(value_name, None)
value = environ.get(value_name.upper(), None)
if not value and raise_not_found:
raise ValueError(f"`{value_name}` is not found.")
return value
Expand Down
6 changes: 5 additions & 1 deletion nc_py_api/nextcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from fastapi import Request

from ._session import NcSession, NcSessionApp, NcSessionBasic, ServerVersion
from ._session import AppConfig, NcSession, NcSessionApp, NcSessionBasic, ServerVersion
from .appconfig_preferences_ex import AppConfigExAPI, PreferencesExAPI
from .apps import AppAPI
from .constants import APP_V2_BASIC_URL, ApiScope, LogLvl
Expand Down Expand Up @@ -114,6 +114,10 @@ def user(self, value: str):
self._session.user = value
self._session.update_server_info()

@property
def app_cfg(self) -> AppConfig:
return self._session.cfg

def request_sign_check(self, request: Request) -> bool:
try:
self._session.sign_check(request)
Expand Down
12 changes: 6 additions & 6 deletions tests/gfixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
secret = "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E" \
"X1T8Pi+T5papEolTLxz3fJSPS8ffC4204YmggxPsbJdCkXHWNPHKWS9B+vTj2SIV"
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"] = "http://nextcloud.local/index.php"
environ["app_name"] = "nc_py_api"
environ["app_version"] = "1.0.0"
environ["app_secret"] = secret
environ["NC_AUTH_USER"] = "admin"
environ["NC_AUTH_PASS"] = "admin" # "MrtGY-KfY24-iiDyg-cr4n4-GLsNZ"
environ["NEXTCLOUD_URL"] = "http://nextcloud.local/index.php"
environ["APP_ID"] = "nc_py_api"
environ["APP_VERSION"] = "1.0.0"
environ["APP_SECRET"] = secret

NC = Nextcloud()
if environ.get("SKIP_NC_WO_AE", False):
Expand Down
8 changes: 8 additions & 0 deletions tests/nc_app_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from os import environ
import pytest

from gfixture import NC_APP, NC
Expand All @@ -22,6 +23,13 @@ def test_scope_allowed():
assert not NC_APP.scope_allowed(999999999)


def test_app_cfg():
app_cfg = NC_APP.app_cfg
assert app_cfg.app_name == environ["APP_ID"]
assert app_cfg.app_version == environ["APP_VERSION"]
assert app_cfg.app_secret == environ["APP_SECRET"].encode("UTF-8")


@pytest.mark.skipif(NC is None, reason="Usual Nextcloud mode required for the test")
def test_scope_allow_app_ecosystem_disabled():
NC.apps.disable("app_ecosystem_v2")
Expand Down