Skip to content

Commit

Permalink
Add config/parse tests for config/env partial options.
Browse files Browse the repository at this point in the history
Partial option matching is valid on the command line but should never be used in config files or environment options.
  • Loading branch information
dwsteele committed May 17, 2021
1 parent ae7f0af commit 384f247
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/src/module/config/parseTest.c
Expand Up @@ -1289,6 +1289,7 @@ testRun(void)

setenv("PGBACKRESTXXX_NOTHING", "xxx", true);
setenv("PGBACKREST_BOGUS", "xxx", true);
setenv("PGBACKREST_ONLIN", "xxx", true); // Option prefix matching not allowed in environment
setenv("PGBACKREST_NO_DELTA", "xxx", true);
setenv("PGBACKREST_RESET_REPO1_HOST", "", true);
setenv("PGBACKREST_TARGET", "xxx", true);
Expand Down Expand Up @@ -1316,6 +1317,7 @@ testRun(void)
"online=y\n"
"pg1-path=/not/path/to/db\n"
"backup-standby=y\n"
"backup-standb=y\n" // Option prefix matching not allowed in config files
"buffer-size=65536\n"
"protocol-timeout=3600\n"
CFGOPT_JOB_RETRY "=3\n"
Expand All @@ -1339,14 +1341,16 @@ testRun(void)
strZ(
strNew(
"P00 WARN: environment contains invalid option 'bogus'\n"
"P00 WARN: environment contains invalid option 'onlin'\n"
"P00 WARN: environment contains invalid negate option 'no-delta'\n"
"P00 WARN: environment contains invalid reset option 'reset-repo1-host'\n"
"P00 WARN: configuration file contains option 'recovery-option' invalid for section 'db:backup'\n"
"P00 WARN: configuration file contains invalid option 'bogus'\n"
"P00 WARN: configuration file contains negate option 'no-delta'\n"
"P00 WARN: configuration file contains reset option 'reset-delta'\n"
"P00 WARN: configuration file contains command-line only option 'online'\n"
"P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
"P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'\n"
"P00 WARN: configuration file contains invalid option 'backup-standb'")));

TEST_RESULT_STR_Z(jsonFromVar(varNewVarLst(cfgCommandJobRetry())), "[0,33000,33000]", " custom job retries");
TEST_RESULT_BOOL(cfgOptionIdxTest(cfgOptPgHost, 0), false, " pg1-host is not set (command line reset override)");
Expand Down Expand Up @@ -1420,6 +1424,7 @@ testRun(void)
TEST_ERROR(cfgOptionKeyToIdx(cfgOptPgPath, 4), AssertError, "key '4' is not valid for 'pg-path' option");

unsetenv("PGBACKREST_BOGUS");
unsetenv("PGBACKREST_ONLIN");
unsetenv("PGBACKREST_NO_DELTA");
unsetenv("PGBACKREST_RESET_REPO1_HOST");
unsetenv("PGBACKREST_TARGET");
Expand Down

0 comments on commit 384f247

Please sign in to comment.