mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-03 08:34:13 +02:00
parse redis ssl_context
This commit is contained in:
parent
88db1d1d86
commit
e4bb72fd00
6 changed files with 220 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use nextcloud_config_parser::{
|
||||
parse, parse_glob, Config, Database, DbConnect, RedisConfig, RedisConnectionAddr,
|
||||
RedisConnectionInfo, SslOptions,
|
||||
RedisConnectionInfo, RedisTlsParams, SslOptions,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
|
@ -25,15 +25,9 @@ fn parse_redis(cfg: &str) -> RedisConnectionInfo {
|
|||
let redis = ConnectionInfo::from_str(cfg).unwrap();
|
||||
let addr = match redis.addr {
|
||||
ConnectionAddr::Tcp(host, port) => RedisConnectionAddr::Tcp { host, port },
|
||||
ConnectionAddr::TcpTls {
|
||||
ConnectionAddr::TcpTls { host, port, .. } => RedisConnectionAddr::TcpTls {
|
||||
host,
|
||||
port,
|
||||
insecure,
|
||||
..
|
||||
} => RedisConnectionAddr::TcpTls {
|
||||
host,
|
||||
port,
|
||||
insecure,
|
||||
tls_params: None,
|
||||
},
|
||||
ConnectionAddr::Unix(path) => RedisConnectionAddr::Unix { path },
|
||||
|
|
@ -109,6 +103,30 @@ fn test_parse_redis_socket() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_redis_tls() {
|
||||
let config = config_from_file("tests/configs/redis_tls.php");
|
||||
assert_debug_equal(
|
||||
RedisConfig::Single(RedisConnectionInfo {
|
||||
addr: RedisConnectionAddr::TcpTls {
|
||||
host: "127.0.0.1".into(),
|
||||
port: 6379,
|
||||
tls_params: Some(RedisTlsParams {
|
||||
local_cert: Some("/certs/redis.crt".into()),
|
||||
local_pk: Some("/certs/redis.key".into()),
|
||||
ca_file: Some("/certs/ca.crt".into()),
|
||||
insecure: false,
|
||||
accept_invalid_hostname: false,
|
||||
}),
|
||||
},
|
||||
db: 0,
|
||||
username: None,
|
||||
password: None,
|
||||
}),
|
||||
config.redis,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_comment_whitespace() {
|
||||
let config = config_from_file("tests/configs/comment_whitespace.php");
|
||||
|
|
|
|||
19
tests/configs/redis_tls.php
Normal file
19
tests/configs/redis_tls.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
$CONFIG = [
|
||||
'overwrite.cli.url' => 'https://cloud.example.com',
|
||||
'dbtype' => 'mysql',
|
||||
'dbname' => 'nextcloud',
|
||||
'dbhost' => 'localhost',
|
||||
'dbport' => '',
|
||||
'dbuser' => 'nextcloud',
|
||||
'dbpassword' => 'secret',
|
||||
'redis' => [
|
||||
'host' => 'localhost',
|
||||
'ssl_context' => [
|
||||
'local_cert' => '/certs/redis.crt',
|
||||
'local_pk' => '/certs/redis.key',
|
||||
'cafile' => '/certs/ca.crt'
|
||||
]
|
||||
]
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue