示例#1
0
    def testMakingEncryptedContactAccept(self):
        INTRO = "You really shouldn't be able to read this because it should be encrypted and signed"
        RECPTKEYID = "3B898548F994C536"  # id of key2

        m = message.ContactResponseMessage(senderId=None,
                                           senderName=None,
                                           message=INTRO,
                                           senderKey=None)
        output = m.createOutput(RECPTKEYID)
        print("This should be encrypted:", output)
        # Check it's really encrypted by looking for the INTRO string
        for s in range(len(output) - len(INTRO)):
            x = ""
            try:
                x = output[s:s + len(INTRO)].decode("utf-8")
                print(x)
            except Exception:
                pass
            self.assertNotEqual(x, INTRO, "Message wasn't encrypted properly")
        # Test decryption
        bac = message.Message.MessageFromReceivedData(output)
        self.assertIsNone(bac, "shouldn't be able to decode the data")
        # Now we can cheat and add the private key2 to the keyring, then we should be able to decode it
        TestUtils.setupKeyring(["key2_private", "key1_public"])
        bac = message.Message.MessageFromReceivedData(output)
        self.assertIsNotNone(bac, "should be able to decode the data")
示例#2
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     self.FRIEND_TORID = "zo7quhgn1nq1uppt"
     FRIEND_KEYID = "3B898548F994C536"
     TestUtils.setupOwnProfile("46944E14D24D711B")  # id of key1
     DbI.updateProfile(
         self.FRIEND_TORID, {
             "status": "trusted",
             "keyid": FRIEND_KEYID,
             "name": "Norbert Jones",
             "displayName": "Uncle Norbert"
         })
     TestUtils.setupKeyring(["key1_private", "key2_public"])
示例#3
0
 def testMakeEncryptedRelayMessage(self):
     BODY = "Hey dude, have you got any €uros because I heard they were harsh to ünicode?  Oh, and &ampersands and <tags> too :)"
     SENDERID = TestUtils._ownTorId
     RECPTKEYID = "3B898548F994C536"  # keyid of eventual target of the message (key2)
     m = message.RegularMessage(sendTo=RECPTKEYID, messageBody=BODY)
     relaymsg = message.RelayingMessage(m.createOutput(RECPTKEYID))
     output = relaymsg.createOutput(recipientKeyId=None)
     bac = message.Message.MessageFromReceivedData(output, True)
     self.assertIsNotNone(bac, "couldn't decode the data")
     self.assertEqual(bac.encryptionType, message.Message.ENCTYPE_RELAY,
                      "Encryption type not right")
     self.assertIsNotNone(bac.payload, "Message should have a payload")
     self.assertEqual(bac.senderId, SENDERID, "Sender id not right")
     # Now fiddle with keys to let us decode it
     TestUtils.setupKeyring(["key2_private", "key1_public"])
     bac = message.Message.MessageFromReceivedData(output, True)
     self.assertIsNotNone(bac, "couldn't decode the data")
     self.assertEqual(bac.sendTo, RECPTKEYID, "Recipient not right")
     self.assertEqual(bac.messageBody, BODY, "Message not right")
示例#4
0
    def testMakingEncryptedContactAccept(self):
        INTRO = "You really shouldn't be able to read this because it should be encrypted and signed"
        RECPTKEYID = "3B898548F994C536"  # id of key2

        m = message.ContactResponseMessage(senderId=None, senderName=None, message=INTRO, senderKey=None)
        output = m.createOutput(RECPTKEYID)
        print("This should be encrypted:", output)
        # Check it's really encrypted by looking for the INTRO string
        for s in range(len(output) - len(INTRO)):
            x = ""
            try:
                x = output[s : s + len(INTRO)].decode("utf-8")
                print(x)
            except Exception:
                pass
            self.assertNotEqual(x, INTRO, "Message wasn't encrypted properly")
            # Test decryption
        bac = message.Message.MessageFromReceivedData(output)
        self.assertIsNone(bac, "shouldn't be able to decode the data")
        # Now we can cheat and add the private key2 to the keyring, then we should be able to decode it
        TestUtils.setupKeyring(["key2_private", "key1_public"])
        bac = message.Message.MessageFromReceivedData(output)
        self.assertIsNotNone(bac, "should be able to decode the data")
def main(args):

    parser = parse_args()
    args = parser.parse_args()
    utilsObj = TestUtils()
    marathon_url = args.marathon_url

    app_url_list = [
        marathon_url + '/v2/apps/internal-test-team/test-app/',
        marathon_url + '/v2/apps/db1/internal-test-team/test-app/',
        marathon_url + '/v2/apps/db2/internal-test-team/test-app/'
    ]

    json_data = utilsObj.create_json_data("/sample_data.json")
    headers = utilsObj.get_authorization_header()

    for app_url in app_url_list:
        print("\nExecuting Test for {} endpoint\n".format(app_url))
        utilsObj.test_proxy_user_valid_permissions_create(
            app_url, headers, json_data)
        utilsObj.test_proxy_user_valid_permissions_read(app_url, headers)
        utilsObj.test_proxy_user_valid_permissions_delete(
            app_url, headers, json_data)

    json_data = utilsObj.create_json_data("/sample_data.json")
    app_url = marathon_url + '/v2/apps/internal-test-team/'
    print("\nExecuting Test for Invalid End Point: {}\n".format(app_url))
    utilsObj.test_invalid_end_points(app_url, headers, json_data)

    print("\nExecuting POST Without Body:\n")
    app_url = marathon_url + '/logging'
    utilsObj.test_proxy_user_valid_permissions_create_no_body(app_url, headers)

    headers = utilsObj.get_authorization_header_non_json()
    json_data = "abc=xyz.com&level=OFF"
    print("\nExecuting POST With Non JSON Body:\n")
    app_url = marathon_url + '/logging'
    utilsObj.test_proxy_user_valid_permissions_create_non_json_body(
        app_url, headers, json_data)

    print("\nAll Tests Passed \n")
