Skip to content

Commit

Permalink
Adaptation of older versions of CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wumingzhilian committed Apr 10, 2024
1 parent 0d25d2a commit 093c81e
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 89 deletions.
18 changes: 0 additions & 18 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,6 @@ def example_import_dojo(admin_session):
def simple_award_dojo(admin_session):
return create_dojo_yml(open(TEST_DOJOS_LOCATION / "simple_award_dojo.yml").read(), session=admin_session)

@pytest.fixture(scope="session")
def no_practice_challenge_dojo(admin_session):
return create_dojo_yml(open(TEST_DOJOS_LOCATION / "no_practice_challenge.yml").read(), session=admin_session)

@pytest.fixture(scope="session")
def no_import_challenge_dojo(admin_session):
rid = create_dojo_yml(open(TEST_DOJOS_LOCATION / "no_import_challenge.yml").read(), session=admin_session)
make_dojo_official(rid, admin_session)
return rid

@pytest.fixture(scope="session")
def no_practice_dojo(admin_session):
return create_dojo_yml(open(TEST_DOJOS_LOCATION / "no_practice_dojo.yml").read(), session=admin_session)

@pytest.fixture(scope="session")
def lfs_dojo(admin_session):
return create_dojo_yml(open(TEST_DOJOS_LOCATION / "lfs_dojo.yml").read(), session=admin_session)

@pytest.fixture(scope="session")
def welcome_dojo(admin_session):
try:
Expand Down
10 changes: 0 additions & 10 deletions test/dojos/lfs_dojo.yml

This file was deleted.

12 changes: 0 additions & 12 deletions test/dojos/no_practice_challenge.yml

This file was deleted.

12 changes: 0 additions & 12 deletions test/dojos/no_practice_dojo.yml

This file was deleted.

35 changes: 0 additions & 35 deletions test/test_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,41 +132,6 @@ def test_dojo_completion(simple_award_dojo, completionist_user):
assert us["solves"] == 2
assert len(us["badges"]) == 1

@pytest.mark.dependency(depends=["test_join_dojo"])
def test_no_practice(no_practice_challenge_dojo, no_practice_dojo, random_user):
_, session = random_user
for dojo in [ no_practice_challenge_dojo, no_practice_dojo ]:
response = session.get(f"{PROTO}://{HOST}/dojo/{dojo}/join/")
assert response.status_code == 200
response = session.post(f"{PROTO}://{HOST}/pwncollege_api/v1/docker", json={
"dojo": dojo,
"module": "test",
"challenge": "test",
"practice": True
})
assert response.status_code == 200
assert not response.json()["success"]
assert "practice" in response.json()["error"]

@pytest.mark.dependency(depends=["test_join_dojo"])
def test_lfs(lfs_dojo, random_user):
uid, session = random_user
assert session.get(f"{PROTO}://{HOST}/dojo/{lfs_dojo}/join/").status_code == 200
start_challenge(lfs_dojo, "test", "test", session=session)
try:
workspace_run("[ -f '/challenge/dojo.txt' ]", user=uid)
except subprocess.CalledProcessError:
assert False, "LFS didn't create dojo.txt"

@pytest.mark.dependency(depends=["test_join_dojo"])
def test_no_import(no_import_challenge_dojo, admin_session):
try:
create_dojo_yml(open(TEST_DOJOS_LOCATION / "forbidden_import.yml").read(), session=admin_session)
except AssertionError as e:
assert "Import disallowed" in str(e)
else:
raise AssertionError("forbidden-import dojo creation should have failed, but it succeeded")

@pytest.mark.dependency(depends=["test_join_dojo"])
def test_prune_dojo_awards(simple_award_dojo, admin_session, completionist_user):
user_name, _ = completionist_user
Expand Down
4 changes: 2 additions & 2 deletions test/test_welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def desktop_terminal(wd, user_id):
# Expands the accordion entry of the challenge
def challenge_expand(wd, idx):
wd.refresh()
wd.find_element("id", f"challenges-header-button-{idx}").click()
wd.find_element("id", f"challenges-header-{idx}").click()
time.sleep(0.5)

def challenge_start(wd, idx, practice=False):
Expand All @@ -87,7 +87,7 @@ def challenge_submit(wd, idx, flag):
# Gets the accordion entry index
def challenge_idx(wd, name):
num_challenges = len(wd.find_elements("id", "challenge-start"))
idx = next(n for n in range(num_challenges) if wd.find_element("id", f"challenges-header-button-{n+1}").text.split("\n")[0] == name)
idx = next(n for n in range(num_challenges) if wd.find_element("id", f"challenges-header-{n+1}").text.split("\n")[0] == name)
return idx+1

def test_welcome_desktop(random_user_webdriver, welcome_dojo):
Expand Down

0 comments on commit 093c81e

Please sign in to comment.