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

update unit tests per keripy updates. credential tests still fail #74

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions .github/workflows/python-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Enforce Python Code Formatting

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
format-check:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install black
run: pip install black

- name: Run black
run: black --check .
104 changes: 51 additions & 53 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,74 +31,72 @@
from setuptools import find_packages, setup

setup(
name='dkr',
version='0.0.7', # also change in src/did-webs-resolver/__init__.py
license='Apache Software License 2.0',
description='did:webs DID Method Resolver',
name="dkr",
version="0.0.7", # also change in src/did-webs-resolver/__init__.py
license="Apache Software License 2.0",
description="did:webs DID Method Resolver",
long_description="did:webs DID Method Resolver.",
author='Philip S. Feairheller',
author_email='pfeairheller@gmail.com',
url='https://github.com/hyperledger-labs/did-webs-resolver',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
author="Philip S. Feairheller",
author_email="pfeairheller@gmail.com",
url="https://github.com/hyperledger-labs/did-webs-resolver",
packages=find_packages("src"),
package_dir={"": "src"},
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
include_package_data=True,
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: Unix',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Utilities',
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: Unix",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Utilities",
],
project_urls={
'Documentation': 'https://kara.readthedocs.io/',
'Changelog': 'https://kara.readthedocs.io/en/latest/changelog.html',
'Issue Tracker': 'https://github.com/WebOfTrust/kara/issues',
"Documentation": "https://kara.readthedocs.io/",
"Changelog": "https://kara.readthedocs.io/en/latest/changelog.html",
"Issue Tracker": "https://github.com/WebOfTrust/kara/issues",
},
keywords=[
# eg: 'keyword1', 'keyword2', 'keyword3',
],
python_requires='>=3.10.13',
python_requires=">=3.10.13",
install_requires=[
'aiohttp>=3.7.4',
'lmdb>=1.3.0',
'pysodium>=0.7.12',
'blake3>=0.3.1',
'msgpack>=1.0.4',
'cbor2>=5.4.3',
'multidict>=6.0.2',
'ordered-set>=4.1.0',
'keri>=1.1.4',
'hio>=0.6.9',
'multicommand>=1.0.0',
'jsonschema>=4.17.0',
'falcon>=3.1.0',
'hjson>=3.0.2',
'PyYaml>=6.0',
'apispec>=6.0.0',
'mnemonic>=0.20',
'PrettyTable>=3.5.0',
'http_sfv>=0.9.8',
'cryptography>=39.0.2',
'requests>=2.28',
'pytest>=6.2.5',
'pytest-timeout>=2.3.1'
"aiohttp>=3.7.4",
"lmdb>=1.3.0",
"pysodium>=0.7.12",
"blake3>=0.3.1",
"msgpack>=1.0.4",
"cbor2>=5.4.3",
"multidict>=6.0.2",
"ordered-set>=4.1.0",
"keri>=1.1.17",
"hio>=0.6.9",
"multicommand>=1.0.0",
"jsonschema>=4.17.0",
"falcon>=3.1.0",
"hjson>=3.0.2",
"PyYaml>=6.0",
"apispec>=6.0.0",
"mnemonic>=0.20",
"PrettyTable>=3.5.0",
"http_sfv>=0.9.8",
"cryptography>=39.0.2",
"requests>=2.28",
"pytest>=6.2.5",
"pytest-timeout>=2.3.1",
],
extras_require={
},
extras_require={},
tests_require=[
'coverage>=5.5',
],
setup_requires=[
"coverage>=5.5",
],
setup_requires=[],
entry_points={
'console_scripts': [
'dkr = dkr.app.cli.dkr:main',
"console_scripts": [
"dkr = dkr.app.cli.dkr:main",
]
},
)
62 changes: 43 additions & 19 deletions src/dkr/app/cli/commands/did/keri/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,51 @@

from dkr.core import didding

parser = argparse.ArgumentParser(description='Resolve a did:keri DID')
parser.set_defaults(handler=lambda args: handler(args),
transferable=True)
parser.add_argument('-n', '--name',
action='store',
default="dkr",
help="Name of controller. Default is dkr.")
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--passcode', help='22 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument("--did", "-d", help="DID to resolve (did:keri method)", required=True)
parser.add_argument("--oobi", "-o", help="OOBI to use for resolving the DID", required=False)
parser.add_argument("--meta", "-m", help="Whether to include metadata (True), or only return the DID document (False)", type=bool, required=False, default=None)
parser = argparse.ArgumentParser(description="Resolve a did:keri DID")
parser.set_defaults(handler=lambda args: handler(args), transferable=True)
parser.add_argument(
"-n",
"--name",
action="store",
default="dkr",
help="Name of controller. Default is dkr.",
)
parser.add_argument(
"--base",
"-b",
help="additional optional prefix to file location of KERI keystore",
required=False,
default="",
)
parser.add_argument(
"--passcode",
help="22 character encryption passcode for keystore (is not saved)",
dest="bran",
default=None,
) # passcode => bran
parser.add_argument(
"--did", "-d", help="DID to resolve (did:keri method)", required=True
)
parser.add_argument(
"--oobi", "-o", help="OOBI to use for resolving the DID", required=False
)
parser.add_argument(
"--meta",
"-m",
help="Whether to include metadata (True), or only return the DID document (False)",
type=bool,
required=False,
default=None,
)


