def test_contact(self): data = copy.deepcopy(TEST_DATADICT) data['private'] = False data['contact'][0]['email'] = '*****@*****.**' data['id'] = 'test-contact' data['name'] = 'test-contact' model.User(name="test_sysadmin", sysadmin=True).save() organisation = get_action('organization_create')({'user': '******'}, {'name': 'test-organization', 'title': "Test organization"}) data['owner_org'] = organisation.get('name') get_action('package_create')({'user': '******'}, data) offset = url_for("/contact/send/test-contact") res = self.app.post(offset, params={'recipient': utils.get_package_contacts(data.get('name'))[0].get('id')}) assert res.status == 302 offset = url_for("/dataset/test-contact") res = self.app.post(offset) assert 'Message not sent' in res import base64 import time cc = ContactController() _time = base64.b64encode(cc.crypto.encrypt(cc._pad(str(int(time.time()))))) offset = url_for("/contact/send/test-contact") params = { 'recipient': utils.get_package_contacts(data.get('name'))[0].get('id'), 'check_this_out': _time, 'accept_logging': 'True' } self.app.post(offset, params=params, status=302) offset = url_for("/dataset/test-contact") res = self.app.post(offset) assert 'spam bot' in res _time = base64.b64encode(cc.crypto.encrypt(cc._pad(str(int(time.time())-21)))) offset = url_for("/contact/send/test-contact") params = { 'recipient': utils.get_package_contacts(data.get('name'))[0].get('id'), 'check_this_out': _time, 'accept_logging': 'True' } self.app.post(offset, params=params, status=302) offset = url_for("/dataset/test-contact") res = self.app.post(offset) assert 'Message not sent' in res
def test_contact(self): data = copy.deepcopy(TEST_DATADICT) data['private'] = False data['contact'][0]['email'] = '*****@*****.**' model.User(name="test_sysadmin", sysadmin=True).save() organisation = get_action('organization_create')( { 'user': '******' }, { 'name': 'test-organization', 'title': "Test organization" }) data['owner_org'] = organisation.get('name') package = get_action('package_create')({'user': '******'}, data) name = package['name'] id = package['id'] package_contact_id = utils.get_package_contacts(id)[0].get('id') send_contact_offset = url_for("/contact/send/{0}".format(id)) res = self.app.post(send_contact_offset, params={'recipient': package_contact_id}) assert res.status == 302 dataset_offset = url_for("/dataset/{0}".format(name)) res = self.app.post(dataset_offset) assert 'Message not sent' in res import base64 import time cc = ContactController() _time = base64.b64encode( cc.crypto.encrypt(cc._pad(str(int(time.time()))))) params = {'recipient': package_contact_id, 'accept_logging': 'True'} self.app.post(send_contact_offset, params=params, status=302) res = self.app.post(dataset_offset) assert 'spam bot' in res _time = base64.b64encode( cc.crypto.encrypt(cc._pad(str(int(time.time()) - 21)))) params = {'recipient': package_contact_id, 'accept_logging': 'True'} self.app.post(send_contact_offset, params=params, status=302) offset = url_for("/dataset/{0}".format(name)) res = self.app.post(offset) assert 'Message not sent' in res
def test_pad(self): cc = ContactController() dummy_string = '0123456789abcdefghijklmno' for x in range(len(dummy_string)): assert len(cc._pad(dummy_string[:x])) == 8 + 8 * (x / 8)