mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
feat: configure auth channel mismatch formats
This commit is contained in:
@@ -8,7 +8,7 @@ use tracing::{error, info, warn};
|
||||
|
||||
static MIGRATOR: Migrator = sqlx::migrate!("./migrations");
|
||||
static BASELINE_V2_SQL: &str = include_str!("../bootstrap/20260413020000_baseline_v2.sql");
|
||||
const BASELINE_V2_CUTOFF_VERSION: i64 = 20260428000000;
|
||||
const BASELINE_V2_CUTOFF_VERSION: i64 = 20260502000000;
|
||||
const MIGRATIONS_TABLE_EXISTS_SQL: &str =
|
||||
"SELECT to_regclass('public._sqlx_migrations') IS NOT NULL";
|
||||
const PUBLIC_BASE_TABLE_COUNT_SQL: &str = r#"
|
||||
@@ -665,6 +665,7 @@ SELECT EXISTS (
|
||||
20260423000000,
|
||||
20260424000000,
|
||||
20260428000000,
|
||||
20260502000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -732,7 +733,20 @@ SELECT EXISTS (
|
||||
.sql
|
||||
.contains("api_formats json DEFAULT '[]'::json NOT NULL"));
|
||||
assert!(BASELINE_V2_SQL.contains("api_formats json,"));
|
||||
assert!(BASELINE_V2_SQL.contains("concurrent_limit integer,"));
|
||||
assert!(BASELINE_V2_SQL.contains("allow_auth_channel_mismatch_formats json,"));
|
||||
assert!(!BASELINE_V2_SQL.contains("api_formats json DEFAULT '[]'::json NOT NULL"));
|
||||
|
||||
let auth_mismatch_migration = MIGRATOR
|
||||
.iter()
|
||||
.find(|migration| migration.version == 20260502000000)
|
||||
.expect("auth mismatch migration should be embedded");
|
||||
assert!(auth_mismatch_migration
|
||||
.sql
|
||||
.contains("allow_auth_channel_mismatch_formats = rebuilt.api_formats"));
|
||||
assert!(auth_mismatch_migration
|
||||
.sql
|
||||
.contains("pak.allow_auth_channel_mismatch_formats IS NULL"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1256,6 +1270,7 @@ ORDER BY id
|
||||
20260423000000,
|
||||
20260424000000,
|
||||
20260428000000,
|
||||
20260502000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ SELECT
|
||||
is_active,
|
||||
api_formats,
|
||||
auth_type_by_format,
|
||||
allow_auth_channel_mismatch_formats,
|
||||
api_key,
|
||||
auth_config,
|
||||
note,
|
||||
@@ -198,6 +199,7 @@ SELECT
|
||||
is_active,
|
||||
api_formats,
|
||||
auth_type_by_format,
|
||||
allow_auth_channel_mismatch_formats,
|
||||
api_key,
|
||||
auth_config,
|
||||
note,
|
||||
@@ -1234,7 +1236,8 @@ INSERT INTO provider_api_keys (
|
||||
circuit_breaker_by_format,
|
||||
is_active,
|
||||
created_at,
|
||||
updated_at
|
||||
updated_at,
|
||||
allow_auth_channel_mismatch_formats
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
@@ -1310,7 +1313,8 @@ INSERT INTO provider_api_keys (
|
||||
CASE
|
||||
WHEN $51::double precision IS NULL THEN NOW()
|
||||
ELSE TO_TIMESTAMP($51::double precision)
|
||||
END
|
||||
END,
|
||||
$52
|
||||
)
|
||||
"#,
|
||||
)
|
||||
@@ -1373,7 +1377,7 @@ INSERT INTO provider_api_keys (
|
||||
.bind(key.is_active)
|
||||
.bind(key.created_at_unix_ms.map(|value| value as f64))
|
||||
.bind(key.updated_at_unix_secs.map(|value| value as f64))
|
||||
.bind(key.expires_at_unix_secs.map(|value| value as f64))
|
||||
.bind(&key.allow_auth_channel_mismatch_formats)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_postgres_err()?;
|
||||
@@ -1723,6 +1727,7 @@ SET
|
||||
provider_id = $2,
|
||||
api_formats = $3,
|
||||
auth_type_by_format = $39,
|
||||
allow_auth_channel_mismatch_formats = $40,
|
||||
auth_type = $4,
|
||||
api_key = $5,
|
||||
auth_config = $6,
|
||||
@@ -1818,6 +1823,7 @@ WHERE id = $1
|
||||
.bind(key.updated_at_unix_secs.map(|value| value as f64))
|
||||
.bind(key.expires_at_unix_secs.map(|value| value as f64))
|
||||
.bind(&key.auth_type_by_format)
|
||||
.bind(&key.allow_auth_channel_mismatch_formats)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_postgres_err()?
|
||||
@@ -2479,6 +2485,8 @@ fn map_key_row(row: &PgRow) -> Result<StoredProviderCatalogKey, DataLayerError>
|
||||
);
|
||||
key.note = row.try_get("note").ok();
|
||||
key.auth_type_by_format = row.try_get("auth_type_by_format").ok();
|
||||
key.allow_auth_channel_mismatch_formats =
|
||||
row.try_get("allow_auth_channel_mismatch_formats").ok();
|
||||
key.internal_priority = row.try_get("internal_priority").unwrap_or(50);
|
||||
key.cache_ttl_minutes = row.try_get("cache_ttl_minutes").unwrap_or(5);
|
||||
key.max_probe_interval_minutes = row.try_get("max_probe_interval_minutes").unwrap_or(32);
|
||||
|
||||
Reference in New Issue
Block a user