示例#1
0
 def test_address_random(self):
     task_id1 = addresser.task.unique_id()
     task_id2 = addresser.task.unique_id()
     task_address1 = addresser.task.address(object_id=task_id1)
     task_address2 = addresser.task.address(object_id=task_id2)
     self.assertIsAddress(task_address1)
     self.assertIsAddress(task_address2)
     self.assertNotEqual(task_address1, task_address2)
     self.assertEqual(addresser.address_is(task_address1),
                      addresser.AddressSpace.TASKS_ATTRIBUTES)
     self.assertEqual(addresser.address_is(task_address2),
                      addresser.AddressSpace.TASKS_ATTRIBUTES)
 def test_address_random(self):
     user_id1 = addresser.user.unique_id()
     user_id2 = addresser.user.unique_id()
     rel_address1 = addresser.sysadmin.member.address(object_id=user_id1)
     rel_address2 = addresser.sysadmin.member.address(object_id=user_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.SYSADMIN_MEMBERS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.SYSADMIN_MEMBERS)
示例#3
0
 def test_address_is(self):
     """Tests that address_is returns AddressSpace.USER if it is a user
     address, and None if it is of another address type"""
     user_address = addresser.user.address(addresser.user.unique_id())
     role_address = addresser.role.address(addresser.role.unique_id())
     self.assertEqual(addresser.address_is(user_address),
                      addresser.AddressSpace.USER)
     self.assertEqual(addresser.user.address_is(user_address),
                      addresser.AddressSpace.USER)
     self.assertIsNone(addresser.user.address_is(role_address))
     self.assertEqual(addresser.address_is(role_address),
                      addresser.AddressSpace.ROLES_ATTRIBUTES)
 def test_address_random(self):
     role_id1 = addresser.role.unique_id()
     role_id2 = addresser.role.unique_id()
     role_address1 = addresser.role.address(object_id=role_id1)
     role_address2 = addresser.role.address(object_id=role_id2)
     self.assertIsAddress(role_address1)
     self.assertIsAddress(role_address2)
     self.assertNotEqual(role_address1, role_address2)
     self.assertEqual(addresser.address_is(role_address1),
                      addresser.AddressSpace.ROLES_ATTRIBUTES)
     self.assertEqual(addresser.address_is(role_address2),
                      addresser.AddressSpace.ROLES_ATTRIBUTES)
示例#5
0
 def test_address_random(self):
     user_id1 = addresser.user.unique_id()
     user_id2 = addresser.user.unique_id()
     user_address1 = addresser.user.address(object_id=user_id1)
     user_address2 = addresser.user.address(object_id=user_id2)
     self.assertIsAddress(user_address1)
     self.assertIsAddress(user_address2)
     self.assertNotEqual(user_address1, user_address2)
     self.assertEqual(addresser.address_is(user_address1),
                      addresser.AddressSpace.USER)
     self.assertEqual(addresser.address_is(user_address2),
                      addresser.AddressSpace.USER)
示例#6
0
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     role_id1 = addresser.role.unique_id()
     role_id2 = addresser.role.unique_id()
     role_address1 = addresser.role.address(object_id=role_id1)
     role_address2 = addresser.role.address(object_id=role_id2)
     self.assertIsAddress(role_address1)
     self.assertIsAddress(role_address2)
     self.assertNotEqual(role_address1, role_address2)
     self.assertEqual(addresser.address_is(role_address1),
                      addresser.AddressSpace.ROLES_ATTRIBUTES)
     self.assertEqual(addresser.address_is(role_address2),
                      addresser.AddressSpace.ROLES_ATTRIBUTES)
