mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-10-01 08:14:06 +02:00
parent
cefb45de22
commit
2af3ee0742
3 changed files with 82 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ use nextcloud_config_parser::{
|
|||
parse, parse_glob, Config, Database, DbConnect, RedisClusterConnectionInfo, RedisConfig,
|
||||
RedisConnectionAddr, RedisConnectionInfo, RedisTlsParams, SslOptions,
|
||||
};
|
||||
use sqlx::postgres::PgSslMode;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use indexmap::{indexmap, IndexMap};
|
||||
|
|
@ -394,6 +395,47 @@ fn test_parse_postgres_socket_folder() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_postgres_ssl() {
|
||||
let config = config_from_file("tests/configs/postgres_ssl.php");
|
||||
assert_debug_equal(
|
||||
&Database::Postgres {
|
||||
database: "nextcloud".to_string(),
|
||||
username: "redacted".to_string(),
|
||||
password: "".to_string(),
|
||||
connect: DbConnect::Tcp {
|
||||
host: "1.2.3.4".into(),
|
||||
port: 5432,
|
||||
},
|
||||
options: indexmap! {
|
||||
"sslmode".into() => "require".into(),
|
||||
"sslcert".into() => "/cert.crt".into(),
|
||||
"sslrootcert".into() => "/root.crt".into(),
|
||||
"sslkey".into() => "/key.pem".into(),
|
||||
"sslcrl".into() => "/root.crl".into(),
|
||||
},
|
||||
},
|
||||
&config.database,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
config.database.url(),
|
||||
"postgresql://redacted:@1.2.3.4/nextcloud?sslmode=require&sslcert=/cert.crt&sslrootcert=/root.crt&sslkey=/key.pem&sslcrl=/root.crl"
|
||||
);
|
||||
assert_debug_equal(
|
||||
PgConnectOptions::new()
|
||||
.host("1.2.3.4")
|
||||
.port(5432)
|
||||
.username("redacted")
|
||||
.database("nextcloud")
|
||||
.ssl_mode(PgSslMode::Require)
|
||||
.ssl_client_cert("/cert.crt")
|
||||
.ssl_root_cert("/root.crt")
|
||||
.ssl_client_key("/key.pem"),
|
||||
PgConnectOptions::from_str(&config.database.url()).unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_redis_cluster() {
|
||||
let config = config_from_file("tests/configs/redis.cluster.php");
|
||||
|
|
@ -644,7 +686,7 @@ fn test_parse_postgres_ip() {
|
|||
.password("redacted")
|
||||
.database("nextcloud")
|
||||
.port(5432)
|
||||
.ssl_mode(sqlx::postgres::PgSslMode::Disable),
|
||||
.ssl_mode(PgSslMode::Disable),
|
||||
PgConnectOptions::from_str(&config.database.url()).unwrap(),
|
||||
);
|
||||
}
|
||||
|
|
@ -747,7 +789,7 @@ fn test_parse_postgres_escaped_credentials() {
|
|||
.password("reda@cted")
|
||||
.port(5432)
|
||||
.database("nextcloud")
|
||||
.ssl_mode(sqlx::postgres::PgSslMode::Disable),
|
||||
.ssl_mode(PgSslMode::Disable),
|
||||
PgConnectOptions::from_str(&config.database.url()).unwrap(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue