def testcase_3(headers, body_content, domain):
    headers = headers.copy()
    body_content = body_content.copy()

    domain = ""

    concat_dict = body_content.copy()
    concat_dict['domain'] = domain
    concat_text = common_data.get_concat_text(concat_dict)

    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.get(url + path + domain,
                            params=body_content,
                            headers=headers)

    if response.status_code == 400:  #and response.json()['code'] == "400.0":
        print "TEST CASE 3 OK"
    else:
        print "TEST CASE 3 FAILED"
        print response.status_code
        print "HTTP Path: " + url + path + domain
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
def testcase_0(headers, body_content, old_domain, new_domain):
    body_content['new_domain'] = new_domain
    headers = headers.copy()
    body_content = body_content.copy()

    concat_dict = body_content.copy()
    concat_dict['domain'] = old_domain
    concat_text = common_data.get_concat_text(concat_dict)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.put(url + path + old_domain,
                            data=body_content,
                            headers=headers)

    if response.status_code == 200:
        print "TEST CASE 0 OK"
    else:
        print "TEST CASE 0 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
def testcase_8(headers, body_content, domain):
    headers = headers.copy()
    body_content = body_content.copy()

    domain = "INVALID_DOMAIN@"

    concat_dict = body_content.copy()
    concat_dict['domain'] = quote(domain)
    concat_text = common_data.get_concat_text(concat_dict)
    print concat_text
    concat_text = body_content['access_token'] + body_content[
        'certificate_serial'] + "INVALID_DOMAIN@"
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    print signed_signature
    headers['X-Signature'] = signed_signature

    print quote(domain)
    response = requests.get(url + path + quote(domain),
                            params=body_content,
                            headers=headers)

    if response.status_code == 400:  # and response.json()['code'] == "400.6":
        print "TEST CASE 8 OK"
    else:
        print "TEST CASE 8 FAILED"
        print response.status_code
        print "HTTP Path: " + url + path + domain
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #4
0
def testcase_3(headers, body_content, domain, key):
    headers = headers.copy()
    body_content = body_content.copy()

    domain = ""

    concat_dict = body_content.copy()
    concat_dict['domain'] = domain
    concat_dict['key'] = key
    concat_text = common_data.get_concat_text(concat_dict)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.get(url + path + domain + "/" + key, params=body_content, headers=headers)

    #response = requests.get(url + path + domain +"/" + key, params=body_content, headers=headers, allow_redirects=False)

    # TODO check error code
    if response.status_code == 400 and response.json()['code'] == "400.0":
        print "TEST CASE 3 OK"
    else:
        print "TEST CASE 3 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #5
0
def testcase_12(headers, body_content, domain, key):
    headers = headers.copy()
    body_content = body_content.copy()

    body_content['access_token'] = "INVALID_ACCESS_TOKEN"

    concat_dict = body_content.copy()
    concat_dict['domain'] = domain
    concat_dict['key'] = key
    concat_text = common_data.get_concat_text(concat_dict)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.get(url + path + domain + "/" + key, params=body_content, headers=headers)

    #response = requests.get(url + path + domain +"/" + key, params=body_content, headers=headers, allow_redirects=False)

    if response.status_code == 401 and response.json()['code'] == "401.0":
        print "TEST CASE 12 OK"
    else:
        print "TEST CASE 12 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
def testcase_1(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    headers.pop('Content-Type')

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature
    response = requests.post(url + path, data=body_content, headers=headers)

    if response.status_code == 400 and response.json()['code'] == "400.23":
        print "TEST CASE 1 OK!"
    else:
        print "TEST CASE 1 FAILED!"
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #7
0
def get_device_authentication_token():
    headers = dict()
    headers = init_headers(headers)

    body_content = dict()
    init_body_content(body_content)
    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature
    response = response = requests.post(url + path, data=body_content, headers=headers)
    if response.status_code == 200:
        resp_data = response.json()
        if 'data' in resp_data and 'access_token' and 'refresh_token' in resp_data['data']:
            return resp_data['data']
        else:
            return {"access_token": "", "refresh_token": ""}
    else:
        return {"access_token": "", "refresh_token": ""}
Exemple #8
0
def testcase_18(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    body_content['content'] = "INVALID_CONTENT"

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.post(url + path, data=body_content, headers=headers)

    if response.status_code == 400 and response.json()['code'] == "400.21":
        print "TEST CASE 18 OK"
    else:
        print "TEST CASE 18 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
def testcase_11(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    body_content['access_token'] = "INVALID_ACCESS_TOKEN"

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.post(url + path, data=body_content, headers=headers)

    if response.status_code == 400 and response.json()['code'] == "401.0":
        print "TEST CASE 11 OK!"
    else:
        print response.status_code
        print "TEST CASE 11 FAILED!"
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
def testcase_9(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    headers['X-Api-Key'] = "INVALID_X_API_KEY"

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.post(url + path, data=body_content, headers=headers)

    if response.status_code == 400:  # and response.json()['code'] == "400.1":
        print "TEST CASE 9 OK!"
    else:
        print response.status_code
        print "TEST CASE 9 FAILED!"
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #11
0
def testcase_2(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    headers.pop('X-Api-Key')

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.post(url + path, data=body_content, headers=headers)

    # TODO check error code
    if response.status_code == 400:
        print "TEST CASE 2 OK"
    else:
        print "TEST CASE 2 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #12
0
def testcase_16(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    body_content['key'] = "QQQQ$%#%$$"

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.post(url + path, data=body_content, headers=headers)

    # TODO check error code
    if response.status_code == 400 and response.json()['code'] == "400.14":
        print "TEST CASE 16 OK"
    else:
        print "TEST CASE 16 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #13
0
def testcase_10(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    headers['Content-Type'] = "INVALID_CONTENT_TYPE"
    #text/plain

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature

    response = requests.post(url + path, data=body_content, headers=headers)

    # TODO check error code
    if response.status_code == 400 and response.json()['code'] == "400.20":
        print "TEST CASE 10 OK"
    else:
        print "TEST CASE 10 FAILED"
        print response.status_code
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text
Exemple #14
0
def testcase_0(headers, body_content):
    headers = headers.copy()
    body_content = body_content.copy()

    concat_text = common_data.get_concat_text(body_content)
    signature = Signature()
    signature.load_key(common_data.certificate_serial)
    signed_signature = signature.sign(concat_text)
    headers['X-Signature'] = signed_signature
    response = requests.post(url + path, data=body_content, headers=headers)

    if response.status_code == 200 :
        resp_data = response.json()
        if 'data' in resp_data and 'access_token' and 'refresh_token' in resp_data['data']:
            print "TEST CASE 0 OK"
        else:
            print "TEST CASE 0 FAILED"
            print "HTTP Header:" + str(headers)
            print "HTTP Body:" + str(body_content)
    else:
        print "TEST CASE 0 FAILED"
        print "HTTP Header:" + str(headers)
        print "HTTP Body:" + str(body_content)
    print response.text