示例#7
0
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     user_id1 = addresser.user.unique_id()
     user_id2 = addresser.user.unique_id()
     user_address1 = addresser.user.address(user_id1)
     user_address2 = addresser.user.address(user_id2)
     self.assertIsAddress(user_address1)
     self.assertIsAddress(user_address2)
     self.assertNotEqual(user_address1, user_address2)
     self.assertEqual(addresser.address_is(user_address1),
                      addresser.AddressSpace.USER)
     self.assertEqual(addresser.address_is(user_address2),
                      addresser.AddressSpace.USER)
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     task_id1 = addresser.task.unique_id()
     task_id2 = addresser.task.unique_id()
     task_address1 = addresser.task.address(object_id=task_id1)
     task_address2 = addresser.task.address(object_id=task_id2)
     self.assertIsAddress(task_address1)
     self.assertIsAddress(task_address2)
     self.assertNotEqual(task_address1, task_address2)
     self.assertEqual(addresser.address_is(task_address1),
                      addresser.AddressSpace.TASKS_ATTRIBUTES)
     self.assertEqual(addresser.address_is(task_address2),
                      addresser.AddressSpace.TASKS_ATTRIBUTES)
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     user_id1 = addresser.user.unique_id()
     user_id2 = addresser.user.unique_id()
     rel_address1 = addresser.sysadmin.owner.address(object_id=user_id1)
     rel_address2 = addresser.sysadmin.owner.address(object_id=user_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.SYSADMIN_OWNERS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.SYSADMIN_OWNERS)
示例#10
0
 def test_get_test_inputs(self):
     """Verifies the test data inputs function returns the expected test data"""
     message, message_type, inputs, outputs, signer = self.get_test_inputs()
     self.assertIsInstance(signer, Key)
     self.assertEqual(message_type, RBACPayload.CREATE_USER)
     self.assertIsInstance(message, user_transaction_pb2.CreateUser)
     self.assertIsInstance(message.name, str)
     self.assertIsInstance(inputs, list)
     self.assertIsInstance(outputs, list)
     self.assertEqual(len(inputs), 1)
     self.assertEqual(len(outputs), 1)
     self.assertEqual(addresser.address_is(inputs[0]), addresser.AddressSpace.USER)
     self.assertEqual(addresser.address_is(outputs[0]), addresser.AddressSpace.USER)
示例#11
0
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     user_id = addresser.user.unique_id()
     user_address = addresser.user.address(user_id)
     self.assertIsAddress(user_address)
     self.assertEqual(addresser.address_is(user_address),
                      addresser.AddressSpace.USER)
 def test_address_random(self):
     task_id1 = addresser.task.owner.unique_id()
     user_id1 = addresser.user.unique_id()
     task_id2 = addresser.task.owner.unique_id()
     user_id2 = addresser.user.unique_id()
     rel_address1 = addresser.task.owner.address(object_id=task_id1,
                                                 target_id=user_id1)
     rel_address2 = addresser.task.owner.address(object_id=task_id2,
                                                 target_id=user_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.TASKS_OWNERS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.TASKS_OWNERS)
def _update(database, block_num, address, resource):
    data_type = addresser.address_is(address)

    _update_state(database, block_num, address, resource)

    resource["start_block_num"] = block_num
    resource["end_block_num"] = str(sys.maxsize)

    if ADD_SUFFIX.get(data_type, False):
        resource["suffix"] = int(address[-2:], 16)

    try:
        table_query = database.get_table(TABLE_NAMES[data_type])
        update_filter = {k: resource[k] for k in FILTER_KEYS[data_type]}
    except KeyError:
        raise TypeError("Unknown data type: {}".format(data_type))

    update_filter["end_block_num"] = str(sys.maxsize)

    query = (
        table_query.filter(update_filter)
        .update({"end_block_num": block_num})
        .merge(table_query.insert(resource).without("replaced"))
    )

    return database.run_query(query)
