Beispiel #1
0
    def test_generated_task_admin_addr(self):
        """Tests the task admin address creation function as well as the
        address_is function.
        """

        task_id = uuid4().hex
        admin_id = uuid4().hex
        address = addresser.make_task_admins_address(task_id, admin_id)

        self.assertEqual(len(address), addresser.ADDRESS_LENGTH,
                         "The address is 70 characters")

        self.assertTrue(addresser.is_address(address),
                        "The address is 70 character hexidecimal")

        self.assertTrue(addresser.namespace_ok(address),
                        "The address has correct namespace prefix")

        self.assertTrue(
            addresser.is_family_address(address),
            "The address is 70 character hexidecimal with family prefix",
        )

        self.assertEqual(
            addresser.address_is(address),
            AddressSpace.TASKS_ADMINS,
            "The address created must be a Task Attributes address.",
        )
Beispiel #2
0
    def test_determine_task_admin_addr(self):
        """Tests that a specific task_id and admin_id generates the
        expected task admin address, and thus is probably deterministic.
        """

        task_id = "99968acb8f1a48b3a4bc21e2cd252e67"
        admin_id = "966ab67317234df489adb4bc1f517b88"
        expected_address = "9f44481e326a1713a905b26359fc8d\
a2817c1a5f67de6f464701f0c10042da345d2848"

        address = addresser.make_task_admins_address(task_id, admin_id)

        self.assertEqual(len(address), addresser.ADDRESS_LENGTH,
                         "The address is 70 characters")

        self.assertTrue(addresser.is_address(address),
                        "The address is 70 character hexidecimal")

        self.assertTrue(addresser.namespace_ok(address),
                        "The address has correct namespace prefix")

        self.assertTrue(
            addresser.is_family_address(address),
            "The address is 70 character hexidecimal with family prefix",
        )

        self.assertEqual(address, expected_address,
                         "The address is the one we expected it to be")

        self.assertEqual(
            addresser.address_is(address),
            AddressSpace.TASKS_ADMINS,
            "The address created must be a Task Attributes address.",
        )
    def test_task_addresses(self):
        """Tests the Task address creation functions as well as the
        address_is function.

        Notes:
            1. Create an address of a particular type:
                - Task Attributes
                - Task Owners
                - Task Admins
            2. Assert that address_is returns the correct address type.

        """

        task_address = addresser.make_task_attributes_address(uuid4().hex)

        self.assertEqual(len(task_address), 70, "The address is a well-formed address.")

        self.assertEqual(
            addresser.address_is(task_address),
            AddressSpace.TASKS_ATTRIBUTES,
            "The Task Attributes address created must be "
            "found to be a Task Attributes address.",
        )

        task_owners_address = addresser.make_task_owners_address(
            task_id=uuid4().hex, user_id=uuid4().hex
        )

        self.assertEqual(
            len(task_owners_address), 70, "The address is a well-formed address."
        )

        self.assertEqual(
            addresser.address_is(task_owners_address),
            AddressSpace.TASKS_OWNERS,
            "The Task Owners address created must be "
            "found to be a Task Owners address.",
        )

        task_admins_address = addresser.make_task_admins_address(
            task_id=uuid4().hex, user_id=uuid4().hex
        )

        self.assertEqual(
            len(task_admins_address), 70, "The address is a well-formed address."
        )

        self.assertEqual(
            addresser.address_is(task_admins_address),
            AddressSpace.TASKS_ADMINS,
            "The Task Admins address created must be "
            "found to be a Task Admins address.",
        )
