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
26 changes: 17 additions & 9 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@ on:

jobs:
build-and-test-python:
name: Test
name: Test Python code
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.8, 3.9]
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [3.8, 3.9 ] # '3.10' has issues for now
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.14.0
with:
workflow: "build-libs.yml"
path: ./libs
repo: trinsic-id/okapi
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: 3.9
- name: Build, Test, Pack
run: |
python -m pip install -r requirements.txt
Expand All @@ -41,14 +48,15 @@ jobs:
working-directory: python
env:
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
TEST_SERVER_ENDPOINT: staging-internal.trinsic.cloud
TEST_SERVER_PORT: 443
TEST_SERVER_USE_TLS: true
LD_LIBRARY_PATH: "${{ github.workspace }}/libs"
TEST_SERVER_ENDPOINT: ${{ secrets.TEST_SERVER_ENDPOINT }}
TEST_SERVER_PORT: ${{ secrets.TEST_SERVER_PORT }}
TEST_SERVER_USE_TLS: ${{ secrets.TEST_SERVER_USE_TLS }}
- name: Upload Unit Test Results - Python
if: always()
uses: actions/upload-artifact@v2
with:
name: Python ${{ matrix.python-version }} Unit Test Results (${{ matrix.os }})
name: Python Unit Test Results (${{ matrix.os }})
path: 'python/test_output*.xml'

publish-test-results-python:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
description: 'Version to build'
required: true
default: ''
release:
types: [ published ]

jobs:
release_testpypi:
Expand All @@ -24,10 +22,16 @@ jobs:
run: |
python -m pip install -r requirements.txt
python -m pip install build
python ../devops/build_sdks.py --github-token=${{ secrets.API_GITHUB_TOKEN }} --package-version=${{ github.event.inputs.packageVersion }}
python ../devops/build_sdks.py --package-version=${{ github.event.inputs.packageVersion }}
python -m build --sdist --wheel --outdir dist/ .
shell: pwsh
working-directory: python
env:
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
LD_LIBRARY_PATH: "${{ github.workspace }}/libs"
TEST_SERVER_ENDPOINT: ${{ secrets.TEST_SERVER_ENDPOINT }}
TEST_SERVER_PORT: ${{ secrets.TEST_SERVER_PORT }}
TEST_SERVER_USE_TLS: ${{ secrets.TEST_SERVER_USE_TLS }}
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
betterproto~=2.0.0b3
grpclib~=0.4.1
grpcio-tools
trinsic-okapi~=1.0.4
trinsic-okapi~=1.0.5
blake3~=0.2.1
10 changes: 4 additions & 6 deletions python/samples/provider_demo.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import asyncio

from trinsic.proto.services.provider.v1 import ParticipantType
from trinsic.services import ProviderService, WalletService
from trinsic.services import ProviderService, AccountService
from trinsic.trinsic_util import trinsic_test_config


async def provider_demo():
wallet_service = WalletService(trinsic_test_config())
wallet_profile = await wallet_service.create_wallet()
provider_service = ProviderService(trinsic_test_config())
provider_service.profile = wallet_profile
account_service = AccountService(server_config=trinsic_test_config())
account_profile, _ = await account_service.sign_in()
provider_service = ProviderService(account_profile, trinsic_test_config())
invite_response = await provider_service.invite_participant(
participant=ParticipantType.participant_type_individual,
description="I dunno",
email="scott.phillips@trinsic.id")
assert invite_response
provider_service.close()


if __name__ == "__main__":
Expand Down
33 changes: 20 additions & 13 deletions python/samples/vaccine_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import json
from os.path import abspath, join, dirname

from trinsic.proto.services.universalwallet.v1 import WalletProfile
from trinsic.services import WalletService
from trinsic.proto.services.account.v1 import AccountProfile, AccountDetails
from trinsic.services import WalletService, AccountService, CredentialsService
from trinsic.trinsic_util import trinsic_test_config

# pathData() {
Expand All @@ -22,14 +22,22 @@ def _vaccine_cert_frame_path() -> str:

async def vaccine_demo():
# createService() {
wallet_service = WalletService(trinsic_test_config())
account_service = AccountService(server_config=trinsic_test_config())
# }

# setupActors() {
# Create 3 different profiles for each participant in the scenario
allison = await wallet_service.create_wallet()
clinic = await wallet_service.create_wallet()
airline = await wallet_service.create_wallet()
allison, _ = await account_service.sign_in()
clinic, _ = await account_service.sign_in()
airline, _ = await account_service.sign_in()
# }

account_service.profile = clinic
info = await account_service.get_info()

# createService() {
wallet_service = WalletService(allison, trinsic_test_config())
credentials_service = CredentialsService(clinic, trinsic_test_config())
# }

# storeAndRecallProfile() {
Expand All @@ -38,18 +46,17 @@ async def vaccine_demo():
fid.write(bytes(allison))

# Create profile from existing data
allison = WalletProfile()
allison = AccountProfile()
with open("allison.bin", "rb") as fid:
allison.parse(fid.read())
# }

# issueCredential() {
# Sign a credential as the clinic and send it to Allison
wallet_service.profile = clinic
with open(_vaccine_cert_unsigned_path(), "r") as fid:
credential_json = json.load(fid)

credential = await wallet_service.issue_credential(credential_json)
credential = await credentials_service.issue_credential(credential_json)
print(f"Credential: {credential}")
# }

Expand All @@ -64,18 +71,18 @@ async def vaccine_demo():
# Allison shares the credential with the venue.
# The venue has communicated with Allison the details of the credential
# that they require expressed as a JSON-LD frame.
wallet_service.profile = allison
credentials_service.profile = allison
with open(_vaccine_cert_frame_path(), "r") as fid2:
proof_request_json = json.load(fid2)

credential_proof = await wallet_service.create_proof(document_id=item_id, reveal_document=proof_request_json)
credential_proof = await credentials_service.create_proof(document_id=item_id, reveal_document=proof_request_json)
print(f"Proof: {credential_proof}")
# }

# verifyCredential() {
# The airline verifies the credential
wallet_service.profile = airline
valid = await wallet_service.verify_proof(credential_proof)
credentials_service.profile = airline
valid = await credentials_service.verify_proof(credential_proof)

print(f"Verification result: {valid}")
assert valid
Expand Down
2 changes: 1 addition & 1 deletion python/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = trinsic-sdk
version = 1.1.1
version = 1.0.1
author = Scott Phillips
author_email = scott.phillips@trinsic.id
description = Trinsic Services SDK bindings
Expand Down
14 changes: 5 additions & 9 deletions python/tests/test_trinsic_services.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import unittest

import okapi.okapi_utils

from samples.provider_demo import provider_demo
from samples.vaccine_demo import vaccine_demo
from trinsic.services import WalletService
from trinsic.trinsic_util import trinsic_test_config


class TestServices(unittest.IsolatedAsyncioTestCase):
def setUp(self) -> None:
okapi.okapi_utils.download_binaries(False)

async def test_servicebase_setprofile(self):
wallet_service = WalletService(trinsic_test_config())
wallet_service = WalletService(None, trinsic_test_config())
with self.assertRaises(Exception) as excep:
self.assertIsNotNone(wallet_service.metadata(None))
self.assertTrue(excep.exception.args[0].lower() == "profile not set")
self.assertIsNotNone(wallet_service.build_metadata(None))
self.assertEqual("cannot call authenticated endpoint: profile must be set", excep.exception.args[0].lower())

async def test_providerservice_inviteparticipant(self):
await provider_demo()
# await provider_demo()
pass

async def test_vaccine_demo(self):
await vaccine_demo()
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from trinsic.services import create_channel
from trinsic.trinsic_util import create_channel


class TestUtilities(unittest.IsolatedAsyncioTestCase):
Expand Down
114 changes: 0 additions & 114 deletions python/trinsic/_service_wrappers.py

This file was deleted.

Empty file.
Loading