WGU D385
Pytest & Security Unit Testing Workbook
48 Original, Executed & Passing Tests
Positive • Negative • Boundary • Exceptions • Authentication • Authorization • API • Regression •
Parameterized Testing
VERIFIED RUN: The complete included pytest suite was executed in a clean local run: 48 passed. The workbook
records expected results and uses the verified execution as the actual result for each case.
ALIGNMENT: Built as an original practice workbook for WGU D385 Software Security and Testing. The September
2026 catalog describes D385 as recognizing software vulnerabilities, planning interventions, and developing and
testing those interventions, with coverage of Web security, permissions and identity security, debugging, log-file
analysis, API security, encryption, and cryptography. This workbook concentrates on testing and verification skills
that support those areas.
IMPORTANT: This is an independent study and practice resource. It is not an official WGU assessment, rubric,
answer key, or guaranteed-pass submission. Pytest is used here as a practical testing framework; the catalog does
not prescribe Pytest specifically.
September 2026 Edition
Page 1
, WGU D385 - Pytest & Security Unit Testing Practice Workbook | 2026
Contents
1. 1. September 2026 D385 Alignment and Workbook Scope
2. 2. Testing Strategy: From Requirement to Evidence
3. 3. Practice Application Architecture
4. 4. Running Pytest and Reading Results
5. 5. Tests 1-5: Positive Behavior
6. 6. Tests 6-12: Negative and Invalid Input
7. 7. Tests 13-17: Boundary Conditions
8. 8. Tests 18-22: Exception Behavior
9. 9. Tests 23-29: Authentication
10. 10. Tests 30-34: Authorization
11. 11. Tests 35-39: API Response Contracts
12. 12. Tests 40-44: Security Regression Verification
13. 13. Tests 45-48: Parameterized Expected-vs-Actual Testing
14. 14. Complete 48-Test Results Matrix
15. 15. Full Practice Application Source Code
16. 16. Full Pytest Suite
17. 17. Independent Practice Challenges
18. 18. Answer Guide and Remediation Thinking
19. 19. Final Readiness Checklist and References
Page 2
, WGU D385 - Pytest & Security Unit Testing Practice Workbook | 2026
1. September 2026 D385 Alignment and Workbook Scope
The September 2026 WGU Institutional Catalog describes D385 - Software Security and Testing as a course that
prepares learners to recognize security vulnerabilities, plan interventions, and develop and test those
interventions. The catalog also names Web security, permissions and identity security, debugging, log-file
analysis, API security, encryption, and cryptography as course topics.
This workbook focuses on the “develop and test interventions” portion of that scope. Its mini-application
deliberately includes identity, authentication, authorization, API-like responses, input validation, password
handling, sessions, and security regression checks so that the tests demonstrate both ordinary correctness and
security-focused verification.
Scope boundary: The workbook does not claim to reproduce a WGU task. It uses original Python code and original
test cases to practice software security and testing skills in a way that is consistent with the published course
description.
Learning objectives
Distinguish positive, negative, boundary, exception, authentication, authorization, API contract, and
regression tests.
Write pytest assertions that compare expected and actual behavior clearly.
Use fixtures to isolate test state and reduce duplication.
Validate secure error behavior without leaking sensitive implementation details.
Prove that remediated vulnerabilities remain fixed through regression tests.
Use parameterization to increase coverage without repetitive test code.
Read a pytest execution summary and connect each passing test to a requirement or security control.
2. Testing Strategy: From Requirement to Evidence
A strong security test starts with a requirement, identifies the risk if the requirement fails, executes a controlled
action, and records evidence that the observed result matches the expected result. This workbook uses the
following cycle:
1. Define the behavior or control.
2. Choose a representative valid, invalid, or edge-case input.
3. Arrange isolated state.
4. Act by calling the function or API-like endpoint.
5. Assert the expected status, exception, field, or security property.
6. Interpret the result as evidence.
7. Retain the test as a regression guard after remediation.
Core test categories
Category Purpose
Positive tests Confirm that valid inputs and allowed actions work.
Negative tests Confirm that invalid inputs and prohibited actions fail safely.
Boundary tests Exercise values at, just below, or just above allowed limits.
Exception tests Verify that abnormal conditions produce controlled, meaningful
Page 3