mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* added os:GetEnvironmentVariable to list all environs or get a single one * first version of restarting the core to test save/load added environment variable to filter tests * fixed string constructor (size_t instead of signed int) * added string_view constructor * splitted and extended restart tests * added docs * added pol.cfg setting to disallow environment variable access * Change environmental variable access rules Instead of defaulting to all values allowed, now defaults to none. May specify either `*` to allow all variables, or a comma-delimited list. * Address review changes - Use Clib lower instead of boost - const auto references - Separate tests for access and finding env vars * Update documentation * Apply suggestions from code review Co-authored-by: Kevin Eady <8634912+KevinEady@users.noreply.github.com> Co-authored-by: Fernando Rozenblit <rozenblit@gmail.com>
40 lines
1.1 KiB
Text
40 lines
1.1 KiB
Text
use os;
|
|
include "testutil";
|
|
|
|
program test_env()
|
|
return 1;
|
|
endprogram
|
|
|
|
exported function get_env()
|
|
var res:=GetEnvironmentVariable("POLCORE_TEST");
|
|
if (res != "1")
|
|
return ret_error("Environment variable not found got: "+res);
|
|
endif
|
|
return 1;
|
|
endfunction
|
|
|
|
exported function list_env()
|
|
var res:=GetEnvironmentVariable();
|
|
if (res["POLCORE_TEST"] != "1")
|
|
return ret_error("Environment variable not found got: "+res);
|
|
endif
|
|
return 1;
|
|
endfunction
|
|
|
|
exported function get_noaccess_env()
|
|
foreach env in ({"POLCORE_TEST_NOACCESS", "polcore_test_noaccess"})
|
|
var res:=GetEnvironmentVariable(env);
|
|
if (res.errortext != "Environment Variable access disallowed due to pol.cfg setting")
|
|
return ret_error("Environment variable was found when expected access error, got: "+res);
|
|
endif
|
|
endforeach
|
|
return 1;
|
|
endfunction
|
|
|
|
exported function get_notfound_env()
|
|
var res:=GetEnvironmentVariable("POLCORE_TEST_NOTFOUND");
|
|
if (res.errortext != "Environment variable not found")
|
|
return ret_error("Environment variable found when expected not found error, got: "+res);
|
|
endif
|
|
return 1;
|
|
endfunction
|