Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub async fn migrate(tx: &mut AnyTransaction<'_>) -> laravel::Result<()> {
tx.schema()
.create("sessions", |table| {
table.string("id").primary();
table.big_integer("user_id").nullable().index();
// The signed-in user's pid: their auth id (`User::auth_id`)
table.uuid("user_id").nullable().index();
table.string("ip_address").length(45).nullable();
table.text("user_agent").nullable();
table.long_text("payload");
Expand Down
6 changes: 4 additions & 2 deletions app/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ pub fn configure() -> ApplicationBuilder {
("APP_DEBUG", "true"),
("BCRYPT_ROUNDS", "4"),
("BROADCAST_CONNECTION", "discard"),
("CACHE_STORE", "memory"),
("CACHE_STORE", "database"),
("FEATURE_STORE", "memory"),
("MAIL_MAILER", "log"),
("OTEL_SDK_DISABLED", "true"),
// Production queues on the database and runs jobs on its worker; tests run them inline
("QUEUE_CONNECTION", "sync"),
("SESSION_DRIVER", "memory"),
// Sessions and the cache in Postgres, as production keeps them
("SESSION_DRIVER", "database"),
("WORKFLOW_STORE", "memory"),
("DB_CONNECTION", "pgsql"),
// The test blob store: RustFS in CI, MinIO on a development machine, both on port 59000.
Expand Down
4 changes: 4 additions & 0 deletions app/tests/sign_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ async fn a_new_person_gets_an_account_and_returns_where_they_started(app: Applic
.assert_ok()
.assert_json_path("signed_in", true)
.assert_json_path("name", "Ada Lovelace");
// The session is a row in Postgres (SESSION_DRIVER=database, as in production), under the user's pid
let pid = user.pid;
let sessions: i64 = db::query!("SELECT count(*) FROM sessions WHERE user_id = {pid}").scalar().await?.unwrap_or(0);
assert_eq!(sessions, 1);

// Again: the same account, found by the GitHub ID
let again = app.get("/auth/github/callback").await;
Expand Down
Loading