Skip to content

Commit e2ea844

Browse files
authored
v0.0.21 (#16)
* v0.0.21 Signed-off-by: Alexander Piskun <[email protected]>
1 parent b837765 commit e2ea844

File tree

6 files changed

+44
-34
lines changed

6 files changed

+44
-34
lines changed

.github/workflows/analysis-coverage.yml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ on:
2020
- '.pre-commit-config.yaml'
2121
workflow_dispatch:
2222

23+
env:
24+
NEXTCLOUD_URL: "http://localhost:8080/index.php"
25+
APP_ID: "nc_py_api"
26+
APP_VERSION: "1.0.0"
27+
APP_SECRET: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
28+
NC_AUTH_USER: "admin"
29+
NC_AUTH_PASS: "adminpassword"
30+
2331
jobs:
2432
analysis:
2533
runs-on: macos-12
@@ -52,13 +60,6 @@ jobs:
5260
- nextcloud: "27.0.0"
5361
python: "3.10"
5462
php-version: "8.2"
55-
env:
56-
nextcloud_url: "http://localhost:8080/index.php"
57-
app_name: "nc_py_api"
58-
app_version: "1.0.0"
59-
app_secret: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
60-
nc_auth_user: "admin"
61-
nc_auth_pass: "adminpassword"
6263

6364
services:
6465
mariadb:
@@ -136,10 +137,10 @@ jobs:
136137
sleep 5s
137138
php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \
138139
--net=host --host="127.0.0.1" --expose="local"
139-
php occ app_ecosystem_v2:app:register $app_name $app_version "NcPyApi" \
140+
php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \
140141
--daemon-config-id 1 \
141142
--port 9002 \
142-
--secret $app_secret \
143+
--secret $APP_SECRET \
143144
-e --force-scopes --system-app
144145
kill -15 $(cat /tmp/_install.pid)
145146
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
@@ -187,12 +188,6 @@ jobs:
187188
php-version: "8.2"
188189
env:
189190
NC_dbname: nextcloud_abz
190-
nextcloud_url: "http://localhost:8080/index.php"
191-
app_name: "nc_py_api"
192-
app_version: "1.0.0"
193-
app_secret: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
194-
nc_auth_user: "admin"
195-
nc_auth_pass: "adminpassword"
196191

197192
services:
198193
postgres:
@@ -271,10 +266,10 @@ jobs:
271266
sleep 5s
272267
php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \
273268
--net=host --host="127.0.0.1" --expose="local"
274-
php occ app_ecosystem_v2:app:register $app_name $app_version "NcPyApi" \
269+
php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \
275270
--daemon-config-id 1 \
276271
--port 9002 \
277-
--secret $app_secret \
272+
--secret $APP_SECRET \
278273
-e --force-scopes --system-app
279274
kill -15 $(cat /tmp/_install.pid)
280275
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null
@@ -316,13 +311,6 @@ jobs:
316311
nextcloud: [ "27.0.0" ]
317312
python: [ "3.11" ]
318313
php-version: [ "8.2" ]
319-
env:
320-
nextcloud_url: "http://localhost:8080/index.php"
321-
app_name: "nc_py_api"
322-
app_version: "1.0.0"
323-
app_secret: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E"
324-
nc_auth_user: "admin"
325-
nc_auth_pass: "adminpassword"
326314

327315
services:
328316
oracle:
@@ -400,10 +388,10 @@ jobs:
400388
sleep 5s
401389
php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \
402390
--net=host --host="127.0.0.1" --expose="local"
403-
php occ app_ecosystem_v2:app:register $app_name $app_version "NcPyApi" \
391+
php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \
404392
--daemon-config-id 1 \
405393
--port 9002 \
406-
--secret $app_secret \
394+
--secret $APP_SECRET \
407395
-e --force-scopes --system-app
408396
kill -15 $(cat /tmp/_install.pid)
409397
timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

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

5+
## [0.0.21 - 2023-06-04]
6+
7+
### Added
8+
9+
- `app_cfg` property to `NextcloudApp` class.
10+
11+
### Fixed
12+
13+
- All input environment variables now in Upper Case.
14+
515
## [0.0.20 - 2023-06-03]
616

717
- Written from the scratch new version of the Nextcloud Python Client. Deep Alpha.

nc_py_api/_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, **kwargs):
4848
def _get_value(value_name: str, raise_not_found=True, **kwargs):
4949
value = kwargs.get(value_name, None)
5050
if not value:
51-
value = environ.get(value_name, None)
51+
value = environ.get(value_name.upper(), None)
5252
if not value and raise_not_found:
5353
raise ValueError(f"`{value_name}` is not found.")
5454
return value

nc_py_api/nextcloud.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from fastapi import Request
88

9-
from ._session import NcSession, NcSessionApp, NcSessionBasic, ServerVersion
9+
from ._session import AppConfig, NcSession, NcSessionApp, NcSessionBasic, ServerVersion
1010
from .appconfig_preferences_ex import AppConfigExAPI, PreferencesExAPI
1111
from .apps import AppAPI
1212
from .constants import APP_V2_BASIC_URL, ApiScope, LogLvl
@@ -114,6 +114,10 @@ def user(self, value: str):
114114
self._session.user = value
115115
self._session.update_server_info()
116116

117+
@property
118+
def app_cfg(self) -> AppConfig:
119+
return self._session.cfg
120+
117121
def request_sign_check(self, request: Request) -> bool:
118122
try:
119123
self._session.sign_check(request)

tests/gfixture.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
secret = "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E" \
77
"X1T8Pi+T5papEolTLxz3fJSPS8ffC4204YmggxPsbJdCkXHWNPHKWS9B+vTj2SIV"
88
if not environ.get("CI", False): # For local tests
9-
environ["nc_auth_user"] = "admin"
10-
environ["nc_auth_pass"] = "admin" # "MrtGY-KfY24-iiDyg-cr4n4-GLsNZ"
11-
environ["nextcloud_url"] = "http://nextcloud.local/index.php"
12-
environ["app_name"] = "nc_py_api"
13-
environ["app_version"] = "1.0.0"
14-
environ["app_secret"] = secret
9+
environ["NC_AUTH_USER"] = "admin"
10+
environ["NC_AUTH_PASS"] = "admin" # "MrtGY-KfY24-iiDyg-cr4n4-GLsNZ"
11+
environ["NEXTCLOUD_URL"] = "http://nextcloud.local/index.php"
12+
environ["APP_ID"] = "nc_py_api"
13+
environ["APP_VERSION"] = "1.0.0"
14+
environ["APP_SECRET"] = secret
1515

1616
NC = Nextcloud()
1717
if environ.get("SKIP_NC_WO_AE", False):

tests/nc_app_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from os import environ
12
import pytest
23

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

2425

26+
def test_app_cfg():
27+
app_cfg = NC_APP.app_cfg
28+
assert app_cfg.app_name == environ["APP_ID"]
29+
assert app_cfg.app_version == environ["APP_VERSION"]
30+
assert app_cfg.app_secret == environ["APP_SECRET"].encode("UTF-8")
31+
32+
2533
@pytest.mark.skipif(NC is None, reason="Usual Nextcloud mode required for the test")
2634
def test_scope_allow_app_ecosystem_disabled():
2735
NC.apps.disable("app_ecosystem_v2")

0 commit comments

Comments
 (0)