Defensive Design & Testing
Admin; DROP TABLE Users;1ai: SQL Injection
1aii: Sanitisation removes/strips dangerous characters (like ; or ') (1) so the input is treated as text/string rather than a command (1).
1b: Validation: Checking data is sensible/reasonable/meets criteria (1).
Verification: Checking data matches the original source / is copied correctly (1).
| Test Type | Test Data | Reason for Test | Expected Outcome |
|---|---|---|---|
| Normal | 65 | To check that a typical passing score is accepted. | Output "Pass" |
| Boundary | 39 | (a) .................................................... | (b) ......................... |
| Boundary | (c) ........... | To check the lowest score required to Pass. | Output "Pass" |
| Erroneous | 101 | (d) .................................................... | (e) ......................... |
2: (a) To check the highest value that results in a Fail (1).
(b) Output "Fail" (1).
(c) 40 (1).
(d) To check that data outside the valid range (upper limit) is rejected (1).
(e) Error message displayed / Asks for input again (1).
3a: Line 05 (1).
Correction: elif len(pWord) < 8: (1)
3b: Line 07 (1).
Explanation: It returns True when the password is too short / it should return False (1).
4: attempts = 0
auth = False
while attempts < 3 and auth == False:
pwd = input("Enter password: ")
if pwd == "Secret123":
print("Access Granted")
auth = True
else: attempts = attempts + 1
if auth == False: print("Account Locked")
5a: 1. Indentation: Shows the structure/hierarchy of the code (2).
2. Meaningful Variable Names: Using attempts instead of x (2).
(Alternative: Subprograms/Modules).
5b: 1. Iterative Testing (1).
2. Final / Terminal Testing (1).
num1 and 0 for num2, the program crashes. State the name of this type of error.
6a: Runtime Error / Execution Error
6b: if num2 == 0:
print("Cannot divide by zero")
else: print(num1 / num2)