mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-03 08:34:13 +02:00
add test for credentials escaping
This commit is contained in:
parent
74b2091624
commit
ffc38e3ae1
2 changed files with 49 additions and 0 deletions
|
|
@ -562,3 +562,37 @@ fn test_parse_config_nested_array() {
|
|||
&config.database,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_postgres_escaped_credentials() {
|
||||
let config = config_from_file("tests/configs/postgres_escape.php");
|
||||
assert_debug_equal(
|
||||
&Database::Postgres {
|
||||
database: "nextcloud".to_string(),
|
||||
username: "reda:cted".to_string(),
|
||||
password: "reda@cted".to_string(),
|
||||
connect: DbConnect::Tcp {
|
||||
host: "1.2.3.4".to_string(),
|
||||
port: 5432,
|
||||
},
|
||||
ssl_options: SslOptions::Disabled,
|
||||
},
|
||||
&config.database,
|
||||
);
|
||||
assert_eq!(
|
||||
config.database.url(),
|
||||
"postgresql://reda%3Acted:reda%40cted@1.2.3.4/nextcloud?sslmode=disable"
|
||||
);
|
||||
|
||||
#[cfg(feature = "db-sqlx")]
|
||||
assert_debug_equal(
|
||||
PgConnectOptions::new()
|
||||
.host("1.2.3.4")
|
||||
.username("reda:cted")
|
||||
.password("reda@cted")
|
||||
.port(5432)
|
||||
.database("nextcloud")
|
||||
.ssl_mode(sqlx::postgres::PgSslMode::Disable),
|
||||
PgConnectOptions::from_str(&config.database.url()).unwrap(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
15
tests/configs/postgres_escape.php
Normal file
15
tests/configs/postgres_escape.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
$CONFIG = [
|
||||
'overwrite.cli.url' => 'https://cloud.example.com',
|
||||
'dbtype' => 'pgsql',
|
||||
'dbname' => 'nextcloud',
|
||||
'dbhost' => '1.2.3.4',
|
||||
'dbport' => '',
|
||||
'dbtableprefix' => 'oc_',
|
||||
'dbuser' => 'reda:cted',
|
||||
'dbpassword' => 'reda@cted',
|
||||
'redis' => [
|
||||
'host' => 'localhost'
|
||||
]
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue