Skip to content

Commit

Permalink
Merge pull request #31 from hyperledger/master
Browse files Browse the repository at this point in the history
Merging with the up-to-date solution
  • Loading branch information
denizgunseli authored May 12, 2020
2 parents e8c3329 + e81a2b8 commit 19a5778
Show file tree
Hide file tree
Showing 353 changed files with 7,392 additions and 7,094 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/blackformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Black Code Formatter Check

on:
pull_request:
branches:
- master

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Black Code Formatter Check
uses: lgeiger/[email protected]
with:
args: "--check ."
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# 0.5.1

## April 23, 2020

- Restore previous response format for the `/credential/{id}` admin route [#474](https://github.com/hyperledger/aries-cloudagent-python/pull/474)

# 0.5.0

## April 21, 2020

- Add support for credential revocation and revocation registry handling, with thanks to Medici Ventures [#306](https://github.com/hyperledger/aries-cloudagent-python/pull/306), [#417](https://github.com/hyperledger/aries-cloudagent-python/pull/417), [#425](https://github.com/hyperledger/aries-cloudagent-python/pull/425), [#429](https://github.com/hyperledger/aries-cloudagent-python/pull/429), [#432](https://github.com/hyperledger/aries-cloudagent-python/pull/432), [#435](https://github.com/hyperledger/aries-cloudagent-python/pull/435), [#441](https://github.com/hyperledger/aries-cloudagent-python/pull/441), [#455](https://github.com/hyperledger/aries-cloudagent-python/pull/455)
- **Breaking change** Remove previous credential and presentation protocols (0.1 versions) [#416](https://github.com/hyperledger/aries-cloudagent-python/pull/416)
- Add support for major/minor protocol version routing [#443](https://github.com/hyperledger/aries-cloudagent-python/pull/443)
- Event tracing and trace reports for message exchanges [#440](https://github.com/hyperledger/aries-cloudagent-python/pull/451)
- Support additional Indy restriction operators (`>`, `<`, `<=` in addition to `>=`) [#457](https://github.com/hyperledger/aries-cloudagent-python/pull/457)
- Support signed attachments according to the updated Aries RFC 0017 [#456](https://github.com/hyperledger/aries-cloudagent-python/pull/456)
- Increased test coverage [#442](https://github.com/hyperledger/aries-cloudagent-python/pull/442), [#453](https://github.com/hyperledger/aries-cloudagent-python/pull/453)
- Updates to demo agents and documentation [#402](https://github.com/hyperledger/aries-cloudagent-python/pull/402), [#403](https://github.com/hyperledger/aries-cloudagent-python/pull/403), [#411](https://github.com/hyperledger/aries-cloudagent-python/pull/411), [#415](https://github.com/hyperledger/aries-cloudagent-python/pull/415), [#422](https://github.com/hyperledger/aries-cloudagent-python/pull/422), [#423](https://github.com/hyperledger/aries-cloudagent-python/pull/423), [#449](https://github.com/hyperledger/aries-cloudagent-python/pull/449), [#450](https://github.com/hyperledger/aries-cloudagent-python/pull/450), [#452](https://github.com/hyperledger/aries-cloudagent-python/pull/452)
- Use Indy generate_nonce method to create proof request nonces [#431](https://github.com/hyperledger/aries-cloudagent-python/pull/431)
- Make request context available in the outbound transport handler [#408](https://github.com/hyperledger/aries-cloudagent-python/pull/408)
- Contain indy-anoncreds usage in IndyIssuer, IndyHolder, IndyProver classes [#406](https://github.com/hyperledger/aries-cloudagent-python/pull/406), [#463](https://github.com/hyperledger/aries-cloudagent-python/pull/463)
- Fix issue with validation of proof with predicates and revocation support [#400](https://github.com/hyperledger/aries-cloudagent-python/pull/400)

# 0.4.5

## March 3, 2020
Expand Down
17 changes: 11 additions & 6 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import uuid

from aiohttp import web
from aiohttp_apispec import docs, response_schema, setup_aiohttp_apispec
from aiohttp_apispec import (
docs,
response_schema,
setup_aiohttp_apispec,
validation_middleware,
)
import aiohttp_cors

from marshmallow import fields, Schema
Expand Down Expand Up @@ -149,7 +154,7 @@ def __init__(
async def make_application(self) -> web.Application:
"""Get the aiohttp application instance."""

middlewares = []
middlewares = [validation_middleware]

admin_api_key = self.context.settings.get("admin.admin_api_key")
admin_insecure_mode = self.context.settings.get("admin.admin_insecure_mode")
Expand Down Expand Up @@ -203,11 +208,11 @@ async def collect_stats(request, handler):

app.add_routes(
[
web.get("/", self.redirect_handler),
web.get("/plugins", self.plugins_handler),
web.get("/status", self.status_handler),
web.get("/", self.redirect_handler, allow_head=False),
web.get("/plugins", self.plugins_handler, allow_head=False),
web.get("/status", self.status_handler, allow_head=False),
web.post("/status/reset", self.status_reset_handler),
web.get("/ws", self.websocket_handler),
web.get("/ws", self.websocket_handler, allow_head=False),
]
)

Expand Down
17 changes: 15 additions & 2 deletions aries_cloudagent/admin/tests/test_admin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from aiohttp import web
from asynctest import TestCase as AsyncTestCase
from asynctest.mock import patch
from asynctest.mock import CoroutineMock, patch

from ...config.default_context import DefaultContextBuilder
from ...config.injection_context import InjectionContext
Expand All @@ -12,7 +13,7 @@
from ...core.protocol_registry import ProtocolRegistry
from ...transport.outbound.message import OutboundMessage

from ..server import AdminServer
from ..server import AdminServer, AdminSetupError


class TestAdminServerBasic(AsyncTestCase):
Expand Down Expand Up @@ -64,6 +65,11 @@ async def test_start_stop(self):
await server.start()
await server.stop()

with patch.object(web.TCPSite, "start", CoroutineMock()) as mock_start:
mock_start.side_effect = OSError("Failure to launch")
with self.assertRaises(AdminSetupError):
await self.get_admin_server(settings).start()

async def test_responder_send(self):
message = OutboundMessage(payload="{}")
admin_server = self.get_admin_server()
Expand All @@ -75,14 +81,21 @@ async def test_responder_webhook(self):
admin_server = self.get_admin_server()
test_url = "target_url"
test_attempts = 99
admin_server.add_webhook_target(test_url, max_attempts=test_attempts)
admin_server.add_webhook_target(
target_url=test_url,
topic_filter=["*"], # cover vacuous filter
max_attempts=test_attempts,
)
test_topic = "test_topic"
test_payload = {"test": "TEST"}
await admin_server.responder.send_webhook(test_topic, test_payload)
assert self.webhook_results == [
(test_topic, test_payload, test_url, test_attempts)
]

admin_server.remove_webhook_target(target_url=test_url)
assert test_url not in admin_server.webhook_targets

async def test_import_routes(self):
# this test just imports all default admin routes
# for routes with associated tests, this shouldn't make a difference in coverage
Expand Down
50 changes: 24 additions & 26 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def add_arguments(self, parser: ArgumentParser):
action="store_true",
help="Enables a remote debugging service that can be accessed\
using ptvsd for Visual Studio Code. The framework will wait\
for the debugger to connect at start-up. Default: false."
for the debugger to connect at start-up. Default: false.",
)
parser.add_argument(
"--debug-seed",
Expand Down Expand Up @@ -216,30 +216,30 @@ def add_arguments(self, parser: ArgumentParser):
dest="invite_role",
type=str,
metavar="<role>",
help="Specify the role of the generated invitation."
help="Specify the role of the generated invitation.",
)
parser.add_argument(
"--invite-label",
dest="invite_label",
type=str,
metavar="<label>",
help="Specify the label of the generated invitation."
help="Specify the label of the generated invitation.",
)
parser.add_argument(
"--invite-multi-use",
action="store_true",
help="Flag specifying the generated invite should be multi-use."
help="Flag specifying the generated invite should be multi-use.",
)
parser.add_argument(
"--invite-public",
action="store_true",
help="Flag specifying the generated invite should be public."
help="Flag specifying the generated invite should be public.",
)
parser.add_argument(
"--test-suite-endpoint",
type=str,
metavar="<endpoint>",
help="URL endpoint for sending messages to the test suite agent."
help="URL endpoint for sending messages to the test suite agent.",
)

parser.add_argument(
Expand Down Expand Up @@ -436,9 +436,9 @@ def add_arguments(self, parser: ArgumentParser):
type=str,
dest="genesis_transactions",
metavar="<genesis-transactions>",
help="Specifies the genesis transactions to use to connect to\
help='Specifies the genesis transactions to use to connect to\
an Hyperledger Indy ledger. The transactions are provided as string\
of JSON e.g. '{\"reqSignature\":{},\"txn\":{\"data\":{\"d... <snip>'",
of JSON e.g. \'{"reqSignature":{},"txn":{"data":{"d... <snip>\'',
)
parser.add_argument(
"--genesis-file",
Expand Down Expand Up @@ -538,7 +538,7 @@ def add_arguments(self, parser: ArgumentParser):
"--invite-base-url",
type=str,
metavar="<base-url>",
help="Base URL to use when formatting connection invitations in URL format."
help="Base URL to use when formatting connection invitations in URL format.",
)
parser.add_argument(
"--monitor-ping",
Expand All @@ -563,15 +563,13 @@ def add_arguments(self, parser: ArgumentParser):
help="Write timing information to a given log file.",
)
parser.add_argument(
"--trace",
action="store_true",
help="Generate tracing events.",
"--trace", action="store_true", help="Generate tracing events.",
)
parser.add_argument(
"--trace-target",
type=str,
metavar="<trace-target>",
help="Target for trace events (\"log\", \"message\", or http endpoint).",
help='Target for trace events ("log", "message", or http endpoint).',
)
parser.add_argument(
"--trace-tag",
Expand All @@ -588,7 +586,7 @@ def add_arguments(self, parser: ArgumentParser):
parser.add_argument(
"--preserve-exchange-records",
action="store_true",
help="Keep credential exchange records after exchange has completed."
help="Keep credential exchange records after exchange has completed.",
)

def get_settings(self, args: Namespace) -> dict:
Expand Down Expand Up @@ -622,20 +620,20 @@ def get_settings(self, args: Namespace) -> dict:
settings["trace.label"] = args.label
else:
settings["trace.label"] = "aca-py.agent"
if settings.get("trace.enabled"):
if settings.get("trace.enabled") or settings.get("trace.target"):
# make sure we can trace to the configured target
# (target can be set even if tracing is off)
try:
trace_event(
settings,
None,
handler="ArgParse",
outcome="Successfully configured aca-py",
raise_errors=True
outcome="Successfully_configured_aca-py",
raise_errors=True,
force_trace=True,
)
except Exception as e:
raise ArgsParseError(
"Error writing trace event "
+ str(e)
)
raise ArgsParseError("Error writing trace event " + str(e))
if args.preserve_exchange_records:
settings["preserve_exchange_records"] = True
return settings
Expand Down Expand Up @@ -782,11 +780,11 @@ def add_arguments(self, parser: ArgumentParser):
"--wallet-storage-creds",
type=str,
metavar="<storage-creds>",
help="Specify the storage credentials to use for the wallet.\
This is required if you are for using 'postgres_storage' wallet\
For example, '{\"account\":\"postgres\",\"password\":\
\"mysecretpassword\",\"admin_account\":\"postgres\",\"admin_password\":\
\"mysecretpassword\"}'",
help='Specify the storage credentials to use for the wallet.\
This is required if you are for using \'postgres_storage\' wallet\
For example, \'{"account":"postgres","password":\
"mysecretpassword","admin_account":"postgres","admin_password":\
"mysecretpassword"}\'',
)
parser.add_argument(
"--replace-public-did",
Expand Down
14 changes: 9 additions & 5 deletions aries_cloudagent/config/default_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
from ..issuer.base import BaseIssuer
from ..holder.base import BaseHolder
from ..verifier.base import BaseVerifier
from ..protocols.actionmenu.base_service import BaseMenuService
from ..protocols.actionmenu.driver_service import DriverMenuService
from ..protocols.introduction.base_service import BaseIntroductionService
from ..protocols.introduction.demo_service import DemoIntroductionService

# FIXME: We shouldn't rely on a hardcoded message version here.
from ..protocols.actionmenu.v1_0.base_service import BaseMenuService
from ..protocols.actionmenu.v1_0.driver_service import DriverMenuService
from ..protocols.introduction.v0_1.base_service import BaseIntroductionService
from ..protocols.introduction.v0_1.demo_service import DemoIntroductionService

from ..storage.base import BaseStorage
from ..storage.provider import StorageProvider
from ..transport.wire_format import BaseWireFormat
Expand Down Expand Up @@ -114,7 +117,7 @@ async def bind_providers(self, context: InjectionContext):
BaseVerifier,
ClassProvider(
"aries_cloudagent.verifier.indy.IndyVerifier",
ClassProvider.Inject(BaseWallet),
ClassProvider.Inject(BaseLedger),
),
)

Expand Down Expand Up @@ -149,6 +152,7 @@ async def load_plugins(self, context: InjectionContext):
plugin_registry.register_package("aries_cloudagent.protocols")

# Currently providing admin routes only
plugin_registry.register_plugin("aries_cloudagent.holder")
plugin_registry.register_plugin("aries_cloudagent.ledger")
plugin_registry.register_plugin(
"aries_cloudagent.messaging.credential_definitions"
Expand Down
24 changes: 11 additions & 13 deletions aries_cloudagent/connections/models/connection_record.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""Handle connection information interface with non-secrets storage."""

from marshmallow import fields
from marshmallow.validate import OneOf
from marshmallow import fields, validate

from ...config.injection_context import InjectionContext
from ...messaging.models.base_record import BaseRecord, BaseRecordSchema
from ...messaging.valid import INDY_DID, INDY_RAW_PUBLIC_KEY, UUIDFour
from ...protocols.connections.messages.connection_invitation import ConnectionInvitation
from ...protocols.connections.messages.connection_request import ConnectionRequest

# FIXME: We shouldn't rely on a hardcoded message version here.
from ...protocols.connections.v1_0.messages.connection_invitation import (
ConnectionInvitation,
)
from ...protocols.connections.v1_0.messages.connection_request import ConnectionRequest
from ...storage.base import BaseStorage
from ...storage.record import StorageRecord

Expand All @@ -24,12 +27,7 @@ class Meta:
WEBHOOK_TOPIC = "connections"
LOG_STATE_FLAG = "debug.connections"
CACHE_ENABLED = True
TAG_NAMES = {
"my_did",
"their_did",
"request_id",
"invitation_key",
}
TAG_NAMES = {"my_did", "their_did", "request_id", "invitation_key"}

RECORD_TYPE = "connection"
RECORD_TYPE_INVITATION = "connection_invitation"
Expand Down Expand Up @@ -299,7 +297,7 @@ class Meta:
required=False,
description="Connection initiator: self, external, or multiuse",
example=ConnectionRecord.INITIATOR_SELF,
validate=OneOf(["self", "external", "multiuse"]),
validate=validate.OneOf(["self", "external", "multiuse"]),
)
invitation_key = fields.Str(
required=False, description="Public key for connection", **INDY_RAW_PUBLIC_KEY
Expand All @@ -318,7 +316,7 @@ class Meta:
required=False,
description="Connection acceptance: manual or auto",
example=ConnectionRecord.ACCEPT_AUTO,
validate=OneOf(["manual", "auto"]),
validate=validate.OneOf(["manual", "auto"]),
)
error_msg = fields.Str(
required=False,
Expand All @@ -329,7 +327,7 @@ class Meta:
required=False,
description="Invitation mode: once, multi, or static",
example=ConnectionRecord.INVITATION_MODE_ONCE,
validate=OneOf(["once", "multi", "static"]),
validate=validate.OneOf(["once", "multi", "static"]),
)
alias = fields.Str(
required=False,
Expand Down
9 changes: 7 additions & 2 deletions aries_cloudagent/core/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
from ..config.logging import LoggingConfigurator
from ..config.wallet import wallet_config
from ..messaging.responder import BaseResponder
from ..protocols.connections.manager import ConnectionManager, ConnectionManagerError

# FIXME: We shouldn't rely on a hardcoded message version here.
from ..protocols.connections.v1_0.manager import (
ConnectionManager,
ConnectionManagerError,
)
from ..transport.inbound.manager import InboundTransportManager
from ..transport.inbound.message import InboundMessage
from ..transport.outbound.base import OutboundDeliveryError
Expand Down Expand Up @@ -73,7 +78,7 @@ async def setup(self):

# Register all inbound transports
self.inbound_transport_manager = InboundTransportManager(
context, self.inbound_message_router, self.handle_not_returned,
context, self.inbound_message_router, self.handle_not_returned
)
await self.inbound_transport_manager.setup()

Expand Down
Loading

0 comments on commit 19a5778

Please sign in to comment.