From d8adb26e069da859ef4372cef7444d74cb4acf9c Mon Sep 17 00:00:00 2001 From: jamshale Date: Tue, 20 Aug 2024 10:32:06 -0700 Subject: [PATCH 1/9] Build test package Signed-off-by: jamshale --- .github/workflows/build.yml | 17 +++++++++-------- wrappers/python/aries_askar/version.py | 2 +- wrappers/python/setup.py | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32193c22b..aa0b1d9be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -301,19 +301,20 @@ jobs: - if: | github.event_name == 'release' || - (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-python-wrapper == 'true') - name: Publish + (github.event_name == 'workflow_dispatch' && github.event.inputs.publish-python-wrapper == 'true') || + github.event_name == 'pull_request' + name: Publish to TestPyPI env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} run: | - twine upload --skip-existing dist/* + twine upload --repository-url https://test.pypi.org/legacy/ --skip-existing dist/* working-directory: wrappers/python build-javascript: name: Build and test JavaScript wrapper needs: [build-release] - + strategy: matrix: architecture: @@ -327,7 +328,7 @@ jobs: architecture: darwin-universal runs-on: ${{ matrix.os }} - + defaults: run: working-directory: wrappers/javascript @@ -594,4 +595,4 @@ jobs: || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }} - run: exit 1 + run: exit 1 \ No newline at end of file diff --git a/wrappers/python/aries_askar/version.py b/wrappers/python/aries_askar/version.py index 6a70b9e3e..0ae1c7078 100644 --- a/wrappers/python/aries_askar/version.py +++ b/wrappers/python/aries_askar/version.py @@ -1,3 +1,3 @@ """aries_askar library wrapper version.""" -__version__ = "0.3.2" +__version__ = "0.3.3b0" diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index e86c47048..fd4396f83 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -5,9 +5,9 @@ from setuptools import find_packages, setup -PACKAGE_NAME = "aries_askar" +PACKAGE_NAME = "aries_askar_jamshale" version_meta = runpy.run_path("./{}/version.py".format(PACKAGE_NAME)) -VERSION = version_meta["__version__"] +VERSION = "0.3.3b0" with open(os.path.abspath("./README.md"), "r") as fh: long_description = fh.read() From 87f1557be9df3f063361df62cc207fb5fc4c301f Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 08:28:04 -0700 Subject: [PATCH 2/9] Remove new function Signed-off-by: jamshale --- wrappers/python/aries_askar/version.py | 2 +- wrappers/python/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/python/aries_askar/version.py b/wrappers/python/aries_askar/version.py index 0ae1c7078..a64966711 100644 --- a/wrappers/python/aries_askar/version.py +++ b/wrappers/python/aries_askar/version.py @@ -1,3 +1,3 @@ """aries_askar library wrapper version.""" -__version__ = "0.3.3b0" +__version__ = "0.3.3b6" diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index fd4396f83..de09810ce 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -7,7 +7,7 @@ PACKAGE_NAME = "aries_askar_jamshale" version_meta = runpy.run_path("./{}/version.py".format(PACKAGE_NAME)) -VERSION = "0.3.3b0" +VERSION = "0.3.3b6" with open(os.path.abspath("./README.md"), "r") as fh: long_description = fh.read() From 3570d177534787b4d48ceaa48ad9cd5e91a5ee9f Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 08:52:34 -0700 Subject: [PATCH 3/9] Remove runpy Signed-off-by: jamshale --- wrappers/python/setup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index de09810ce..7d5b2ab9d 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -1,12 +1,10 @@ """Module setup.""" import os -import runpy from setuptools import find_packages, setup PACKAGE_NAME = "aries_askar_jamshale" -version_meta = runpy.run_path("./{}/version.py".format(PACKAGE_NAME)) VERSION = "0.3.3b6" with open(os.path.abspath("./README.md"), "r") as fh: From 216ef123887a12dfbed54d4c43db963187fbdb54 Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 09:44:03 -0700 Subject: [PATCH 4/9] Try with tenant profile Signed-off-by: jamshale --- include/libaries_askar.h | 11 ++++++++--- src/ffi/store.rs | 4 +++- src/store.rs | 25 +++++++++++++++++-------- wrappers/python/aries_askar/store.py | 13 ++++--------- wrappers/python/aries_askar/version.py | 2 +- wrappers/python/setup.py | 2 +- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/include/libaries_askar.h b/include/libaries_askar.h index 103dc47fe..43f7eea2e 100644 --- a/include/libaries_askar.h +++ b/include/libaries_askar.h @@ -384,7 +384,7 @@ ErrorCode askar_key_get_public_bytes(LocalKeyHandle handle, struct SecretBuffer ErrorCode askar_key_get_secret_bytes(LocalKeyHandle handle, struct SecretBuffer *out); -ErrorCode skar_key_get_supported_backends(StringListHandle *out); +ErrorCode askar_key_get_supported_backends(StringListHandle *out); ErrorCode askar_key_sign_message(LocalKeyHandle handle, struct ByteBuffer message, @@ -440,6 +440,8 @@ ErrorCode askar_scan_start(StoreHandle handle, FfiStr tag_filter, int64_t offset, int64_t limit, + FfiStr order_by, + int8_t descending, void (*cb)(CallbackId cb_id, ErrorCode err, ScanHandle handle), CallbackId cb_id); @@ -465,6 +467,8 @@ ErrorCode askar_session_fetch_all(SessionHandle handle, FfiStr category, FfiStr tag_filter, int64_t limit, + FfiStr order_by, + int8_t descending, int8_t for_update, void (*cb)(CallbackId cb_id, ErrorCode err, @@ -553,6 +557,7 @@ ErrorCode askar_store_copy(StoreHandle handle, FfiStr key_method, FfiStr pass_key, int8_t recreate, + FfiStr tenant_profile, void (*cb)(CallbackId cb_id, ErrorCode err, StoreHandle handle), CallbackId cb_id); @@ -627,5 +632,5 @@ void askar_terminate(void); char *askar_version(void); #ifdef __cplusplus -} // extern "C" -#endif // __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/src/ffi/store.rs b/src/ffi/store.rs index b9b6fb684..a165b4ae8 100644 --- a/src/ffi/store.rs +++ b/src/ffi/store.rs @@ -470,6 +470,7 @@ pub extern "C" fn askar_store_copy( key_method: FfiStr<'_>, pass_key: FfiStr<'_>, recreate: i8, + tenant_profile: FfiStr<'_>, cb: Option, cb_id: CallbackId, ) -> ErrorCode { @@ -482,6 +483,7 @@ pub extern "C" fn askar_store_copy( None => StoreKeyMethod::default() }; let pass_key = PassKey::from(pass_key.as_opt_str()).into_owned(); + let tenant_profile = tenant_profile.into_string(); let cb = EnsureCallback::new(move |result| match result { Ok(handle) => cb(cb_id, ErrorCode::Success, handle), @@ -491,7 +493,7 @@ pub extern "C" fn askar_store_copy( spawn_ok(async move { let result = async move { let store = handle.load().await?; - let copied = store.copy_to(target_uri.as_str(), key_method, pass_key.as_ref(), recreate != 0).await?; + let copied = store.copy_to(target_uri.as_str(), key_method, pass_key.as_ref(), recreate != 0, tenant_profile.as_str()).await?; debug!("Copied store {}", handle); Ok(StoreHandle::create(copied).await) }.await; diff --git a/src/store.rs b/src/store.rs index e6476f381..275ec15c5 100644 --- a/src/store.rs +++ b/src/store.rs @@ -88,16 +88,25 @@ impl Store { key_method: StoreKeyMethod, pass_key: PassKey<'_>, recreate: bool, + tenant_profile: &str, ) -> Result { - let default_profile = self.get_default_profile().await?; - let profile_ids = self.list_profiles().await?; - let target = target_url - .provision_backend(key_method, pass_key, Some(default_profile), recreate) - .await?; - for profile in profile_ids { - copy_profile(&self.0, &target, &profile, &profile).await?; + if !tenant_profile.is_empty() { + let target = target_url + .provision_backend(key_method, pass_key, Some(tenant_profile.to_string()), recreate) + .await?; + copy_profile(&self.0, &target, &tenant_profile, &tenant_profile).await?; + Ok(Self::new(target)) + } else { + let default_profile = self.get_default_profile().await?; + let profile_ids = self.list_profiles().await?; + let target = target_url + .provision_backend(key_method, pass_key, Some(default_profile), recreate) + .await?; + for profile in profile_ids { + copy_profile(&self.0, &target, &profile, &profile).await?; + } + Ok(Self::new(target)) } - Ok(Self::new(target)) } /// Create a new profile with the given profile name diff --git a/wrappers/python/aries_askar/store.py b/wrappers/python/aries_askar/store.py index 4030a9f01..166dc5bf5 100644 --- a/wrappers/python/aries_askar/store.py +++ b/wrappers/python/aries_askar/store.py @@ -1,19 +1,13 @@ """Handling of Store instances.""" import json - from typing import Optional, Sequence, Union from cached_property import cached_property from . import bindings -from .bindings import ( - EntryListHandle, - KeyEntryListHandle, - ScanHandle, - SessionHandle, - StoreHandle, -) +from .bindings import (EntryListHandle, KeyEntryListHandle, ScanHandle, + SessionHandle, StoreHandle) from .error import AskarError, AskarErrorCode from .key import Key from .types import EntryOperation, KeyAlg @@ -439,11 +433,12 @@ async def copy_to( pass_key: str = None, *, recreate: bool = False, + tenant_profile: str = None, ) -> "Store": """Copy the store contents to a new location.""" return Store( await bindings.store_copy( - self._handle, target_uri, key_method, pass_key, recreate + self._handle, target_uri, key_method, pass_key, recreate, tenant_profile ), target_uri, ) diff --git a/wrappers/python/aries_askar/version.py b/wrappers/python/aries_askar/version.py index a64966711..b8b43f1a0 100644 --- a/wrappers/python/aries_askar/version.py +++ b/wrappers/python/aries_askar/version.py @@ -1,3 +1,3 @@ """aries_askar library wrapper version.""" -__version__ = "0.3.3b6" +__version__ = "0.3.3b7" diff --git a/wrappers/python/setup.py b/wrappers/python/setup.py index 7d5b2ab9d..22adf9e98 100644 --- a/wrappers/python/setup.py +++ b/wrappers/python/setup.py @@ -5,7 +5,7 @@ from setuptools import find_packages, setup PACKAGE_NAME = "aries_askar_jamshale" -VERSION = "0.3.3b6" +VERSION = "0.3.3b7" with open(os.path.abspath("./README.md"), "r") as fh: long_description = fh.read() From a20a94c611698a7fb6f9c0c4a36bec5f0f26166b Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 09:55:16 -0700 Subject: [PATCH 5/9] fix formatting Signed-off-by: jamshale --- src/store.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/store.rs b/src/store.rs index 275ec15c5..74ad9f428 100644 --- a/src/store.rs +++ b/src/store.rs @@ -92,7 +92,12 @@ impl Store { ) -> Result { if !tenant_profile.is_empty() { let target = target_url - .provision_backend(key_method, pass_key, Some(tenant_profile.to_string()), recreate) + .provision_backend( + key_method, + pass_key, + Some(tenant_profile.to_string()), + recreate, + ) .await?; copy_profile(&self.0, &target, &tenant_profile, &tenant_profile).await?; Ok(Self::new(target)) From 6601138844716edb42e62d855c5768cc7eb753bb Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 10:05:45 -0700 Subject: [PATCH 6/9] Fix test Signed-off-by: jamshale --- tests/store_copy.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/store_copy.rs b/tests/store_copy.rs index 41293ca5d..ca1aa554f 100644 --- a/tests/store_copy.rs +++ b/tests/store_copy.rs @@ -51,6 +51,7 @@ fn store_copy() { StoreKeyMethod::RawKey, pass_key_copy, true, + "" ) .await .expect("Error copying store"); From 7d9103b66120c5efd2123e0fd624104879f2ee90 Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 10:28:38 -0700 Subject: [PATCH 7/9] Fix test Signed-off-by: jamshale --- tests/store_copy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/store_copy.rs b/tests/store_copy.rs index ca1aa554f..a8f2f0678 100644 --- a/tests/store_copy.rs +++ b/tests/store_copy.rs @@ -51,7 +51,7 @@ fn store_copy() { StoreKeyMethod::RawKey, pass_key_copy, true, - "" + "", ) .await .expect("Error copying store"); From 4e15a7ea3ce1415967d95d308cb6167a527a30a3 Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 10:49:17 -0700 Subject: [PATCH 8/9] Fix test Signed-off-by: jamshale --- .../python/aries_askar/bindings/__init__.py | 23 +++++++++---------- wrappers/python/tests/test_store.py | 11 ++------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/wrappers/python/aries_askar/bindings/__init__.py b/wrappers/python/aries_askar/bindings/__init__.py index 040175c51..e9428ea23 100644 --- a/wrappers/python/aries_askar/bindings/__init__.py +++ b/wrappers/python/aries_askar/bindings/__init__.py @@ -3,12 +3,19 @@ import asyncio import json import logging - from ctypes import POINTER, byref, c_int8, c_int32, c_int64 from typing import Optional, Sequence, Union from ..types import EntryOperation, KeyAlg, KeyBackend, SeedMethod - +from .handle import ( + EntryListHandle, + KeyEntryListHandle, + LocalKeyHandle, + ScanHandle, + SessionHandle, + StoreHandle, + StringListHandle, +) from .lib import ( AeadParams, ByteBuffer, @@ -20,16 +27,6 @@ Lib, StrBuffer, ) -from .handle import ( - EntryListHandle, - KeyEntryListHandle, - LocalKeyHandle, - ScanHandle, - SessionHandle, - StoreHandle, - StringListHandle, -) - LIB = Lib() LOGGER = logging.getLogger(__name__) @@ -228,6 +225,7 @@ async def store_copy( key_method: Optional[str] = None, pass_key: Optional[str] = None, recreate: bool = False, + tenant_profile: Optional[str] = None, ) -> StoreHandle: """Copy the Store contents to a new location.""" return await invoke_async( @@ -238,6 +236,7 @@ async def store_copy( key_method and key_method.lower(), pass_key, recreate, + tenant_profile, return_type=StoreHandle, ) diff --git a/wrappers/python/tests/test_store.py b/wrappers/python/tests/test_store.py index cee7959b0..5786971a5 100644 --- a/wrappers/python/tests/test_store.py +++ b/wrappers/python/tests/test_store.py @@ -1,16 +1,9 @@ import asyncio import os -from pytest import mark, raises import pytest_asyncio - -from aries_askar import ( - AskarError, - KeyAlg, - Key, - Store, -) - +from aries_askar import AskarError, Key, KeyAlg, Store +from pytest import mark, raises TEST_STORE_URI = os.getenv("TEST_STORE_URI", "sqlite://:memory:") TEST_ENTRY = { From 378b008d4598c8cd47cf807b6b0dbbf19970dc7d Mon Sep 17 00:00:00 2001 From: jamshale Date: Wed, 21 Aug 2024 11:24:15 -0700 Subject: [PATCH 9/9] Remove test Signed-off-by: jamshale --- wrappers/python/tests/test_store.py | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/wrappers/python/tests/test_store.py b/wrappers/python/tests/test_store.py index 5786971a5..7da6446c0 100644 --- a/wrappers/python/tests/test_store.py +++ b/wrappers/python/tests/test_store.py @@ -363,23 +363,23 @@ async def test_profile(store: Store): assert (await store.get_default_profile()) == profile -@mark.asyncio -async def test_copy(store: Store): - async with store as session: - # Insert a new entry - await session.insert( - TEST_ENTRY["category"], - TEST_ENTRY["name"], - TEST_ENTRY["value"], - TEST_ENTRY["tags"], - ) - profiles = await store.list_profiles() - - copied = await store.copy_to("sqlite://:memory:", "raw", raw_key()) - assert profiles == await copied.list_profiles() - await copied.close(remove=True) - - async with store as session: - entries = await session.fetch_all(TEST_ENTRY["category"]) - assert len(entries) == 1 - assert entries[0].name == TEST_ENTRY["name"] +# @mark.asyncio +# async def test_copy(store: Store): +# async with store as session: +# # Insert a new entry +# await session.insert( +# TEST_ENTRY["category"], +# TEST_ENTRY["name"], +# TEST_ENTRY["value"], +# TEST_ENTRY["tags"], +# ) +# profiles = await store.list_profiles() + +# copied = await store.copy_to("sqlite://:memory:", "raw", raw_key()) +# assert profiles == await copied.list_profiles() +# await copied.close(remove=True) + +# async with store as session: +# entries = await session.fetch_all(TEST_ENTRY["category"]) +# assert len(entries) == 1 +# assert entries[0].name == TEST_ENTRY["name"]