Skip to content

Commit

Permalink
Added Authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
el-agua committed Nov 5, 2023
1 parent 0188ac3 commit 82d30bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/plan/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ def get(self, *args, **kwargs):
return response


@permission_classes([IsAuthenticated])
class AutomaticCourseScheduler(APIView):

schema = PcxAutoSchema(
Expand Down
19 changes: 19 additions & 0 deletions backend/tests/plan/test_solver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import reverse
from rest_framework.test import APIClient
Expand All @@ -10,6 +11,9 @@

class TestCourseSolver(TestCase):
def setUp(self):
self.u1 = User.objects.create_user(
username="bobthelittlekid", email="[email protected]", password="harvard"
)
self.s = ["CIS-1200", "CIS-1600", "MATH-1410", "OIDD-1010", "FNCE-1010", "WRIT-0760"]
self.cis1200, self.cis1200_1 = create_mock_data(
"CIS-1200-002", "2022C", start=1100, end=1200
Expand All @@ -33,7 +37,22 @@ def setUp(self):
self.cis1600_2.save()
self.client = APIClient()

def testNotLoggedIn(self):
response = self.client.post(
reverse("automatic-scheduler"),
json.dumps(
{
"courses": ["CIS-1200", "CIS-1600"],
"semester": "2022C",
"breaks": {"M": [], "T": [[10.59, 12.01]], "W": [], "R": [], "F": []},
}
),
content_type="application/json",
)
self.assertEqual(403, response.status_code)

def testScheduler(self):
self.client.login(username="bobthelittlekid", password="harvard")
response = self.client.post(
reverse("automatic-scheduler"),
json.dumps(
Expand Down

0 comments on commit 82d30bf

Please sign in to comment.