Use `config` module for `allowed_owner` setting COUCHDB-2585
Project: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/commit/861fade1 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/tree/861fade1 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/diff/861fade1 Branch: refs/heads/master Commit: 861fade15517e2edac4fc96ec3cc164083ca6ab7 Parents: 9c867e8 Author: ILYA Khlopotov <[email protected]> Authored: Wed Feb 18 07:48:16 2015 -0800 Committer: ILYA Khlopotov <[email protected]> Committed: Wed Feb 18 07:48:16 2015 -0800 ---------------------------------------------------------------------- src/global_changes_httpd.erl | 5 +++-- test/global_changes_hooks_tests.erl | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/861fade1/src/global_changes_httpd.erl ---------------------------------------------------------------------- diff --git a/src/global_changes_httpd.erl b/src/global_changes_httpd.erl index be6cfdc..00f87af 100644 --- a/src/global_changes_httpd.erl +++ b/src/global_changes_httpd.erl @@ -250,10 +250,11 @@ to_non_neg_int(Value) -> end. allowed_owner(Req) -> - case application:get_env(global_changes, allowed_owner) of + case config:get("global_changes", "allowed_owner", undefined) of undefined -> chttpd:verify_is_server_admin(Req), admin; - {ok, {M, F, A}} -> + SpecStr -> + {ok, {M, F, A}} = couch_util:parse_term(SpecStr), M:F(Req, A) end. http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/861fade1/test/global_changes_hooks_tests.erl ---------------------------------------------------------------------- diff --git a/test/global_changes_hooks_tests.erl b/test/global_changes_hooks_tests.erl index 3b6ccbc..5dd42e2 100644 --- a/test/global_changes_hooks_tests.erl +++ b/test/global_changes_hooks_tests.erl @@ -5,6 +5,8 @@ -export([allowed_owner/2]). +-define(t2l(V), lists:flatten(io_lib:format("~p", [V]))). + start() -> Ctx = test_util:start_couch([chttpd]), DbName = ?tempdb(), @@ -24,13 +26,13 @@ setup(default) -> get_host(); setup(A) -> Host = setup(default), - ok = application:set_env(global_changes, allowed_owner, - {?MODULE, allowed_owner, A}), + ok = config:set("global_changes", "allowed_owner", + ?t2l({?MODULE, allowed_owner, A}), false), Host. teardown(_) -> delete_admin("admin"), - application:unset_env(global_changes, allowed_owner), + config:delete("global_changes", "allowed_owner", false), ok. allowed_owner(Req, "throw") ->
