diff --git a/app/config.ini b/app/config.ini index fe952f8..5a97d75 100644 --- a/app/config.ini +++ b/app/config.ini @@ -3,7 +3,7 @@ debug = true # This is a unique ID that distinguish the Credential Issuer instance -uid = Credential Issuer 01 +uid = issuer_identifier # The abs path of the file where the keypair of the CI is stored # WARNING: if it does not exists will be created the first time @@ -22,4 +22,4 @@ AUTH_USERNAME = demo AUTH_PASSWORD = demo # Database -SQLALCHEMY_DATABASE_URI = sqlite:////app/app/test.db \ No newline at end of file +SQLALCHEMY_DATABASE_URI = sqlite:////app/app/test.db diff --git a/app/contracts b/app/contracts index ee33864..a62ecba 160000 --- a/app/contracts +++ b/app/contracts @@ -1 +1 @@ -Subproject commit ee33864ed36d30e52b326f2f622c813a3f0b446e +Subproject commit a62ecba9231438d821b788fcabdf26575b665286 diff --git a/app/zencontract.py b/app/zencontract.py index 306c276..594aa69 100644 --- a/app/zencontract.py +++ b/app/zencontract.py @@ -1,7 +1,6 @@ from pathlib import Path from zenroom import zenroom -from zenroom.zenroom import Error from app.config.config import BaseConfig @@ -41,34 +40,32 @@ def get_contract(self): contract = contracts_dir.joinpath(self.name).read_text() for k, v in self.placeholder.items(): contract = contract.replace(f"'{k}'", f"'{v}'") - return contract.encode() + return contract def execute(self): if config.getboolean("debug"): # pragma: no cover log.debug("+" * 50) log.debug("EXECUTING %s" % self.name) log.debug("+" * 50) - log.debug("DATA: %s" % self.data()) - log.debug("KEYS: %s" % self.keys()) - log.debug("CODE: \n%s" % self.zencode.decode()) - try: - result, errors = zenroom.execute( - self.zencode, keys=self._keys, data=self._data - ) - self._error = errors - return result.decode() - except Error: - return None + log.debug("DATA: %s" % self._data) + log.debug("KEYS: %s" % self._keys) + log.debug("CODE: \n%s" % self.zencode) + + result, errors = zenroom.zencode_exec( + script=self.zencode, keys=self._keys, data=self._data + ) + self._error = errors + return result def keys(self, keys=None): if keys: - self._keys = keys.encode() - return self._keys.decode() if self._keys else None + self._keys = keys + return self._keys def data(self, data=None): if data: - self._data = data.encode() - return self._data.decode() if self._data else None + self._data = data + return self._data def errors(self): return self._error diff --git a/setup.cfg b/setup.cfg index 2a08712..9dc95b4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ test=pytest [tool:pytest] -addopts = --cov=app --cov-report term-missing +addopts = --maxfail=1 --cov=app --cov-report term-missing env = DDDC_CREDENTIAL_ISSUER_CONFIGFILE=/home/puria/src/dddc-credential-issuer/app/test.ini diff --git a/setup.py b/setup.py index 6e5f80a..53b98d0 100644 --- a/setup.py +++ b/setup.py @@ -8,9 +8,9 @@ packages=find_packages(), install_requires=[ "bunch==1.0.1", - "fastapi==0.7.1", + "fastapi==0.33.0", "pytest_runner==4.4", - "zenroom==0.2.5", + "zenroom==1.0.5", "pre-commit==1.14.4", "python-multipart==0.0.5", "pyjwt==1.7.1", diff --git a/start.sh b/start.sh index 61cc504..d8f1269 100755 --- a/start.sh +++ b/start.sh @@ -1,4 +1,4 @@ #!/bin/sh docker build -t dddc-credential-issuer . -docker run --rm -p 80:80 -e APP_MODULE="app.main:api" -e LOG_LEVEL="debug" -it dddc-credential-issuer +docker run --rm -p 5000:80 -e APP_MODULE="app.main:api" -e LOG_LEVEL="debug" -it dddc-credential-issuer