Terarea  2
The automation project
Loading...
Searching...
No Matches
test_injection_bind.py
Go to the documentation of this file.
1"""_summary_
2 File in charge of testing the boilerplate Boilerplate non http class.
3"""
4import os
5import sys
6from typing import List
7import constants as TCONST
8
9
10sys.path.append(os.getcwd())
11
12try:
13 from src.lib.sql.sql_injection import SQLInjection
14except ImportError as e:
15 raise ImportError("Failed to import the src module") from e
16
17DEBUG = TCONST.DEBUG
18ERROR = TCONST.ERROR
19SUCCESS = TCONST.SUCCESS
20
21SENTENCES = [
22 "SHOW TABLES;",
23 "SHOW Databases;",
24 "DROP TABLES;",
25 "SHOW DATABASE;",
26 "SELECT * FROM table;",
27]
28
30 error=ERROR,
31 success=SUCCESS,
32 debug=DEBUG
33)
34
35
36def _run_test(array: List[str], function: object, expected_response: bool = False) -> None:
37 """ Run a test and return it's status"""
38 for i in array:
39 response = function(i)
40 assert response == expected_response
41
42
44 """_summary_
45 Function in charge of testing the logic gate for sql injection.
46 """
48 array=SQLII.logic_gates,
49 function=SQLII.check_if_logic_gate_sql_injection,
50 expected_response=True
51 )
52
53
55 """_summary_
56 Function in charge of testing the command for sql injection.
57 """
59 array=SQLII.keywords,
60 function=SQLII.check_if_command_sql_injection,
61 expected_response=True
62 )
63
64
66 """_summary_
67 Function in charge of testing the symbol for sql injection.
68 """
70 array=SQLII.symbols,
71 function=SQLII.check_if_symbol_sql_injection,
72 expected_response=True
73 )
74
75
77 """_summary_
78 Function in charge of testing the list of all sql injections.
79 """
81 array=SQLII.all,
82 function=SQLII.check_if_sql_injection,
83 expected_response=True
84 )
85
86
88 """_summary_
89 Function in charge of testing the list of all sql injections in strings.
90 """
92 array=[SQLII.all],
93 function=SQLII.check_if_injections_in_strings,
94 expected_response=True
95 )
96
97
99 """_summary_
100 Function in charge of testing the list of all sql injections in strings.
101 """
102 _run_test(
103 array=[SQLII.all, SQLII.all],
104 function=SQLII.check_if_injections_in_strings,
105 expected_response=True
106 )
107
108
110 """_summary_
111 Function in charge of testing the list of a series of sentences
112 """
113 _run_test(
114 array=SENTENCES,
115 function=SQLII.check_if_sql_injection,
116 expected_response=True,
117 )
None _run_test(List[str] array, object function, bool expected_response=False)
None test_if_logic_gate_sql_injection_list_logic_gates()
None test_if_injections_in_strings_list_list_all()
None test_if_injections_in_strings_list_list_all_list_all()
None test_if_command_sql_injection_list_keywords()
None test_if_symbol_sql_injection_list_symbols()