aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test/java/market/guess
Commit message (Collapse)AuthorAgeFilesLines
* server: add username login and logout endpoints Kostya2026-10-093-37/+159
| | | | | | | | | | | | | | | | | | | | | | The spec asks for a login by unique name only, with no passwords or sign-up, and an error that lets the user try again if the name exists. Add POST /api/login (form field "username") and POST /api/logout. Sessions maps each name, ignoring case, to the one HTTP session holding it. A second session asking for a held name gets 409 NAME_TAKEN, and a blank name gets 400. When a session ends, by logout or by Tomcat timing it out after a client quits without logging out, an HttpSessionListener frees the name. The account itself (ledger, Market Maker roles) stays, and logging in with that name again resumes it rather than locking the user out for the life of the server. New accounts start with a zero balance and are funded through deposits. Json gives every endpoint the same response shape, with errors as {"error": CODE, "message": text} built from a failed Result. Tomcat setup for the tests moves into a shared TestServer helper, whose clients each keep their own cookie jar and so act as separate users.
* server: add Tomcat webapp module with shared engine and CORS Kostya2026-10-091-0/+97
Exercise 3 moves the market behind a Tomcat server that the desktop and browser clients share. Add a server module, registered in the build scripts, holding the pieces every later endpoint builds on: - ServerEngine wires one in-memory market (repositories, ledger, trading pipeline, v3 upload loader) and lives in the servlet context for the webapp's lifetime. Its catalog refuses path-based loading, so events can only arrive through uploaded streams and the server never reads or writes files. - EngineBootstrap builds that engine when the webapp deploys. - CorsFilter answers preflights and echoes the caller's Origin with Allow-Credentials, which the browser client needs to send its session cookie from another origin. With usernames as the only login, echoing any origin exposes nothing a page couldn't get by logging in itself. - /api/health reports that the engine is up. Vendor tomcat-juli 10.1.26 next to the other Tomcat jars. It ships in Tomcat's bin/ rather than lib/, and embedded Tomcat cannot start without it. A test deploys the module into embedded Tomcat, so annotation scanning, the health check and CORS are checked against a real container.