示例#14
0
 def test_address_random(self):
     role_id1 = addresser.role.admin.unique_id()
     user_id1 = addresser.user.unique_id()
     role_id2 = addresser.role.admin.unique_id()
     user_id2 = addresser.user.unique_id()
     rel_address1 = addresser.role.admin.address(object_id=role_id1,
                                                 target_id=user_id1)
     rel_address2 = addresser.role.admin.address(object_id=role_id2,
                                                 target_id=user_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.ROLES_ADMINS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.ROLES_ADMINS)
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     task_id = addresser.task.unique_id()
     task_address = addresser.task.address(object_id=task_id)
     self.assertIsAddress(task_address)
     self.assertEqual(addresser.address_is(task_address),
                      addresser.AddressSpace.TASKS_ATTRIBUTES)
示例#16
0
 def test_address_random(self):
     object_id1 = addresser.proposal.unique_id()
     target_id1 = addresser.proposal.unique_id()
     object_id2 = addresser.proposal.unique_id()
     target_id2 = addresser.proposal.unique_id()
     proposal_address1 = addresser.proposal.address(object_id=object_id1,
                                                    target_id=target_id1)
     proposal_address2 = addresser.proposal.address(object_id=object_id2,
                                                    target_id=target_id2)
     self.assertIsAddress(proposal_address1)
     self.assertIsAddress(proposal_address2)
     self.assertNotEqual(proposal_address1, proposal_address2)
     self.assertEqual(addresser.address_is(proposal_address1),
                      addresser.AddressSpace.PROPOSALS)
     self.assertEqual(addresser.address_is(proposal_address2),
                      addresser.AddressSpace.PROPOSALS)
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     user_id = addresser.user.unique_id()
     rel_address = addresser.sysadmin.owner.address(object_id=user_id)
     self.assertIsAddress(rel_address)
     self.assertEqual(addresser.address_is(rel_address),
                      addresser.AddressSpace.SYSADMIN_OWNERS)
 def test_address_random(self):
     role_id1 = addresser.role.task.unique_id()
     task_id1 = addresser.task.unique_id()
     role_id2 = addresser.role.task.unique_id()
     task_id2 = addresser.task.unique_id()
     rel_address1 = addresser.role.task.address(object_id=role_id1,
                                                target_id=task_id1)
     rel_address2 = addresser.role.task.address(object_id=role_id2,
                                                target_id=task_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.ROLES_TASKS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.ROLES_TASKS)
示例#19
0
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     role_id = addresser.role.unique_id()
     role_address = addresser.role.address(object_id=role_id)
     self.assertIsAddress(role_address)
     self.assertEqual(addresser.address_is(role_address),
                      addresser.AddressSpace.ROLES_ATTRIBUTES)
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     sysadmin_address = addresser.sysadmin.address()
     self.assertIsAddress(sysadmin_address)
     self.assertEqual(
         addresser.address_is(sysadmin_address),
         addresser.AddressSpace.SYSADMIN_ATTRIBUTES,
     )
示例#21
0
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     object_id1 = addresser.proposal.unique_id()
     target_id1 = addresser.proposal.unique_id()
     object_id2 = addresser.proposal.unique_id()
     target_id2 = addresser.proposal.unique_id()
     proposal_address1 = addresser.proposal.address(object_id=object_id1,
                                                    target_id=target_id1)
     proposal_address2 = addresser.proposal.address(object_id=object_id2,
                                                    target_id=target_id2)
     self.assertIsAddress(proposal_address1)
     self.assertIsAddress(proposal_address2)
     self.assertNotEqual(proposal_address1, proposal_address2)
     self.assertEqual(addresser.address_is(proposal_address1),
                      addresser.AddressSpace.PROPOSALS)
     self.assertEqual(addresser.address_is(proposal_address2),
                      addresser.AddressSpace.PROPOSALS)
示例#22
0
 def test_address(self):
     role_id = addresser.role.admin.unique_id()
     user_id = addresser.user.unique_id()
     rel_address = addresser.role.admin.address(object_id=role_id,
                                                target_id=user_id)
     self.assertIsAddress(rel_address)
     self.assertEqual(addresser.address_is(rel_address),
                      addresser.AddressSpace.ROLES_ADMINS)
