コード例 #1
0
    def test_gen_sysadmin_owner_addr(self):
        """Tests the sysadmin owner address creation function as well as the
        address_is function.
        """

        owner_id = uuid4().hex
        address = addresser.make_sysadmin_owners_address(owner_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.SYSADMIN_OWNERS,
            "The address created must be a SysAdmin Attributes address.",
        )
コード例 #2
0
    def test_det_sysadmin_owner_addr(self):
        """Tests that a specific owner_id generates the expected
        sysadmin owner address, and thus is probably deterministic.
        """

        owner_id = "966ab67317234df489adb4bc1f517b88"
        expected_address = "9f4448000000000000000000000000\
00000000000000000000000000000000000000de"

        address = addresser.make_sysadmin_owners_address(owner_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.SYSADMIN_OWNERS,
            "The address created must be a SysAdmin Attributes address.",
        )
コード例 #3
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),
        )
コード例 #4
0
    def test_sysadmin_addresses(self):
        """Tests the SysAdmin address creation functions as well as the
        address_is function.

        Notes:
            1. Create a SysAdmin address.
                - SysAdmin Attributes
                - SysAdmin Members
                - SysAdmin Owners
                - SysAdmin Admins
            2. Assert that the address_is function returns the correct
               address type.
        """

        sysadmin_address = addresser.make_sysadmin_attr_address()

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

        self.assertEqual(
            addresser.address_is(sysadmin_address),
            AddressSpace.SYSADMIN_ATTRIBUTES,
            "The SysAdmin Attributes address created must be found "
            "to be a SysAdmin Attributes address.",
        )

        sysadmin_members_address = addresser.make_sysadmin_members_address(
            user_id=uuid4().hex)

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

        self.assertEqual(
            addresser.address_is(sysadmin_members_address),
            AddressSpace.SYSADMIN_MEMBERS,
            "The SysAdmin Members address created must be found to "
            "be a SysAdmin Members address.",
        )

        sysadmin_owners_address = addresser.make_sysadmin_owners_address(
            user_id=uuid4().hex)

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

        self.assertEqual(
            addresser.address_is(sysadmin_owners_address),
            AddressSpace.SYSADMIN_OWNERS,
            "The SysAdmin Owners address created must be found to "
            "be a SysAdmin Owners address.",
        )

        sysadmin_admins_address = addresser.make_sysadmin_admins_address(
            user_id=uuid4().hex)

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

        self.assertEqual(
            addresser.address_is(sysadmin_admins_address),
            AddressSpace.SYSADMIN_ADMINS,
            "The SysAdmin Admins address created must be found to "
            "be a SysAdmin Admins address.",
        )
コード例 #5
0
 def address(self, object_id, target_id=None):
     """Makes a blockchain address of this address type"""
     return legacy.make_sysadmin_owners_address(user_id=object_id)
コード例 #6
0
    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),
        )