def handler(args):
hby = existing.setupHby(name=args.name, base=args.base, bran=args.bran)
hbyDoer = habbing.HaberyDoer(habery=hby) # setup doer
obl = oobiing.Oobiery(hby=hby)
res = KeriResolver(hby=hby, hbyDoer=hbyDoer, obl=obl, did=args.did, oobi=args.oobi, meta=args.meta)
res = KeriResolver(
hby=hby, hbyDoer=hbyDoer, obl=obl, did=args.did, oobi=args.oobi, meta=args.meta
)
return [res]


Expand All @@ -55,7 +79,7 @@ def __init__(self, hby, hbyDoer, obl, did, oobi, meta):
def resolve(self, tymth, tock=0.0, **opts):
self.wind(tymth)
self.tock = tock
_ = (yield self.tock)
_ = yield self.tock

aid = didding.parseDIDKeri(self.did)
print(f"From arguments got aid: {aid}", file=sys.stderr)
Expand All @@ -68,13 +92,13 @@ def resolve(self, tymth, tock=0.0, **opts):
while self.hby.db.roobi.get(keys=(self.oobi,)) is None:
_ = yield tock

didresult = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=self.oobi, meta=True)
didresult = didding.generateDIDDoc(
self.hby, did=self.did, aid=aid, oobi=self.oobi, meta=True
)
dd = didresult[didding.DD_FIELD]
result = didresult if self.meta else dd
data = json.dumps(result, indent=2)

print(data)
self.remove(self.toRemove)
return result


91 changes: 55 additions & 36 deletions src/dkr/app/cli/commands/did/keri/resolver-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,51 @@

from dkr.core import resolving

parser = argparse.ArgumentParser(description='Expose did:keri resolver as an HTTP web service')
parser.set_defaults(handler=lambda args: launch(args),
transferable=True)
parser.add_argument('-p', '--http',
action='store',
default=7678,
help="Port on which to listen for did:keri resolution requests. Defaults to 7678")
parser.add_argument('-n', '--name',
action='store',
default="dkr",
help="Name of controller. Default is dkr.")
parser.add_argument('--base', '-b', help='additional optional prefix to file location of KERI keystore',
required=False, default="")
parser.add_argument('--passcode', help='22 character encryption passcode for keystore (is not saved)',
dest="bran", default=None) # passcode => bran
parser.add_argument("--config-dir",
"-c",
dest="configDir",
help="directory override for configuration data",
default=None)
parser.add_argument('--config-file',
dest="configFile",
action='store',
default=None,
help="configuration filename override")
parser = argparse.ArgumentParser(
description="Expose did:keri resolver as an HTTP web service"
)
parser.set_defaults(handler=lambda args: launch(args), transferable=True)
parser.add_argument(
"-p",
"--http",
action="store",
default=7678,
help="Port on which to listen for did:keri resolution requests. Defaults to 7678",
)
parser.add_argument(
"-n",
"--name",
action="store",
default="dkr",
help="Name of controller. Default is dkr.",
)
parser.add_argument(
"--base",
"-b",
help="additional optional prefix to file location of KERI keystore",
required=False,
default="",
)
parser.add_argument(
"--passcode",
help="22 character encryption passcode for keystore (is not saved)",
dest="bran",
default=None,
) # passcode => bran
parser.add_argument(
"--config-dir",
"-c",
dest="configDir",
help="directory override for configuration data",
default=None,
)
parser.add_argument(
"--config-file",
dest="configFile",
action="store",
default=None,
help="configuration filename override",
)


def launch(args, expire=0.0):
Expand All @@ -46,22 +66,21 @@ def launch(args, expire=0.0):
configFile = args.configFile
configDir = args.configDir

ks = keeping.Keeper(name=name,
base=base,
temp=False,
reopen=True)
ks = keeping.Keeper(name=name, base=base, temp=False, reopen=True)

aeid = ks.gbls.get('aeid')
aeid = ks.gbls.get("aeid")

cf = None
if aeid is None:
if configFile is not None:
cf = configing.Configer(name=configFile,
base=base,
headDirPath=configDir,
temp=False,
reopen=True,
clear=False)
cf = configing.Configer(
name=configFile,
base=base,
headDirPath=configDir,
temp=False,
reopen=True,
clear=False,
)

hby = habbing.Habery(name=name, base=base, bran=bran, cf=cf)
else:
Expand Down
Loading
Loading