def setUp(self):
        self.storage = BasicStorage()
        self.cache = BasicCache()
        self.wallet = BasicWallet()
        self.responder = MockResponder()
        self.responder.send = async_mock.CoroutineMock()

        self.context = InjectionContext(enforce_typing=False)
        self.context.injector.bind_instance(BaseStorage, self.storage)
        self.context.injector.bind_instance(BaseWallet, self.wallet)
        self.context.injector.bind_instance(BaseResponder, self.responder)
        self.context.injector.bind_instance(BaseCache, self.cache)
        self.ledger = async_mock.create_autospec(BaseLedger)
        self.ledger.__aenter__ = async_mock.CoroutineMock(
            return_value=self.ledger)
        self.context.injector.bind_instance(BaseLedger, self.ledger)
        self.context.update_settings({
            "default_endpoint":
            TestConfig.test_endpoint,
            "default_label":
            "This guy",
            "additional_endpoints": ["http://aries.ca/another-endpoint"],
            "debug.auto_accept_invites":
            True,
            "debug.auto_accept_requests":
            True,
        })

        self.manager = OutOfBandManager(self.context)
        self.test_conn_rec = ConnectionRecord(
            my_did=TestConfig.test_did,
            their_did=TestConfig.test_target_did,
            their_role=None,
            state=ConnectionRecord.STATE_ACTIVE,
        )
    async def test_properties(self, wallet):
        assert wallet.name
        assert wallet.type == "basic"
        assert wallet.handle is None
        none_wallet = BasicWallet()
        assert none_wallet.name is None

        assert "BasicWallet" in str(wallet)
        assert wallet.created
Ejemplo n.º 3
0
 async def test_make_model(self):
     connection_response = ConnectionResponse(connection=ConnectionDetail(
         did=self.test_did, did_doc=self.make_did_doc()))
     wallet = BasicWallet()
     key_info = await wallet.create_signing_key()
     await connection_response.sign_field("connection", key_info.verkey,
                                          wallet)
     data = connection_response.serialize()
     model_instance = ConnectionResponse.deserialize(data)
     assert type(model_instance) is type(connection_response)
Ejemplo n.º 4
0
    def setUp(self):
        self.context = InjectionContext(enforce_typing=False)

        self.storage = async_mock.create_autospec(BaseStorage)

        self.context.injector.bind_instance(BaseStorage, self.storage)

        self.wallet = self.wallet = BasicWallet()
        self.context.injector.bind_instance(BaseWallet, self.wallet)

        self.app = {
            "request_context": self.context,
        }
async def wallet():
    wallet = BasicWallet({"name": "basic"})
    await wallet.open()
    yield wallet
    await wallet.close()
async def basic_wallet():
    wallet = BasicWallet()
    await wallet.open()
    yield wallet
    await wallet.close()
    async def test_save_retrieve_delete_connection_menu(self):
        self.storage = BasicStorage()
        self.context = InjectionContext()
        self.context.injector.bind_instance(BaseStorage, self.storage)
        self.context.injector.bind_instance(BaseWallet, BasicWallet())

        self.responder = MockResponder()
        self.context.injector.bind_instance(test_module.BaseResponder,
                                            self.responder)

        menu = test_module.Menu(
            title="title",
            description="description",
            errormsg=None,
            options=[
                MenuOption(
                    name=f"name-{i}",
                    title=f"option-title-{i}",
                    description=f"option-description-{i}",
                    disabled=bool(i % 2),
                    form=MenuForm(
                        title=f"form-title-{i}",
                        description=f"form-description-{i}",
                        params=[
                            MenuFormParam(
                                name=f"param-name-{i}-{j}",
                                title=f"param-title-{i}-{j}",
                                default=f"param-default-{i}-{j}",
                                description=f"param-description-{i}-{j}",
                                input_type="int",
                                required=bool((i + j) % 2),
                            ) for j in range(2)
                        ],
                    ),
                ) for i in range(3)
            ],
        )
        connection_id = "connid"

        for i in range(2):  # once to add, once to update
            await test_module.save_connection_menu(menu, connection_id,
                                                   self.context)

            webhooks = self.responder.webhooks
            assert len(webhooks) == 1
            (result, target) = webhooks[0]
            assert result == "actionmenu"
            assert target["connection_id"] == connection_id
            assert target["menu"] == menu.serialize()
            self.responder.webhooks.clear()

        # retrieve connection menu
        assert (await test_module.retrieve_connection_menu(
            connection_id, self.context)).serialize() == menu.serialize()

        # delete connection menu
        await test_module.save_connection_menu(None, connection_id,
                                               self.context)

        webhooks = self.responder.webhooks
        assert len(webhooks) == 1
        (result, target) = webhooks[0]
        assert result == "actionmenu"
        assert target == {"connection_id": connection_id, "menu": None}
        self.responder.webhooks.clear()

        # retrieve no menu
        assert (await test_module.retrieve_connection_menu(
            connection_id, self.context) is None)