示例#23
0
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     task_id1 = addresser.task.owner.unique_id()
     user_id1 = addresser.user.unique_id()
     task_id2 = addresser.task.owner.unique_id()
     user_id2 = addresser.user.unique_id()
     rel_address1 = addresser.task.owner.address(object_id=task_id1,
                                                 related_id=user_id1)
     rel_address2 = addresser.task.owner.address(object_id=task_id2,
                                                 related_id=user_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.TASKS_OWNERS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.TASKS_OWNERS)
示例#24
0
 def test_address_random(self):
     """Tests address makes a unique address given different inputs"""
     role_id1 = addresser.role.member.unique_id()
     user_id1 = addresser.user.unique_id()
     role_id2 = addresser.role.member.unique_id()
     user_id2 = addresser.user.unique_id()
     rel_address1 = addresser.role.member.address(object_id=role_id1,
                                                  target_id=user_id1)
     rel_address2 = addresser.role.member.address(object_id=role_id2,
                                                  target_id=user_id2)
     self.assertIsAddress(rel_address1)
     self.assertIsAddress(rel_address2)
     self.assertNotEqual(rel_address1, rel_address2)
     self.assertEqual(addresser.address_is(rel_address1),
                      addresser.AddressSpace.ROLES_MEMBERS)
     self.assertEqual(addresser.address_is(rel_address2),
                      addresser.AddressSpace.ROLES_MEMBERS)
 def test_address(self):
     role_id = addresser.role.task.unique_id()
     task_id = addresser.task.unique_id()
     rel_address = addresser.role.task.address(object_id=role_id,
                                               target_id=task_id)
     self.assertIsAddress(rel_address)
     self.assertEqual(addresser.address_is(rel_address),
                      addresser.AddressSpace.ROLES_TASKS)
示例#26
0
 def test_address(self):
     object_id = addresser.proposal.unique_id()
     target_id = addresser.proposal.unique_id()
     proposal_address = addresser.proposal.address(object_id=object_id,
                                                   target_id=target_id)
     self.assertIsAddress(proposal_address)
     self.assertEqual(addresser.address_is(proposal_address),
                      addresser.AddressSpace.PROPOSALS)
 def test_address(self):
     task_id = addresser.task.owner.unique_id()
     user_id = addresser.user.unique_id()
     rel_address = addresser.task.owner.address(object_id=task_id,
                                                target_id=user_id)
     self.assertIsAddress(rel_address)
     self.assertEqual(addresser.address_is(rel_address),
                      addresser.AddressSpace.TASKS_OWNERS)
示例#28
0
 def test_address(self):
     sysadmin_id = addresser.sysadmin.unique_id()
     sysadmin_address = addresser.sysadmin.address()
     self.assertIsAddress(sysadmin_address)
     self.assertEqual(
         addresser.address_is(sysadmin_address),
         addresser.AddressSpace.SYSADMIN_ATTRIBUTES,
     )
示例#29
0
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     object_id = addresser.proposal.unique_id()
     target_id = addresser.proposal.unique_id()
     proposal_address = addresser.proposal.address(object_id=object_id,
                                                   target_id=target_id)
     self.assertIsAddress(proposal_address)
     self.assertEqual(addresser.address_is(proposal_address),
                      addresser.AddressSpace.PROPOSALS)
示例#30
0
 def test_address(self):
     """Tests address makes an address that identifies as the correct AddressSpace"""
     role_id = addresser.role.member.unique_id()
     user_id = addresser.user.unique_id()
     rel_address = addresser.role.member.address(object_id=role_id,
                                                 target_id=user_id)
     self.assertIsAddress(rel_address)
     self.assertEqual(addresser.address_is(rel_address),
                      addresser.AddressSpace.ROLES_MEMBERS)