Example #1
0
    def test_generated_user_address(self):
        """Tests the Users address creation function as well as the
        address_is function.
        """

        ident = uuid4().hex
        address = addresser.make_user_address(ident)

        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.USER,
            "The address created must be found to be a User address.",
        )
Example #2
0
    def test_deterministic_user_address(self):
        """Tests that a specific user_id generates the expected
        user address, and thus is probably deterministic.
        """

        ident = "966ab67317234df489adb4bc1f517b88"
        expected_address = "9f444847e7570f3f6f7d2c1635f6de\
eabc1f4d78d9d42b64b70e1819f244138c1e38d6"

        address = addresser.make_user_address(ident)

        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.USER,
            "The User address created must be found to be a User address.",
        )
Example #3
0
    def test_users_address(self):
        """Tests the Users address creation function as well as the
        address_is function.

        Notes:
            1. Create a Users address.
            2. Assert that address_is returns the correct address type.

        """

        users_address = addresser.make_user_address(user_id=uuid4().hex)

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

        self.assertEqual(
            addresser.address_is(users_address),
            AddressSpace.USER,
            "The User address created must be found "
            "to be a User address.",
        )
Example #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),
        )
    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),
        )
Example #6
0
 def address(self, object_id, target_id=None):
     """Makes a blockchain address of this address type"""
     return legacy.make_user_address(user_id=object_id)