|
@@ -148,25 +148,25 @@ class ProjectViewTest(ViewTest):
|
|
|
|
|
|
location, entities = response.context["location_entities"][1]
|
|
|
self.assertEqual(location.name, "Test Location 2")
|
|
|
self.assertQuerysetEqual(entities, ["<Entity: Test Entity 3 (Test Project 1 - Test Location 2)>",
|
|
|
"<Entity: Test Subnet (Test Project 1 - Test Location 2)>"])
|
|
|
|
|
|
self.assertEqual(str(response.context["project"]), "Test Project 1")
|
|
|
self.assertContains(response, "Test Project 1")
|
|
|
self.assertContains(response, "Test Location 1")
|
|
|
self.assertContains(response, "Test Location 2")
|
|
|
|
|
|
|
|
|
class EntityView(ViewTest):
|
|
|
class EntityViewTest(ViewTest):
|
|
|
|
|
|
def test_permission_denied(self):
|
|
|
"""
|
|
|
Tests if permission will be denied for client without sufficient privileges.
|
|
|
"""
|
|
|
|
|
|
self.client.login(username="noperms", password="noperms")
|
|
|
|
|
|
response = self.client.get(reverse("entity", args=(1,)))
|
|
|
|
|
|
self.assertContains(response, "You have insufficient privileges to access this resource. Please contact your local system administrator if you believe you should have been granted access.", status_code=403)
|
|
|
|
|
@@ -181,24 +181,37 @@ class EntityView(ViewTest):
|
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
def test_entity_show(self):
|
|
|
"""
|
|
|
Tests if the entity information is shown properly.
|
|
|
"""
|
|
|
|
|
|
self.client.login(username="fullperms", password="fullperms")
|
|
|
|
|
|
response = self.client.get(reverse("entity", args=(1,)))
|
|
|
|
|
|
expected_incoming_communications = ["<Communication: Test Entity 2 -> Test Entity 1 (TCP:22)>",
|
|
|
"<Communication: Test Entity 2 -> Test Entity 1 (ICMP:8)>",
|
|
|
"<Communication: Test Entity 3 -> Test Entity 1 (TCP:3306)>",
|
|
|
"<Communication: Test Subnet -> Test Entity 1 (TCP:22)>",]
|
|
|
|
|
|
expected_outgoing_communications = ["<Communication: Test Entity 1 -> Test Entity 2 (UDP:123)>",
|
|
|
"<Communication: Test Entity 1 -> Test Entity 3 (UDP:53)>"]
|
|
|
|
|
|
expected_interfaces = ["<Interface: Test Entity 1 (192.168.1.1)>"]
|
|
|
|
|
|
self.assertQuerysetEqual(response.context["interfaces"], expected_interfaces)
|
|
|
self.assertQuerysetEqual(response.context["incoming_communications"], expected_incoming_communications)
|
|
|
self.assertQuerysetEqual(response.context["outgoing_communications"], expected_outgoing_communications)
|
|
|
self.assertEqual(str(response.context["entity"]), "Test Entity 1 (Test Project 1 - Test Location 1)")
|
|
|
self.assertContains(response, "Test Entity 1")
|
|
|
self.assertContains(response, ":INPUT")
|
|
|
self.assertContains(response, ":OUTPUT")
|
|
|
self.assertContains(response, ":FORWARD")
|
|
|
|
|
|
|
|
|
class EntityIptablesTest(ViewTest):
|
|
|
|
|
|
def test_permission_denied(self):
|
|
|
"""
|
|
|
Tests if permission will be denied for client without sufficient privileges.
|