Skip to content

Commit e46a8a7

Browse files
j7nw4rclaude
andcommitted
fix(auth): expose port and require PostgreSQL 15 for migrations
- Add expose_ports() implementation to Auth Image trait to expose port 9999 - Update integration tests to use PostgreSQL 15-alpine (migrations require PostgreSQL 12+ for GENERATED ALWAYS AS ... STORED columns syntax) - Import ImageExt trait for with_tag() method 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 847fa8a commit e46a8a7

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/auth.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ use std::borrow::Cow;
6666
use std::collections::BTreeMap;
6767

6868
use anyhow::{bail, Context};
69-
use testcontainers_modules::testcontainers::core::{ContainerState, ExecCommand, WaitFor};
69+
use testcontainers_modules::testcontainers::core::{
70+
ContainerPort, ContainerState, ExecCommand, WaitFor,
71+
};
7072
use testcontainers_modules::testcontainers::{Image, TestcontainersError};
7173
use tokio_postgres::NoTls;
7274

@@ -337,6 +339,11 @@ impl Image for Auth {
337339
vec![WaitFor::message_on_stderr("API started")]
338340
}
339341

342+
/// Returns the ports to expose from the container
343+
fn expose_ports(&self) -> &[ContainerPort] {
344+
&[ContainerPort::Tcp(AUTH_PORT)]
345+
}
346+
340347
/// Returns the environment variables to be passed to the container
341348
fn env_vars(
342349
&self,

tests/auth_integration.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use anyhow::Result;
77
use supabase_testcontainers_modules::{Auth, AUTH_PORT, DOCKER_INTERNAL_HOST, LOCAL_HOST};
88
use testcontainers::runners::AsyncRunner;
9-
use testcontainers::ContainerAsync;
9+
use testcontainers::{ContainerAsync, ImageExt};
1010
use testcontainers_modules::postgres::Postgres;
1111
use tokio_postgres::NoTls;
1212

@@ -28,7 +28,7 @@ pub struct AuthTestContext {
2828
/// Sets up PostgreSQL and Auth containers for integration testing.
2929
///
3030
/// This function:
31-
/// 1. Starts a PostgreSQL container with host authentication
31+
/// 1. Starts a PostgreSQL 15 container (required for Auth migrations)
3232
/// 2. Initializes the auth database schema
3333
/// 3. Starts the Auth container connected to PostgreSQL
3434
///
@@ -42,8 +42,8 @@ pub struct AuthTestContext {
4242
/// // Containers are automatically stopped when ctx goes out of scope
4343
/// ```
4444
pub async fn setup_auth_with_postgres() -> Result<AuthTestContext> {
45-
// Start PostgreSQL container
46-
let postgres = Postgres::default().start().await?;
45+
// Start PostgreSQL 15 container (Auth migrations require PostgreSQL 12+ for generated columns)
46+
let postgres = Postgres::default().with_tag("15-alpine").start().await?;
4747
let postgres_port = postgres.get_host_port_ipv4(POSTGRES_PORT).await?;
4848

4949
// Connection string for Auth container (uses docker internal host)
@@ -180,8 +180,8 @@ mod tests {
180180
/// Test that signup is rejected when disabled
181181
#[tokio::test]
182182
async fn test_signup_rejected_when_disabled() -> Result<()> {
183-
// Start PostgreSQL container
184-
let postgres = Postgres::default().start().await?;
183+
// Start PostgreSQL 15 container (Auth migrations require PostgreSQL 12+)
184+
let postgres = Postgres::default().with_tag("15-alpine").start().await?;
185185
let postgres_port = postgres.get_host_port_ipv4(POSTGRES_PORT).await?;
186186

187187
let auth_db_url = format!(

0 commit comments

Comments
 (0)