def test_upload_files_post_service_returns_400_bad_payload():
    # Prep a bad payload - without required parameters
    bad_payload = details.encode_multipart_formdata({
        "name": "FirstOne ",
        "size": "100"
    })
    # verify=False to disable certificate validation
    response = requests.post(details.url(baseUrl),
                             data=bad_payload,
                             headers=headers,
                             verify=False)
    assert response.status_code == 400
    headers2 = {"content-Type": details.encode_multipart_headers()}
    # use the post request method to share the file from user 1 to user 2
    response2 = requests.post(details.url(sharefile_baseUrl), data=payload2, headers=headers2, verify=False)
    return fileId
'''

baseUrl = 'https://ec2-35-154-146-139.ap-south-1.compute.amazonaws.com/sharebox/api/files?token='

fileId = "cdc99b28-7879-4dc9-86aa-961ffef55271"

# to be used in conjunction with the function commented above
# payload1 = details.encode_multipart_formdata({"fileId": get_file_and_share_file(), "isAccepted": "true"})

# prep the payload for accept share scenario
payload1 = details.encode_multipart_formdata({
    "fileId": fileId,
    "isAccepted": "true"
})
headers = {"content-Type": details.encode_multipart_headers()}


def test_files_put_service_returns_200_accept_share():
    # verify=False to disable certificate validation
    # calling the url_second() since the accept/decline would happen from user 2
    response = requests.put(details.url_second(baseUrl),
                            data=payload1,
                            headers=headers,
                            verify=False)
    assert response.status_code == 200


# to be used in conjunction with the function commented above
Ejemplo n.º 3
0
import requests
import details  # import details file with token and functions

# Delete any file from your account

baseUrl = 'https://ec2-35-154-146-139.ap-south-1.compute.amazonaws.com/sharebox/api/files?token='

payload = details.encode_multipart_formdata(
    {"fileId": "f993e16e-a4dc-4c85-99b2-8ae833ead042"})

headers = {"content-Type": details.encode_multipart_headers()}


def test_files_delete_service_returns_200():
    # verify=False to disable certificate validation
    response = requests.delete(details.url(baseUrl),
                               data=payload,
                               headers=headers,
                               verify=False)
    assert response.status_code == 200


def test_files_delete_service_returns_400_no_headers():
    # verify=False to disable certificate validation
    response = requests.delete(details.url(baseUrl),
                               data=payload,
                               verify=False)
    assert response.status_code == 400


def test_files_delete_service_returns_400_without_payload():
import requests
import details  # import details file with token and functions

# Upload any file into your account

baseUrl = "https://ec2-35-154-146-139.ap-south-1.compute.amazonaws.com/sharebox/api/upload?token="

payload = details.encode_multipart_formdata({
    "name": "FirstOne ",
    "size": "100",
    "hash": hash(details.boundary),
    "file": "sample1.txt"
})

headers = {"content-Type": details.encode_multipart_headers()}


def test_upload_files_post_service_returns_200():
    # verify=False to disable certificate validation
    response = requests.post(details.url(baseUrl),
                             data=payload,
                             headers=headers,
                             verify=False)
    assert response.status_code == 200


def test_upload_files_post_service_returns_400_no_payload():
    # verify=False to disable certificate validation
    response = requests.post(details.url(baseUrl),
                             headers=headers,
                             verify=False)
Ejemplo n.º 5
0
import requests
import details  # import details file with token and functions

# share files from one account to another account

baseUrl = 'https://ec2-35-154-146-139.ap-south-1.compute.amazonaws.com/sharebox/api/files?token='

payload = details.encode_multipart_formdata({"fileId": "f993e16e-a4dc-4c85-99b2-8ae833ead042", "shareTo": "*****@*****.**"})
headers = {"content-Type": details.encode_multipart_headers(), "Accept": "application/json" }


def test_files_share_service_returns_200():
    # verify=False to disable certificate validation
    response = requests.post(details.url(baseUrl), data=payload, headers=headers, verify=False)
    assert response.status_code == 200


def test_files_delete_service_returns_400_no_headers():
    # verify=False to disable certificate validation
    response = requests.delete(details.url(baseUrl), data=payload, verify=False)
    assert response.status_code == 400


def test_files_delete_service_returns_400_without_payload():
    # verify=False to disable certificate validation
    response = requests.delete(details.url(baseUrl), headers=headers, verify=False)
    assert response.status_code == 400


def test_files_delete_service_returns_401_no_token():
    # verify=False to disable certificate validation