The Lawfare Academy

Lawfare Group → Knowledge Institute → Lawfare Academy

← CS 220 — Web Applications, SQL and Software Engineering

Weeks 12–14

Version control, tests and delivery

Learning objectives

  • Explain and trace the mechanisms in version control, tests and delivery.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

Version control records changes and their relationships. A commit should represent a coherent change that can be reviewed and explained. A branch provides an independent line of work; merging integrates histories and may require resolving semantic conflicts even when text merges automatically. Secrets do not belong in commits. Deleting a secret from the current file does not remove it from history or revoke it.

A delivery pipeline should test the exact revision it deploys. Unit tests isolate rules; integration tests exercise real boundaries; end-to-end tests exercise visitor behavior. A screenshot cannot show that server authorization works. Use fixtures with duplicate names, empty lists, large values and denied access. A migration should have a compatibility and recovery plan; rolling back application files may not reverse a destructive database change.

Operational readiness includes observability and recovery. Log enough to diagnose failures while minimizing sensitive content. Monitor errors and latency as well as uptime. Rehearse restoration rather than merely asserting that backups exist. A failed deployment should leave a clear route to a known working revision. Define acceptance through concrete user tasks: create an order, retrieve it as its owner, reject another account, recover from a failed request and continue using existing records.

Worked reasoning These unit tests check a rule in isolation. They do not prove that the deployed endpoint actually calls this function or that roles come from a trusted source. An integration test must verify those connections. If the endpoint accepts role from submitted JSON, the rule can be correct while the system remains vulnerable.

Extended teaching and laboratory

Unit tests can establish a function’s behavior while the deployed route never calls it. Integration tests cross the actual boundary: authentication, routing, validation, persistence and serialization. A useful negative test attempts an operation as the wrong user and verifies both the response and the absence of data changes.

Deployment includes schema evolution. An application rollback can fail if a migration removed a column the previous version still requires. Expand-and-contract changes keep old and new application versions compatible during transition. Backups and restoration tests answer a different question from whether a migration script exits successfully.

Worked problem Version 2 renames customer_name to display_name by deleting the old column immediately. Version 1 remains on one running worker. Explain the failure and a safer sequence.

Step-by-step reasoning 1. The old worker can still query customer_name and fail after the migration. Rolling back application code alone does not restore the column.

  1. First add display_name without removing customer_name. Backfill and use a documented compatibility period with synchronized writes or a clear authoritative field.
  1. Deploy code that reads the new field with the required transition fallback. Verify old/new behavior and data reconciliation.
  1. Remove the old field only after all consumers have migrated and rollback requirements are resolved. Test recovery on a disposable copy first.

Apply the idea

Version 2 renames customer_name to display_name by deleting the old column immediately. Version 1 remains on one running worker. Explain the failure and a safer sequence.

A unit authorization test passes, but the endpoint accepts role=admin from submitted JSON. Design the integration test that exposes it.

Read the worked reasoning

Authenticate as an ordinary customer, submit role=admin with a request targeting another customer’s order, and verify denial plus no database change. Then verify the permitted operation on the customer’s own order. The test must call the real route so a correct helper cannot conceal an untrusted role source.

Check understanding

Why are unit authorization tests insufficient alone?

  1. The endpoint might bypass the tested rule or supply untrusted identity data
    Feedback

    The complete boundary must also be exercised.

  2. Unit tests automatically exercise production routing
    Feedback

    Isolated function tests do not invoke every route.

  3. Passing tests remove the need for integration
    Feedback

    Each test level supplies different evidence.

Further reading

Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study CS50 Web Git and Testing, CI/CD. Build separate unit, integration and accessibility checks; rehearse a reversible deployment using fictional records.

My learning →