-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_block_attack.py
More file actions
39 lines (31 loc) · 1.18 KB
/
test_block_attack.py
File metadata and controls
39 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from unittest import TestCase
from unittest.mock import Mock
from hypernode_api_python.client import (
HYPERNODE_API_BLOCK_ATTACK_ENDPOINT,
HypernodeAPIPython,
)
class TestBlockAttack(TestCase):
def setUp(self):
self.client = HypernodeAPIPython(token="my_token")
self.mock_request = Mock()
self.client.requests = self.mock_request
self.app_name = "my_app"
def test_block_attack_endpoint_is_correct(self):
self.assertEqual(
"/v2/app/{}/block_attack/", HYPERNODE_API_BLOCK_ATTACK_ENDPOINT
)
def test_calls_block_attack_endpoint_correctly(self):
self.client.block_attack(self.app_name, "BlockSqliBruteForce")
self.mock_request.assert_called_once_with(
"POST",
f"/v2/app/{self.app_name}/block_attack/",
data={"attack_name": "BlockSqliBruteForce"},
)
def test_returns_block_attack_data(self):
response = Mock()
response.status_code = 202
self.mock_request.return_value = response
self.assertEqual(
self.client.block_attack(self.app_name, "BlockSqliBruteForce"),
self.mock_request.return_value,
)