Skip to content

Commit

Permalink
check that secrets are omitted from list and detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
seanshahkarami committed Dec 15, 2023
1 parent e525e70 commit b40f92e
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions cmd/cloudscheduler/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ def wrap_tests():
yield


def get_jobs_list():
def get_job_list():
r = requests.get("http://localhost:9770/api/v1/jobs/list")
r.raise_for_status()
return r.json()


def get_job_detail(id):
r = requests.get(f"http://localhost:9770/api/v1/jobs/{id}/status")
r.raise_for_status()
return r.json()


def test_submit_requires_auth():
r = requests.post(f"http://localhost:9770/api/v1/submit")
assert r.status_code == HTTPStatus.UNAUTHORIZED
Expand Down Expand Up @@ -180,15 +186,20 @@ def test_submit_success():
# TODO(sean) Use ACCEPTED instead of OK?
assert r.status_code == HTTPStatus.OK

jobs = get_jobs_list()
job = get_job_detail(1)
assert job["name"] == "dbaserh"
assert job["user"] == "user"

jobs = get_job_list()

assert len(jobs) == 1
# NOTE(sean) jobs currently returns a map of stringy ints -> jobs
assert jobs["1"]["name"] == "dbaserh"
assert jobs["1"]["user"] == "user"
# TODO(sean) test more fields here!

# check that list output and detail output match
for id, job in jobs.items():
assert get_job_detail(id) == job

def test_submit_success_with_secrets():

def test_secrets_hidden_from_public():
headers = {
"Authorization": "Sage usertoken",
}
Expand Down Expand Up @@ -216,6 +227,10 @@ def test_submit_success_with_secrets():
# TODO(sean) Use ACCEPTED instead of OK?
assert r.status_code == HTTPStatus.OK

jobs = get_jobs_list()
# public list api should not include secrets!
assert "secrets" not in jobs["1"]
jobs = get_job_list()
assert len(jobs) > 0
for _, job in jobs.items():
assert "secrets" not in job

job = get_job_detail(1)
assert "secrets" not in job

0 comments on commit b40f92e

Please sign in to comment.