
3 changed files with 141 additions and 0 deletions
@ -0,0 +1,60 @@ |
|||
import requests |
|||
import json |
|||
|
|||
url_base = "http://localhost:56030" |
|||
|
|||
def test_auth_basic(): |
|||
body = {"Email": "a", "Password": "a"} |
|||
response = requests.post(url_base + "/api/Auth/login", json=body) |
|||
data = json.loads(response.text) |
|||
assert data["firstName"] == "Sajt" |
|||
assert data["lastName"] == "Osperec" |
|||
assert data["id"] == "asdfasdfadf" |
|||
|
|||
def test_auth_fail(): |
|||
body = {"Email": "b", "Password": "b"} |
|||
response = requests.post(url_base + "/api/Auth/login", json=body) |
|||
assert response.status_code == 401 |
|||
|
|||
def test_auth_register(): |
|||
body = {"Email": "b", "FirstName": "a", "LastName": "a", "Password": "a", "Role": 0} |
|||
response = requests.post(url_base + "/api/Auth/register", json=body) |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 0 |
|||
|
|||
def test_auth_register_bad_pass(): |
|||
body = {"Email": "b", "FirstName": "a", "LastName": "a", "Password": "1", "Role": 0} |
|||
response = requests.post(url_base + "/api/Auth/register", json=body) |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 1 |
|||
assert data["body"]["reason"] == "Password does not meet complexity requirements!" |
|||
|
|||
def test_auth_register_email_taken(): |
|||
body = {"Email": "a", "FirstName": "a", "LastName": "a", "Password": "a", "Role": 0} |
|||
response = requests.post(url_base + "/api/Auth/register", json=body) |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 1 |
|||
assert data["body"]["reason"] == "a is already registered!" |
|||
|
|||
def test_auth_child(): |
|||
body = {"SessionId": "id", "FirstName": "a", "LastName": "a", "BirthDate": "x", "SocSecNum": "2"} |
|||
response = requests.post(url_base + "/api/Auth/child", json=body) |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 0 |
|||
assert "childID" in data["body"] |
|||
|
|||
def test_auth_child_ssn_taken(): |
|||
body = {"SessionId": "id", "FirstName": "a", "LastName": "a", "BirthDate": "x", "SocSecNum": "111111111"} |
|||
response = requests.post(url_base + "/api/Auth/child", json=body) |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 1 |
|||
assert "SSN" in data["body"]["reason"] |
|||
|
|||
def test_auth_child_unauthorized(): |
|||
body = {"SessionId": "a", "FirstName": "a", "LastName": "a", "BirthDate": "x", "SocSecNum": "2"} |
|||
response = requests.post(url_base + "/api/Auth/child", json=body) |
|||
assert response.status_code == 401 |
|||
|
|||
body = {"Email": "a", "FirstName": "a", "LastName": "a", "Password": "1", "Role": 0} |
|||
response = requests.post(url_base + "/api/Auth/register", json=body) |
|||
print(response.text) |
@ -0,0 +1,50 @@ |
|||
import requests |
|||
import json |
|||
|
|||
url_base = "http://localhost:56030" |
|||
|
|||
def test_case_basic(): |
|||
case_id = "1f4g5" |
|||
body = {"SessionID": "a"} |
|||
response = requests.post(url_base + "/api/Case/"+case_id, json=body) |
|||
data = json.loads(response.text) |
|||
print(data) |
|||
assert data["id"] == case_id |
|||
|
|||
def test_case_unauthorized(): |
|||
case_id = "1f4g5" |
|||
body = {"SessionID": "b"} |
|||
response = requests.post(url_base + "/api/Case/"+case_id, json=body) |
|||
assert response.status_code == 401 |
|||
|
|||
def test_case_update(): |
|||
case_id = "5f6h4" |
|||
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "a"} |
|||
response = requests.put(url_base + "/api/Case/"+case_id+"/update", json=body) |
|||
assert response.status_code == 200 |
|||
|
|||
def test_case_update_unauthorized(): |
|||
case_id = "5f6h4" |
|||
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "b"} |
|||
response = requests.put(url_base + "/api/Case/"+case_id+"/update", json=body) |
|||
assert response.status_code == 401 |
|||
|
|||
def test_case_close(): |
|||
case_id = "5f6h4" |
|||
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "a"} |
|||
response = requests.put(url_base + "/api/Case/"+case_id+"/close", json=body) |
|||
assert response.status_code == 200 |
|||
|
|||
def test_case_close_unauthorized(): |
|||
case_id = "5f6h4" |
|||
body = {"CaseID": case_id, "UpdateMsg": "a", "SessionID": "b"} |
|||
response = requests.put(url_base + "/api/Case/"+case_id+"/close", json=body) |
|||
assert response.status_code == 401 |
|||
|
|||
def test_case_filter(): |
|||
parent_id = "34g5g53" |
|||
body = {"SessionID": "a", "Filters": {"ParentID": parent_id}} |
|||
response = requests.post(url_base + "/api/Case/filter", json=body) |
|||
data = json.loads(response.text) |
|||
for i in data["cases"]: |
|||
assert i["parentID"] == parent_id |
@ -0,0 +1,31 @@ |
|||
import requests |
|||
import json |
|||
|
|||
url_base = "http://localhost:56030" |
|||
|
|||
def test_doc_get(): |
|||
response = requests.get(url_base + "/api/Doc") |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 0 |
|||
for val in data["body"].values(): |
|||
assert "firstName" in val |
|||
|
|||
def test_doc_assistants(): |
|||
doc_id = "a23f" |
|||
response = requests.get(url_base + "/api/Doc/" + doc_id + "/assistants") |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 0 |
|||
for key, val in data["body"].items(): |
|||
assert key == "doctorID" or "firstName" in val |
|||
if key == "doctorID": |
|||
assert val == doc_id |
|||
|
|||
def test_doc_children(): |
|||
doc_id = "a23f" |
|||
response = requests.get(url_base + "/api/Doc/" + doc_id + "/children") |
|||
data = json.loads(response.text) |
|||
assert data["status"] == 0 |
|||
for key, val in data["body"].items(): |
|||
assert key == "doctorID" or "firstName" in val |
|||
if key == "doctorID": |
|||
assert val == doc_id |
Loading…
Reference in new issue