Unverified Commit 0cdd32ab authored by Peter Stanko's avatar Peter Stanko
Browse files

Using the teacher secret to authenticate

parent 47809d11
Loading
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -23,6 +23,15 @@ def teacher_credentials() -> str:
    })


@pytest.fixture
def teacher_secret() -> str:
    return json.dumps({
        "type": "secret",
        "identifier": "teacher1",
        "secret": "ultimate_teacher_secret"
    })


def test_project_detail_using_admin_cred(client):
    path = f'/courses/testcourse1'
    response = utils.make_request(client, path, 'get')
@@ -34,7 +43,6 @@ def test_project_detail_using_student_cred(client, student_credentials):
    path = f'/courses/testcourse1'
    response = utils.make_request(
        client, path, 'get', credentials=student_credentials)
    print(f"Response: {response.data}")
    assert response.status_code == 200
    assert response.mimetype == 'application/json'

@@ -43,6 +51,13 @@ def test_project_detail_using_teacher_cred(client, teacher_credentials):
    path = f'/courses/testcourse1/projects'
    response = utils.make_request(
        client, path, 'get', credentials=teacher_credentials)
    print(f"Response: {response.data}")
    assert response.status_code == 200
    assert response.mimetype == 'application/json'


def test_project_detail_using_teacher_secret(client, teacher_secret):
    path = f'/courses/testcourse1'
    response = utils.make_request(
        client, path, 'get', credentials=teacher_secret)
    assert response.status_code == 200
    assert response.mimetype == 'application/json'