Beispiel #4
0
    def test_legacy_make_addresses(self):
        user_id = Key().public_key
        unique_id = addresser.role.unique_id()
        unique_id2 = addresser.task.unique_id()

        self.assertEqual(
            legacy.make_user_address(user_id=user_id),
            addresser.user.address(object_id=user_id),
        )

        self.assertEqual(
            legacy.make_role_attributes_address(role_id=unique_id),
            addresser.role.address(object_id=unique_id),
        )
        self.assertEqual(
            legacy.make_role_owners_address(role_id=unique_id,
                                            user_id=user_id),
            addresser.role.owner.address(object_id=unique_id,
                                         target_id=user_id),
        )
        self.assertEqual(
            legacy.make_role_admins_address(role_id=unique_id,
                                            user_id=user_id),
            addresser.role.admin.address(object_id=unique_id,
                                         target_id=user_id),
        )
        self.assertEqual(
            legacy.make_role_members_address(role_id=unique_id,
                                             user_id=user_id),
            addresser.role.member.address(object_id=unique_id,
                                          target_id=user_id),
        )
        self.assertEqual(
            legacy.make_role_tasks_address(role_id=unique_id,
                                           task_id=unique_id2),
            addresser.role.task.address(object_id=unique_id,
                                        target_id=unique_id2),
        )

        self.assertEqual(
            legacy.make_task_attributes_address(task_id=unique_id),
            addresser.task.address(object_id=unique_id),
        )
        self.assertEqual(
            legacy.make_task_owners_address(task_id=unique_id,
                                            user_id=user_id),
            addresser.task.owner.address(object_id=unique_id,
                                         target_id=user_id),
        )
        self.assertEqual(
            legacy.make_task_admins_address(task_id=unique_id,
                                            user_id=user_id),
            addresser.task.admin.address(object_id=unique_id,
                                         target_id=user_id),
        )

        self.assertEqual(legacy.make_sysadmin_attr_address(),
                         addresser.sysadmin.address())
        self.assertEqual(
            legacy.make_sysadmin_owners_address(user_id=user_id),
            addresser.sysadmin.owner.address(object_id=user_id),
        )
        self.assertEqual(
            legacy.make_sysadmin_admins_address(user_id=user_id),
            addresser.sysadmin.admin.address(object_id=user_id),
        )
        self.assertEqual(
            legacy.make_sysadmin_members_address(user_id=user_id),
            addresser.sysadmin.member.address(object_id=user_id),
        )
Beispiel #5
0
 def address(self, object_id, target_id=None):
     """Makes a blockchain address of this address type"""
     return legacy.make_task_admins_address(task_id=object_id,
                                            user_id=target_id)
    def test_legacy_make_addresses(self):
        """Test equality of the legacy addresser and new addresser classes"""
        user_id = Key().public_key
        unique_id = addresser.role.unique_id()
        unique_id2 = addresser.task.unique_id()

        self.assertEqual(
            legacy.make_user_address(user_id=user_id),
            addresser.user.address(object_id=user_id),
        )

        self.assertEqual(
            legacy.make_role_attributes_address(role_id=unique_id),
            addresser.role.address(object_id=unique_id),
        )
        self.assertEqual(
            legacy.make_role_owners_address(role_id=unique_id,
                                            user_id=user_id),
            addresser.role.owner.address(object_id=unique_id,
                                         related_id=user_id),
        )
        self.assertEqual(
            legacy.make_role_admins_address(role_id=unique_id,
                                            user_id=user_id),
            addresser.role.admin.address(object_id=unique_id,
                                         related_id=user_id),
        )
        self.assertEqual(
            legacy.make_role_members_address(role_id=unique_id,
                                             user_id=user_id),
            addresser.role.member.address(object_id=unique_id,
                                          related_id=user_id),
        )
        self.assertEqual(
            legacy.make_role_tasks_address(role_id=unique_id,
                                           task_id=unique_id2),
            addresser.role.task.address(object_id=unique_id,
                                        related_id=unique_id2),
        )

        self.assertEqual(
            legacy.make_task_attributes_address(task_id=unique_id),
            addresser.task.address(object_id=unique_id),
        )
        self.assertEqual(
            legacy.make_task_owners_address(task_id=unique_id,
                                            user_id=user_id),
            addresser.task.owner.address(object_id=unique_id,
                                         related_id=user_id),
        )
        self.assertEqual(
            legacy.make_task_admins_address(task_id=unique_id,
                                            user_id=user_id),
            addresser.task.admin.address(object_id=unique_id,
                                         related_id=user_id),
        )

        self.assertEqual(legacy.make_sysadmin_attr_address(),
                         addresser.sysadmin.address())
        self.assertEqual(
            legacy.make_sysadmin_owners_address(user_id=user_id),
            addresser.sysadmin.owner.address(object_id=user_id),
        )
        self.assertEqual(
            legacy.make_sysadmin_admins_address(user_id=user_id),
            addresser.sysadmin.admin.address(object_id=user_id),
        )
        self.assertEqual(
            legacy.make_sysadmin_members_address(user_id=user_id),
            addresser.sysadmin.member.address(object_id=user_id),
        )