mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: support api key ip restriction rules
This commit is contained in:
@@ -7,7 +7,7 @@ use tracing::info;
|
||||
// Generated by build.rs from schema/bootstrap/postgres.
|
||||
pub(crate) static EMPTY_DATABASE_SNAPSHOT_SQL: &str =
|
||||
include_str!(concat!(env!("OUT_DIR"), "/empty_database_snapshot.sql"));
|
||||
pub(crate) const EMPTY_DATABASE_SNAPSHOT_CUTOFF_VERSION: i64 = 20260519130000;
|
||||
pub(crate) const EMPTY_DATABASE_SNAPSHOT_CUTOFF_VERSION: i64 = 20260520000000;
|
||||
|
||||
const PUBLIC_BASE_TABLE_COUNT_SQL: &str = r#"
|
||||
SELECT COUNT(*)::BIGINT
|
||||
|
||||
@@ -307,10 +307,10 @@ fn empty_database_snapshot_covers_current_cutoff_versions() {
|
||||
20260515000000,
|
||||
20260516000000,
|
||||
20260518000000,
|
||||
20260518100000,
|
||||
20260519000000,
|
||||
20260519120000,
|
||||
20260519130000,
|
||||
20260520000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -471,31 +471,27 @@ fn management_tokens_json_columns_are_normalized_to_jsonb_in_postgres_schema_pat
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn api_key_allowed_ips_is_jsonb_in_postgres_schema_paths() {
|
||||
let api_key_allowed_ips_migration = POSTGRES_MIGRATOR
|
||||
fn api_key_ip_rules_is_jsonb_in_postgres_schema_paths() {
|
||||
let api_key_ip_rules_migration = POSTGRES_MIGRATOR
|
||||
.iter()
|
||||
.find(|migration| migration.version == 20260518100000)
|
||||
.expect("api key allowed IPs migration should be embedded");
|
||||
assert!(api_key_allowed_ips_migration
|
||||
.find(|migration| migration.version == 20260520000000)
|
||||
.expect("api key IP rules migration should be embedded");
|
||||
assert!(api_key_ip_rules_migration
|
||||
.sql
|
||||
.contains("ADD COLUMN IF NOT EXISTS allowed_ips jsonb NULL"));
|
||||
assert!(api_key_allowed_ips_migration
|
||||
.contains("ADD COLUMN IF NOT EXISTS ip_rules jsonb NULL"));
|
||||
assert!(api_key_ip_rules_migration
|
||||
.sql
|
||||
.contains("ALTER COLUMN allowed_ips TYPE jsonb USING allowed_ips::jsonb"));
|
||||
.contains("ALTER COLUMN ip_rules TYPE jsonb USING ip_rules::jsonb"));
|
||||
|
||||
assert!(EMPTY_DATABASE_SNAPSHOT_SQL.contains("allowed_ips jsonb,"));
|
||||
assert!(EMPTY_DATABASE_SNAPSHOT_SQL.contains("ip_rules jsonb,"));
|
||||
|
||||
let bootstrap_schema =
|
||||
include_str!("../../../schema/bootstrap/postgres/001_types_and_tables.sql");
|
||||
assert!(bootstrap_schema.contains("allowed_ips jsonb,"));
|
||||
|
||||
let driver_schema =
|
||||
include_str!("../../../schema/drivers/postgres/baseline/001_types_and_tables.sql");
|
||||
assert!(driver_schema.contains("allowed_ips jsonb,"));
|
||||
assert!(bootstrap_schema.contains("ip_rules jsonb,"));
|
||||
|
||||
let generated_identity =
|
||||
include_str!("../../../schema/generated/postgres/baseline/001_identity.sql");
|
||||
assert!(generated_identity.contains("allowed_ips jsonb,"));
|
||||
assert!(generated_identity.contains("ip_rules jsonb,"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -631,10 +627,10 @@ fn mysql_and_sqlite_migrations_include_enabled_incrementals() {
|
||||
20260512110000,
|
||||
20260516000000,
|
||||
20260518000000,
|
||||
20260518100000,
|
||||
20260519000000,
|
||||
20260519120000,
|
||||
20260519130000,
|
||||
20260520000000,
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -653,10 +649,10 @@ fn mysql_and_sqlite_migrations_include_enabled_incrementals() {
|
||||
20260512110000,
|
||||
20260516000000,
|
||||
20260518000000,
|
||||
20260518100000,
|
||||
20260519000000,
|
||||
20260519120000,
|
||||
20260519130000,
|
||||
20260520000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -1175,10 +1171,10 @@ fn pending_migrations_from_applied_skips_versions_already_applied() {
|
||||
20260515000000,
|
||||
20260516000000,
|
||||
20260518000000,
|
||||
20260518100000,
|
||||
20260519000000,
|
||||
20260519120000,
|
||||
20260519130000,
|
||||
20260520000000,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user