mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-03 08:34:13 +02:00
add support for redis username
This commit is contained in:
parent
88b4abd252
commit
07af6dccd0
3 changed files with 11 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "nextcloud-config-parser"
|
||||
description = "Rust parser for nextcloud config files"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
|
|
|||
12
src/nc.rs
12
src/nc.rs
|
|
@ -337,13 +337,17 @@ fn parse_redis_options(parsed: &Value) -> RedisConfig {
|
|||
.as_str()
|
||||
.filter(|pass| !pass.is_empty())
|
||||
.map(String::from);
|
||||
let username = redis_options["user"]
|
||||
.as_str()
|
||||
.filter(|user| !user.is_empty())
|
||||
.map(String::from);
|
||||
|
||||
match address {
|
||||
RedisAddress::Single(addr) => RedisConfig::Single(ConnectionInfo {
|
||||
addr,
|
||||
redis: RedisConnectionInfo {
|
||||
db,
|
||||
username: None,
|
||||
username,
|
||||
password,
|
||||
},
|
||||
}),
|
||||
|
|
@ -354,7 +358,7 @@ fn parse_redis_options(parsed: &Value) -> RedisConfig {
|
|||
addr,
|
||||
redis: RedisConnectionInfo {
|
||||
db,
|
||||
username: None,
|
||||
username: username.clone(),
|
||||
password: password.clone(),
|
||||
},
|
||||
})
|
||||
|
|
@ -450,7 +454,9 @@ fn test_parse_empty_redis_password() {
|
|||
fn test_parse_full_redis() {
|
||||
let config = config_from_file("tests/configs/full_redis.php");
|
||||
assert_debug_equal(
|
||||
RedisConfig::Single(ConnectionInfo::from_str("redis://:moresecret@redis:1234/1").unwrap()),
|
||||
RedisConfig::Single(
|
||||
ConnectionInfo::from_str("redis://name:moresecret@redis:1234/1").unwrap(),
|
||||
),
|
||||
config.redis,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ $CONFIG = [
|
|||
'host' => 'redis',
|
||||
'dbindex' => 1,
|
||||
'port' => 1234,
|
||||
'user' => 'name',
|
||||
'password' => 'moresecret'
|
||||
]
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue