Skip to content

Commit

Permalink
Add additional unit tests
Browse files Browse the repository at this point in the history
Fixes #709

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/OWASP-BLT/BLT/issues/709?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
DonnieBLT committed Oct 13, 2024
1 parent 06c8743 commit 6c1d275
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions website/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,43 @@ def test_get_userissues(self):
for n in range(0, count):
message = "Test is failed"
self.assertTrue(response.data["results"][n].is_hidden, message)

def test_post_bug(self):
url = "/api/v1/issues/"
data = {
"url": "http://example.com",
"description": "Test bug report",
"screenshot": None,
"label": "0",
"token": "test",
"type": "test",
}
response = self.client.post(url, data, format="multipart")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_user_signup(self):
url = "/auth/registration/"
data = {
"username": "newuser",
"password1": "NewPassword123!",
"password2": "NewPassword123!",
"email": "newuser@example.com",
}
response = self.client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_user_login(self):
user = get_user_model().objects.create_user(username="testuser", password="testpassword")
url = "/auth/login/"
data = {
"username": "testuser",
"password": "testpassword",
}
response = self.client.post(url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn("key", response.data)

def test_issue_page_loads(self):
url = "/issue/1/"
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)

0 comments on commit 6c1d275

Please sign in to comment.