示例#6
0
 def setUp(self):
     Config.load()
     DbClient.useTestTables()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key2_public"])
     TestUtils.setupOwnProfile("46944E14D24D711B")  # id of key1
示例#7
0
def main(args):

    parser = parse_args()
    args = parser.parse_args()
    utilsObj = TestUtils()

    chronos_url = args.chronos_url
    chronos_common_access_url = [chronos_url,
                                 chronos_url + '/scheduler/jobs',
                                 chronos_url + '/scheduler/graph/csv']

    headers = utilsObj.get_authorization_header()

    for app_url in chronos_common_access_url:
        print ("\nExecuting Test for {} endpoint \n".format(app_url))
        utilsObj.test_proxy_user_valid_permissions_read(app_url, headers)

    time.sleep(10)

    json_data = utilsObj.create_json_data("/sample_chronos_data.json")

    app_url = chronos_url + '/scheduler/iso8601'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_valid_permissions_create(app_url, headers, json_data)

    time.sleep(10)

    json_data = utilsObj.create_json_data("/sample_dependency.json")
    app_url = chronos_url + '/scheduler/dependency'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_valid_permissions_create(app_url, headers, json_data)

    app_url = chronos_url + '/scheduler/job/internal-test-team-sample-chronos-job'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_valid_permissions_create(app_url, headers, json_data)

    app_url = chronos_url + '/scheduler/job/stat/internal-test-team-sample-chronos-job'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_valid_permissions_read(app_url, headers)

    app_url = chronos_url + '/scheduler/job/internal-test-team-sample-chronos-job'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_valid_permissions_delete(app_url, headers, json_data)

    app_url = chronos_url + '/scheduler/job/internal-test-team-dependency'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_valid_permissions_delete(app_url, headers, json_data)

    json_data = "notjson"
    app_url = chronos_url + '/scheduler/iso8601'
    print ("\nExecuting Test for Non JSON Body \n")
    utilsObj.test_proxy_user_invalid_body(app_url, headers, json_data)

    json_data = utilsObj.create_json_data("/sample_chronos_data.json")
    json_data['name'] = "test"  # Invalid Body
    app_url = chronos_url + '/scheduler/iso8601'
    print ("\nExecuting Test for {} endpoint \n".format(app_url))
    utilsObj.test_proxy_user_invalid_body(app_url, headers, json_data)
示例#8
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key2_public"])
示例#9
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key2_public"])
     TestUtils.setupOwnProfile("46944E14D24D711B")  # id of key1
示例#10
0
 def setUp(self):
     Config.load()
     CryptoClient.useTestKeyring()
     TestUtils.setupKeyring(["key1_private", "key1_public", "key2_public"])
     self.KEYID_1 = "46944E14D24D711B"
     self.KEYID_2 = "3B898548F994C536"
def main(args):

    parser = parse_args()
    args = parser.parse_args()
    utilsObj = TestUtils()
    marathon_url = args.marathon_url

    app_url_list = [
        marathon_url + "/v2/apps/internal-test-team/test-app/",
        marathon_url + "/v2/apps/db1/internal-test-team/test-app/",
        marathon_url + "/v2/apps/db2/internal-test-team/test-app/",
    ]

    json_data = utilsObj.create_json_data("/sample_data.json")
    headers = utilsObj.get_authorization_header()

    for app_url in app_url_list:
        print("\nExecuting Test for {} endpoint\n".format(app_url))
        utilsObj.test_proxy_user_valid_permissions_create(app_url, headers, json_data)
        utilsObj.test_proxy_user_valid_permissions_read(app_url, headers)
        utilsObj.test_proxy_user_valid_permissions_delete(app_url, headers, json_data)

    json_data = utilsObj.create_json_data("/sample_data.json")
    app_url = marathon_url + "/v2/apps/internal-test-team/"
    print("\nExecuting Test for Invalid End Point: {}\n".format(app_url))
    utilsObj.test_invalid_end_points(app_url, headers, json_data)

    print("\nExecuting POST Without Body:\n")
    app_url = marathon_url + "/logging"
    utilsObj.test_proxy_user_valid_permissions_create_no_body(app_url, headers)

    headers = utilsObj.get_authorization_header_non_json()
    json_data = "abc=xyz.com&level=OFF"
    print("\nExecuting POST With Non JSON Body:\n")
    app_url = marathon_url + "/logging"
    utilsObj.test_proxy_user_valid_permissions_create_non_json_body(app_url, headers, json_data)

    print("\nAll Tests Passed \n")