taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 0a6041484a65b7f27c66022dce6ea502540225e3
parent 39e10a48af5f26e1412a2e62a21405c1f26324fc
Author: Florian Dold <dold@taler.net>
Date:   Tue, 21 Jul 2026 20:01:09 +0200

util: test @inline-secret@ argument splitting

Diffstat:
Mpackages/taler-util/src/talerconfig.test.ts | 33+++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/packages/taler-util/src/talerconfig.test.ts b/packages/taler-util/src/talerconfig.test.ts @@ -323,3 +323,36 @@ test("the default config directory loads only .conf files", (t) => { } } }); + +test("@inline-secret@ tolerates aligned whitespace and paths with spaces", (t) => { + // The C skips whitespace before and after the section name and takes the + // rest of the line as the path, so aligned directives -- a common style for + // secrets -- and paths containing spaces both work. + const dir = nodejs_fs.mkdtempSync( + nodejs_path.join(nodejs_os.tmpdir(), "talerconfig-secret-"), + ); + nodejs_fs.writeFileSync( + nodejs_path.join(dir, "secret one.conf"), + "[SEC]\nKEY = from-secret\n", + ); + nodejs_fs.writeFileSync( + nodejs_path.join(dir, "main.conf"), + "[SEC]\nKEY = placeholder\n@inline-secret@ SEC secret one.conf\n", + ); + const config = Configuration.load(nodejs_path.join(dir, "main.conf")); + assert.strictEqual(config.getString("sec", "key").required(), "from-secret"); +}); + +test("@inline-secret@ still requires two arguments", (t) => { + const dir = nodejs_fs.mkdtempSync( + nodejs_path.join(nodejs_os.tmpdir(), "talerconfig-secret-"), + ); + nodejs_fs.writeFileSync( + nodejs_path.join(dir, "main.conf"), + "[SEC]\n@inline-secret@ SEC\n", + ); + assert.throws( + () => Configuration.load(nodejs_path.join(dir, "main.conf")), + /requires two arguments/, + ); +});