summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Doane <jaydoane@apache.org>2021-06-10 11:48:55 -0700
committerJay Doane <jay.s.doane@gmail.com>2021-06-10 21:35:27 -0700
commit491b77d82317478c574526490502f750b82814db (patch)
tree235c43a5880af8e81cd597fa88ea62b1ae0cff2a
parentcc646dccb9011f204356855edf237743bd3441f6 (diff)
downloadcouchdb-491b77d82317478c574526490502f750b82814db.tar.gz
Improve robustness of chttpd_util_test
In their current form, some of these tests rely on configuration props set with specific values in rel/overlay/etc/default.ini, which makes them prone to breakage when those values change, or when tests run in non-default configuration. This change deletes all config settings in the relevant sections under test, and then adds those under test back explicitly.
-rw-r--r--src/chttpd/test/eunit/chttpd_util_test.erl18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/chttpd/test/eunit/chttpd_util_test.erl b/src/chttpd/test/eunit/chttpd_util_test.erl
index 24403b5cf..07c985368 100644
--- a/src/chttpd/test/eunit/chttpd_util_test.erl
+++ b/src/chttpd/test/eunit/chttpd_util_test.erl
@@ -18,6 +18,15 @@
setup() ->
+ ok = lists:foreach(fun(Section) ->
+ ok = config_delete_all_keys(Section)
+ end, ["httpd", "chttpd", "couch_httpd_auth", "chttpd_auth"]),
+
+ ok = config:set("httpd", "authentication_handlers",
+ "{couch_httpd_auth, cookie_authentication_handler}, "
+ "{couch_httpd_auth, default_authentication_handler}", _Persist = false),
+ ok = config:set("httpd", "backlog", "512", _Persist = false),
+ ok = config:set("chttpd", "require_valid_user", "false", _Persist = false),
ok = config:set("httpd", "both_exist", "get_in_httpd", _Persist = false),
ok = config:set("chttpd", "both_exist", "get_in_chttpd", _Persist = false),
ok = config:set("httpd", "httpd_only", "true", _Persist = false),
@@ -29,6 +38,9 @@ setup() ->
teardown(_) ->
+ ok = config:delete("httpd", "authentication_handlers", _Persist = false),
+ ok = config:delete("httpd", "backlog", _Persist = false),
+ ok = config:delete("chttpd", "require_valid_user", _Persist = false),
ok = config:delete("httpd", "both_exist", _Persist = false),
ok = config:delete("chttpd", "both_exist", _Persist = false),
ok = config:delete("httpd", "httpd_only", _Persist = false),
@@ -39,6 +51,12 @@ teardown(_) ->
ok = config:delete("chttpd_auth", "ca_only", _Persist = false).
+config_delete_all_keys(Section) ->
+ lists:foreach(fun({Key, _Val}) ->
+ ok = config:delete(Section, Key, _Persist = false)
+ end, config:get(Section)).
+
+
chttpd_util_config_test_() ->
{
"chttpd util config tests",