diff options
author | Jiahui Li <54631519+jiahuili430@users.noreply.github.com> | 2021-05-17 07:41:45 -0500 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2021-05-24 16:35:49 -0400 |
commit | 555b56857ecb0f056eb6085fb4624ac55ccbb416 (patch) | |
tree | cf5522086e8b0b96d0d889926fda8869edaabfcc | |
parent | 2b9680517d97feeae910d60af660b1afff898ba7 (diff) | |
download | couchdb-555b56857ecb0f056eb6085fb4624ac55ccbb416.tar.gz |
Moved some config options from httpd to chttpd
Solved conflicts from "cherry-pick" 3.x commit
-rw-r--r-- | rel/overlay/etc/default.ini | 41 | ||||
-rw-r--r-- | src/chttpd/src/chttpd.erl | 20 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_changes.erl | 5 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_cors.erl | 2 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_external.erl | 3 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_util.erl | 24 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_xframe_options.erl | 3 | ||||
-rw-r--r-- | src/chttpd/test/eunit/chttpd_util_test.erl | 107 | ||||
-rw-r--r-- | src/couch/src/couch_httpd.erl | 34 | ||||
-rw-r--r-- | src/couch/src/couch_httpd_vhost.erl | 4 | ||||
-rw-r--r-- | src/couch/test/eunit/couchdb_cors_tests.erl | 2 | ||||
-rw-r--r-- | src/couch/test/eunit/couchdb_mrview_cors_tests.erl | 2 | ||||
-rw-r--r-- | src/couch_replicator/test/eunit/couch_replicator_small_max_request_size_target.erl | 4 | ||||
-rw-r--r-- | test/elixir/test/config_test.exs | 32 | ||||
-rw-r--r-- | test/elixir/test/http_test.exs | 2 | ||||
-rw-r--r-- | test/elixir/test/jsonp_test.exs | 4 | ||||
-rw-r--r-- | test/elixir/test/rewrite_test.exs | 10 | ||||
-rw-r--r-- | test/javascript/tests/rewrite.js | 10 |
18 files changed, 229 insertions, 80 deletions
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini index 3d15eb48a..9aaaae87d 100644 --- a/rel/overlay/etc/default.ini +++ b/rel/overlay/etc/default.ini @@ -87,6 +87,26 @@ max_db_number_for_dbs_info_req = 100 ; prevent non-admins from accessing /_all_dbs ; admin_only_all_dbs = true +; These options are moved from [httpd] +;secure_rewrites = true +;allow_jsonp = false + +;enable_cors = false +;enable_xframe_options = false + +; CouchDB can optionally enforce a maximum uri length; +;max_uri_length = 8000 + +;changes_timeout = 60000 +;config_whitelist = +;rewrite_limit = 100 +;x_forwarded_host = X-Forwarded-Host +;x_forwarded_proto = X-Forwarded-Proto +;x_forwarded_ssl = X-Forwarded-Ssl + +; Maximum allowed http request size. Applies to both clustered and local port. +;max_http_request_size = 4294967296 ; 4GB + ;[jwt_auth] ; List of claims to validate ; can be the name of a claim like "exp" or a tuple if the claim requires @@ -113,26 +133,17 @@ max_db_number_for_dbs_info_req = 100 port = {{backend_port}} bind_address = 127.0.0.1 authentication_handlers = {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler} -secure_rewrites = true -allow_jsonp = false + ; Options for the MochiWeb HTTP server. ;server_options = [{backlog, 128}, {acceptor_pool_size, 16}] ; For more socket options, consult Erlang's module 'inet' man page. ;socket_options = [{recbuf, undefined}, {sndbuf, 262144}, {nodelay, true}] socket_options = [{sndbuf, 262144}] -enable_cors = false -enable_xframe_options = false -; CouchDB can optionally enforce a maximum uri length; -; max_uri_length = 8000 -; changes_timeout = 60000 -; config_whitelist = -; max_uri_length = -; rewrite_limit = 100 -; x_forwarded_host = X-Forwarded-Host -; x_forwarded_proto = X-Forwarded-Proto -; x_forwarded_ssl = X-Forwarded-Ssl -; Maximum allowed http request size. Applies to both clustered and local port. -max_http_request_size = 4294967296 ; 4GB + +; These settings were moved to [chttpd] +; secure_rewrites, allow_jsonp, enable_cors, enable_xframe_options, +; max_uri_length, changes_timeout, config_whitelist, rewrite_limit, +; x_forwarded_host, x_forwarded_proto, x_forwarded_ssl, max_http_request_size [ssl] port = 6984 diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl index 53fdf989a..3c637f6b1 100644 --- a/src/chttpd/src/chttpd.erl +++ b/src/chttpd/src/chttpd.erl @@ -467,7 +467,8 @@ possibly_hack(Req) -> Req. check_request_uri_length(Uri) -> - check_request_uri_length(Uri, config:get("httpd", "max_uri_length")). + check_request_uri_length(Uri, + chttpd_util:get_chttpd_config("max_uri_length")). check_request_uri_length(_Uri, undefined) -> ok; @@ -637,7 +638,8 @@ path(#httpd{mochi_req=MochiReq}) -> MochiReq:get(path). absolute_uri(#httpd{mochi_req=MochiReq, absolute_uri = undefined}, Path) -> - XHost = config:get("httpd", "x_forwarded_host", "X-Forwarded-Host"), + XHost = chttpd_util:get_chttpd_config( + "x_forwarded_host", "X-Forwarded-Host"), Host = case MochiReq:get_header_value(XHost) of undefined -> case MochiReq:get_header_value("Host") of @@ -652,12 +654,12 @@ absolute_uri(#httpd{mochi_req=MochiReq, absolute_uri = undefined}, Path) -> end; Value -> Value end, - XSsl = config:get("httpd", "x_forwarded_ssl", "X-Forwarded-Ssl"), + XSsl = chttpd_util:get_chttpd_config("x_forwarded_ssl", "X-Forwarded-Ssl"), Scheme = case MochiReq:get_header_value(XSsl) of "on" -> "https"; _ -> - XProto = config:get("httpd", "x_forwarded_proto", - "X-Forwarded-Proto"), + XProto = chttpd_util:get_chttpd_config( + "x_forwarded_proto", "X-Forwarded-Proto"), case MochiReq:get_header_value(XProto) of % Restrict to "https" and "http" schemes only "https" -> "https"; @@ -699,8 +701,8 @@ body(#httpd{mochi_req=MochiReq, req_body=ReqBody}) -> case ReqBody of undefined -> % Maximum size of document PUT request body (4GB) - MaxSize = config:get_integer("httpd", "max_http_request_size", - 4294967296), + MaxSize = chttpd_util:get_chttpd_config_integer( + "max_http_request_size", 4294967296), Begin = os:timestamp(), try MochiReq:recv_body(MaxSize) @@ -1103,7 +1105,7 @@ error_headers(#httpd{mochi_req=MochiReq}=Req, 401=Code, ErrorStr, ReasonStr) -> % this is where the basic auth popup is triggered case MochiReq:get_header_value("X-CouchDB-WWW-Authenticate") of undefined -> - case config:get("httpd", "WWW-Authenticate", undefined) of + case chttpd_util:get_chttpd_config("WWW-Authenticate") of undefined -> % If the client is a browser and the basic auth popup isn't turned on % redirect to the session page. @@ -1312,7 +1314,7 @@ stack_hash(Stack) -> %% this value to 0 to restore the older behavior of sending each row in a %% dedicated chunk. chunked_response_buffer_size() -> - config:get_integer("httpd", "chunked_response_buffer", 1490). + chttpd_util:get_chttpd_config_integer("chunked_response_buffer", 1490). basic_headers(Req, Headers0) -> Headers = Headers0 diff --git a/src/chttpd/src/chttpd_changes.erl b/src/chttpd/src/chttpd_changes.erl index 79ca4d1b8..29ead3d39 100644 --- a/src/chttpd/src/chttpd_changes.erl +++ b/src/chttpd/src/chttpd_changes.erl @@ -373,9 +373,8 @@ get_changes_timeout(Args, Callback) -> timeout = Timeout, feed = ResponseType } = Args, - DefaultTimeout = list_to_integer( - config:get("httpd", "changes_timeout", "60000") - ), + DefaultTimeout = chttpd_util:get_chttpd_config_integer( + "changes_timeout", 60000), case Heartbeat of undefined -> case Timeout of diff --git a/src/chttpd/src/chttpd_cors.erl b/src/chttpd/src/chttpd_cors.erl index ba1323387..a2cf16720 100644 --- a/src/chttpd/src/chttpd_cors.erl +++ b/src/chttpd/src/chttpd_cors.erl @@ -287,7 +287,7 @@ allow_credentials(Config, Origin) -> get_cors_config(#httpd{cors_config = undefined, mochi_req = MochiReq}) -> Host = couch_httpd_vhost:host(MochiReq), - EnableCors = config:get("httpd", "enable_cors", "false") =:= "true", + EnableCors = chttpd_util:get_chttpd_config_boolean("enable_cors", false), AllowCredentials = cors_config(Host, "credentials", "false") =:= "true", AllowHeaders = case cors_config(Host, "headers", undefined) of diff --git a/src/chttpd/src/chttpd_external.erl b/src/chttpd/src/chttpd_external.erl index 7317b7e4b..c0a2a9fe0 100644 --- a/src/chttpd/src/chttpd_external.erl +++ b/src/chttpd/src/chttpd_external.erl @@ -59,7 +59,8 @@ json_req_obj_field(<<"headers">>, #httpd{mochi_req=Req}, _Db, _DocId) -> Hlist = mochiweb_headers:to_list(Headers), to_json_terms(Hlist); json_req_obj_field(<<"body">>, #httpd{req_body=undefined, mochi_req=Req}, _Db, _DocId) -> - MaxSize = config:get_integer("httpd", "max_http_request_size", 4294967296), + MaxSize = chttpd_util:get_chttpd_config_integer( + "max_http_request_size", 4294967296), try Req:recv_body(MaxSize) catch exit:normal -> diff --git a/src/chttpd/src/chttpd_util.erl b/src/chttpd/src/chttpd_util.erl index fcaa09de0..23dba7dde 100644 --- a/src/chttpd/src/chttpd_util.erl +++ b/src/chttpd/src/chttpd_util.erl @@ -14,7 +14,11 @@ -export([ - parse_copy_destination_header/1 + parse_copy_destination_header/1, + get_chttpd_config/1, + get_chttpd_config/2, + get_chttpd_config_integer/2, + get_chttpd_config_boolean/2 ]). @@ -39,3 +43,21 @@ parse_copy_destination_header(Req) -> end end end. + + +get_chttpd_config(Key) -> + config:get("chttpd", Key, config:get("httpd", Key)). + + +get_chttpd_config(Key, Default) -> + config:get("chttpd", Key, config:get("httpd", Key, Default)). + + +get_chttpd_config_integer(Key, Default) -> + config:get_integer("chttpd", Key, + config:get_integer("httpd", Key, Default)). + + +get_chttpd_config_boolean(Key, Default) -> + config:get_boolean("chttpd", Key, + config:get_boolean("httpd", Key, Default)). diff --git a/src/chttpd/src/chttpd_xframe_options.erl b/src/chttpd/src/chttpd_xframe_options.erl index 9d3a554cc..2a43617fa 100644 --- a/src/chttpd/src/chttpd_xframe_options.erl +++ b/src/chttpd/src/chttpd_xframe_options.erl @@ -71,7 +71,8 @@ check_host(#httpd{mochi_req = MochiReq} = Req, Config) -> get_xframe_config(#httpd{xframe_config = undefined}) -> - EnableXFrame = config:get("httpd", "enable_xframe_options", "false") =:= "true", + EnableXFrame = chttpd_util:get_chttpd_config_boolean( + "enable_xframe_options", false), SameOrigin = config:get("x_frame_options", "same_origin", "false") =:= "true", AcceptedHosts = case config:get("x_frame_options", "hosts") of undefined -> []; diff --git a/src/chttpd/test/eunit/chttpd_util_test.erl b/src/chttpd/test/eunit/chttpd_util_test.erl new file mode 100644 index 000000000..fec05c830 --- /dev/null +++ b/src/chttpd/test/eunit/chttpd_util_test.erl @@ -0,0 +1,107 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +-module(chttpd_util_test). + + +-include_lib("couch/include/couch_eunit.hrl"). +-include("chttpd_test.hrl"). + + +setup() -> + 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), + ok = config:set("chttpd", "chttpd_only", "1", _Persist = false). + + +teardown(_) -> + ok = config:delete("httpd", "both_exist", _Persist = false), + ok = config:delete("chttpd", "both_exist", _Persist = false), + ok = config:delete("httpd", "httpd_only", _Persist = false), + ok = config:delete("chttpd", "chttpd_only", _Persist = false). + + +chttpd_util_config_test_() -> + { + "chttpd util config tests", + { + setup, + fun test_util:start_couch/0, + fun test_util:stop_couch/1, + { + foreach, + fun setup/0, + fun teardown/1, + [ + ?TDEF_FE(test_behavior), + ?TDEF_FE(test_with_undefined_option), + ?TDEF_FE(test_with_httpd_option), + ?TDEF_FE(test_with_chttpd_option), + ?TDEF_FE(test_with_chttpd_option_which_moved_from_httpd), + ?TDEF_FE(test_get_chttpd_config_integer), + ?TDEF_FE(test_get_chttpd_config_boolean) + ] + } + } + }. + + +test_behavior(_) -> + ?assertEqual("get_in_chttpd", chttpd_util:get_chttpd_config("both_exist")), + ?assertEqual(1, chttpd_util:get_chttpd_config_integer("chttpd_only", 0)), + ?assert(chttpd_util:get_chttpd_config_boolean("httpd_only", false)). + + +test_with_undefined_option(_) -> + ?assertEqual(undefined, chttpd_util:get_chttpd_config("undefined_option")), + ?assertEqual(abc, chttpd_util:get_chttpd_config("undefined_option", abc)), + ?assertEqual(123, chttpd_util:get_chttpd_config("undefined_option", 123)), + ?assertEqual(0.2, chttpd_util:get_chttpd_config("undefined_option", 0.2)), + ?assertEqual("a", chttpd_util:get_chttpd_config("undefined_option", "a")), + ?assertEqual("", chttpd_util:get_chttpd_config("undefined_option", "")), + ?assert(chttpd_util:get_chttpd_config("undefined_option", true)), + ?assertNot(chttpd_util:get_chttpd_config("undefined_option", false)). + + +test_with_httpd_option(_) -> + ?assertEqual("{couch_httpd_auth, cookie_authentication_handler}, " ++ + "{couch_httpd_auth, default_authentication_handler}", + chttpd_util:get_chttpd_config("authentication_handlers")). + + +test_with_chttpd_option(_) -> + ?assertEqual("512", chttpd_util:get_chttpd_config("backlog")), + ?assertEqual("512", chttpd_util:get_chttpd_config("backlog", 123)), + ?assertEqual(512, chttpd_util:get_chttpd_config_integer("backlog", 123)), + ?assertEqual("false", + chttpd_util:get_chttpd_config("require_valid_user")), + ?assertEqual("false", + chttpd_util:get_chttpd_config("require_valid_user", "true")), + ?assertEqual(false, + chttpd_util:get_chttpd_config_boolean("require_valid_user", true)). + + +test_with_chttpd_option_which_moved_from_httpd(_) -> + ?assertEqual(undefined, chttpd_util:get_chttpd_config("max_uri_length")), + ?assertEqual(8000, chttpd_util:get_chttpd_config("max_uri_length", 8000)), + ?assertEqual(undefined, chttpd_util:get_chttpd_config("WWW-Authenticate")), + ?assert(chttpd_util:get_chttpd_config("enable_cors", true)). + + +test_get_chttpd_config_integer(_) -> + ?assertEqual(123, + chttpd_util:get_chttpd_config_integer("max_http_request_size", 123)). + + +test_get_chttpd_config_boolean(_) -> + ?assert(chttpd_util:get_chttpd_config_boolean("allow_jsonp", true)). diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl index fd83c258a..c6e7e5296 100644 --- a/src/couch/src/couch_httpd.erl +++ b/src/couch/src/couch_httpd.erl @@ -73,7 +73,7 @@ make_fun_spec_strs(SpecStr) -> re:split(SpecStr, "(?<=})\\s*,\\s*(?={)", [{return, list}]). validate_host(#httpd{} = Req) -> - case config:get_boolean("httpd", "validate_host", false) of + case chttpd_util:get_chttpd_config_boolean("validate_host", false) of true -> Host = hostname(Req), ValidHosts = valid_hosts(), @@ -97,7 +97,7 @@ hostname(#httpd{} = Req) -> end. valid_hosts() -> - List = config:get("httpd", "valid_hosts", ""), + List = chttpd_util:get_chttpd_config("valid_hosts", ""), re:split(List, ",", [{return, list}]). validate_referer(Req) -> @@ -130,7 +130,8 @@ validate_ctype(Req, Ctype) -> check_max_request_length(Req) -> Len = list_to_integer(header_value(Req, "Content-Length", "0")), - MaxLen = config:get_integer("httpd", "max_http_request_size", 4294967296), + MaxLen = chttpd_util:get_chttpd_config_integer( + "max_http_request_size", 4294967296), case Len > MaxLen of true -> exit({body_too_large, Len}); @@ -199,7 +200,8 @@ path(#httpd{mochi_req=MochiReq}) -> MochiReq:get(path). host_for_request(#httpd{mochi_req=MochiReq}) -> - XHost = config:get("httpd", "x_forwarded_host", "X-Forwarded-Host"), + XHost = chttpd_util:get_chttpd_config( + "x_forwarded_host", "X-Forwarded-Host"), case MochiReq:get_header_value(XHost) of undefined -> case MochiReq:get_header_value("Host") of @@ -217,11 +219,12 @@ host_for_request(#httpd{mochi_req=MochiReq}) -> absolute_uri(#httpd{mochi_req=MochiReq}=Req, [$/ | _] = Path) -> Host = host_for_request(Req), - XSsl = config:get("httpd", "x_forwarded_ssl", "X-Forwarded-Ssl"), + XSsl = chttpd_util:get_chttpd_config("x_forwarded_ssl", "X-Forwarded-Ssl"), Scheme = case MochiReq:get_header_value(XSsl) of "on" -> "https"; _ -> - XProto = config:get("httpd", "x_forwarded_proto", "X-Forwarded-Proto"), + XProto = chttpd_util:get_chttpd_config( + "x_forwarded_proto", "X-Forwarded-Proto"), case MochiReq:get_header_value(XProto) of %% Restrict to "https" and "http" schemes only "https" -> "https"; @@ -252,13 +255,15 @@ recv_chunked(#httpd{mochi_req=MochiReq}, MaxChunkSize, ChunkFun, InitState) -> % Fun({Length, Binary}, State) % called with Length == 0 on the last time. MochiReq:stream_body(MaxChunkSize, ChunkFun, InitState, - config:get_integer("httpd", "max_http_request_size", 4294967296)). + chttpd_util:get_chttpd_config_integer( + "max_http_request_size", 4294967296)). body_length(#httpd{mochi_req=MochiReq}) -> MochiReq:get(body_length). body(#httpd{mochi_req=MochiReq, req_body=undefined}) -> - MaxSize = config:get_integer("httpd", "max_http_request_size", 4294967296), + MaxSize = chttpd_util:get_chttpd_config_integer( + "max_http_request_size", 4294967296), MochiReq:recv_body(MaxSize); body(#httpd{req_body=ReqBody}) -> ReqBody. @@ -503,11 +508,12 @@ initialize_jsonp(Req) -> CallBack -> try % make sure jsonp is configured on (default off) - case config:get("httpd", "allow_jsonp", "false") of - "true" -> - validate_callback(CallBack); - _Else -> - put(jsonp, no_jsonp) + case chttpd_util:get_chttpd_config_boolean( + "allow_jsonp", false) of + true -> + validate_callback(CallBack); + false -> + put(jsonp, no_jsonp) end catch Error -> @@ -610,7 +616,7 @@ error_headers(#httpd{mochi_req=MochiReq}=Req, Code, ErrorStr, ReasonStr) -> % this is where the basic auth popup is triggered case MochiReq:get_header_value("X-CouchDB-WWW-Authenticate") of undefined -> - case config:get("httpd", "WWW-Authenticate", undefined) of + case chttpd_util:get_chttpd_config("WWW-Authenticate") of undefined -> % If the client is a browser and the basic auth popup isn't turned on % redirect to the session page. diff --git a/src/couch/src/couch_httpd_vhost.erl b/src/couch/src/couch_httpd_vhost.erl index 3d6b4da01..4db3f6234 100644 --- a/src/couch/src/couch_httpd_vhost.erl +++ b/src/couch/src/couch_httpd_vhost.erl @@ -259,8 +259,8 @@ bind_path(_, _) -> %% create vhost list from ini host(MochiReq) -> - XHost = config:get("httpd", "x_forwarded_host", - "X-Forwarded-Host"), + XHost = chttpd_util:get_chttpd_config( + "x_forwarded_host", "X-Forwarded-Host"), case MochiReq:get_header_value(XHost) of undefined -> case MochiReq:get_header_value("Host") of diff --git a/src/couch/test/eunit/couchdb_cors_tests.erl b/src/couch/test/eunit/couchdb_cors_tests.erl index 0e0926c1f..55e228f14 100644 --- a/src/couch/test/eunit/couchdb_cors_tests.erl +++ b/src/couch/test/eunit/couchdb_cors_tests.erl @@ -27,7 +27,7 @@ start() -> Ctx = test_util:start_couch([chttpd]), - ok = config:set("httpd", "enable_cors", "true", false), + ok = config:set("chttpd", "enable_cors", "true", false), ok = config:set("vhosts", "example.com", "/", false), Ctx. diff --git a/src/couch/test/eunit/couchdb_mrview_cors_tests.erl b/src/couch/test/eunit/couchdb_mrview_cors_tests.erl index a9215f5d7..4e4659655 100644 --- a/src/couch/test/eunit/couchdb_mrview_cors_tests.erl +++ b/src/couch/test/eunit/couchdb_mrview_cors_tests.erl @@ -33,7 +33,7 @@ start() -> Ctx = test_util:start_couch([chttpd]), Hashed = couch_passwords:hash_admin_password(?PASS), ok = config:set("admins", ?USER, ?b2l(Hashed), _Persist=false), - ok = config:set("httpd", "enable_cors", "true", false), + ok = config:set("chttpd", "enable_cors", "true", false), ok = config:set("vhosts", "example.com", "/", false), Ctx. diff --git a/src/couch_replicator/test/eunit/couch_replicator_small_max_request_size_target.erl b/src/couch_replicator/test/eunit/couch_replicator_small_max_request_size_target.erl index b113c5392..166069cb4 100644 --- a/src/couch_replicator/test/eunit/couch_replicator_small_max_request_size_target.erl +++ b/src/couch_replicator/test/eunit/couch_replicator_small_max_request_size_target.erl @@ -30,12 +30,12 @@ reduce_max_request_size_test_() -> setup() -> Source = couch_replicator_test_helper:create_db(), Target = couch_replicator_test_helper:create_db(), - config:set("httpd", "max_http_request_size", "10000", false), + config:set("chttpd", "max_http_request_size", "10000", false), {Source, Target}. teardown({Source, Target}) -> - config:delete("httpd", "max_http_request_size", false), + config:delete("chttpd", "max_http_request_size", false), couch_replicator_test_helper:delete_db(Source), couch_replicator_test_helper:delete_db(Target). diff --git a/test/elixir/test/config_test.exs b/test/elixir/test/config_test.exs index e49d2aa8f..f76464f5e 100644 --- a/test/elixir/test/config_test.exs +++ b/test/elixir/test/config_test.exs @@ -76,7 +76,7 @@ defmodule ConfigTest do end test "Settings can be altered with undefined whitelist allowing any change", context do - refute context["config"]["httpd"]["config_whitelist"], "Default whitelist is empty" + refute context["config"]["chttpd"]["config_whitelist"], "Default whitelist is empty" set_config(context, "test", "foo", "bar") assert get_config(context, "test")["foo"] == "bar" assert get_config(context, "test", "foo") == "bar" @@ -97,32 +97,32 @@ defmodule ConfigTest do test "Non-term whitelist values allow further modification of the whitelist", context do val = "!This is an invalid Erlang term!" - set_config(context, "httpd", "config_whitelist", val) - assert val == get_config(context, "httpd", "config_whitelist") - delete_config(context, "httpd", "config_whitelist") + set_config(context, "chttpd", "config_whitelist", val) + assert val == get_config(context, "chttpd", "config_whitelist") + delete_config(context, "chttpd", "config_whitelist") end test "Non-list whitelist values allow further modification of the whitelist", context do val = "{[yes, a_valid_erlang_term, but_unfortunately, not_a_list]}" - set_config(context, "httpd", "config_whitelist", val) - assert val == get_config(context, "httpd", "config_whitelist") - delete_config(context, "httpd", "config_whitelist") + set_config(context, "chttpd", "config_whitelist", val) + assert val == get_config(context, "chttpd", "config_whitelist") + delete_config(context, "chttpd", "config_whitelist") end test "Keys not in the whitelist may not be modified", context do - val = "[{httpd,config_whitelist}, {test,foo}]" - set_config(context, "httpd", "config_whitelist", val) - assert val == get_config(context, "httpd", "config_whitelist") + val = "[{chttpd,config_whitelist}, {test,foo}]" + set_config(context, "chttpd", "config_whitelist", val) + assert val == get_config(context, "chttpd", "config_whitelist") set_config(context, "test", "foo", "PUT to whitelisted config variable") delete_config(context, "test", "foo") end test "Non-2-tuples in the whitelist are ignored", context do val = - "[{httpd,config_whitelist}, these, {are}, {nOt, 2, tuples}, [so], [they, will], [all, become, noops], {test,foo}]" + "[{chttpd,config_whitelist}, these, {are}, {nOt, 2, tuples}, [so], [they, will], [all, become, noops], {test,foo}]" - set_config(context, "httpd", "config_whitelist", val) - assert val == get_config(context, "httpd", "config_whitelist") + set_config(context, "chttpd", "config_whitelist", val) + assert val == get_config(context, "chttpd", "config_whitelist") set_config(context, "test", "foo", "PUT to whitelisted config variable") delete_config(context, "test", "foo") end @@ -133,9 +133,9 @@ defmodule ConfigTest do Enum.each(vals, fn pair -> set_config( context, - "httpd", + "chttpd", "config_whitelist", - "[{httpd,config_whitelist}, #{pair}" + "[{chttpd,config_whitelist}, #{pair}" ) pair_format = @@ -149,7 +149,7 @@ defmodule ConfigTest do delete_config(context, "test", "foo") end) - delete_config(context, "httpd", "config_whitelist") + delete_config(context, "chttpd", "config_whitelist") end test "Blacklist is functional", context do diff --git a/test/elixir/test/http_test.exs b/test/elixir/test/http_test.exs index 14cecfe7b..f26ac9f29 100644 --- a/test/elixir/test/http_test.exs +++ b/test/elixir/test/http_test.exs @@ -31,7 +31,7 @@ defmodule HttpTest do server_config = [ %{ - :section => "httpd", + :section => "chttpd", :key => "x_forwarded_host", :value => "X-Host" } diff --git a/test/elixir/test/jsonp_test.exs b/test/elixir/test/jsonp_test.exs index 2e1934a22..308221b71 100644 --- a/test/elixir/test/jsonp_test.exs +++ b/test/elixir/test/jsonp_test.exs @@ -20,7 +20,7 @@ defmodule JsonpTest do server_config = [ %{ - :section => "httpd", + :section => "chttpd", :key => "allow_jsonp", :value => "true" } @@ -51,7 +51,7 @@ defmodule JsonpTest do server_config = [ %{ - :section => "httpd", + :section => "chttpd", :key => "allow_jsonp", :value => "true" } diff --git a/test/elixir/test/rewrite_test.exs b/test/elixir/test/rewrite_test.exs index 75f198568..d4c2faf1a 100644 --- a/test/elixir/test/rewrite_test.exs +++ b/test/elixir/test/rewrite_test.exs @@ -16,7 +16,7 @@ defmodule RewriteTest do @tag config: [ {"httpd", "authentication_handlers", "{couch_httpd_auth, special_test_authentication_handler}"}, - {"httpd", "WWW-Authenticate", "X-Couch-Test-Auth"} + {"chttpd", "WWW-Authenticate", "X-Couch-Test-Auth"} ] test "Test basic rewrites on #{db_name}", context do db_name = context[:db_name] @@ -450,7 +450,7 @@ defmodule RewriteTest do @tag with_random_db: db_name @tag config: [ - {"httpd", "secure_rewrites", "false"} + {"chttpd", "secure_rewrites", "false"} ] test "path relative to server on #{db_name}", context do db_name = context[:db_name] @@ -474,7 +474,7 @@ defmodule RewriteTest do @tag with_random_db: db_name @tag config: [ - {"httpd", "rewrite_limit", "2"} + {"chttpd", "rewrite_limit", "2"} ] test "loop detection on #{db_name}", context do db_name = context[:db_name] @@ -492,8 +492,8 @@ defmodule RewriteTest do @tag with_random_db: db_name @tag config: [ - {"httpd", "rewrite_limit", "2"}, - {"httpd", "secure_rewrites", "false"} + {"chttpd", "rewrite_limit", "2"}, + {"chttpd", "secure_rewrites", "false"} ] test "serial execution is not spuriously counted as loop on #{db_name}", context do db_name = context[:db_name] diff --git a/test/javascript/tests/rewrite.js b/test/javascript/tests/rewrite.js index 88479b877..a470eaee6 100644 --- a/test/javascript/tests/rewrite.js +++ b/test/javascript/tests/rewrite.js @@ -26,7 +26,7 @@ couchTests.rewrite = function(debug) { [{section: "httpd", key: "authentication_handlers", value: "{couch_httpd_auth, special_test_authentication_handler}"}, - {section:"httpd", + {section:"chttpd", key: "WWW-Authenticate", value: "X-Couch-Test-Auth"}], @@ -430,7 +430,7 @@ couchTests.rewrite = function(debug) { T(result.error == "insecure_rewrite_rule"); run_on_modified_server( - [{section: "httpd", + [{section: "chttpd", key: "secure_rewrites", value: "false"}], function() { @@ -483,7 +483,7 @@ couchTests.rewrite = function(debug) { // Assert loop detection run_on_modified_server( - [{section: "httpd", + [{section: "chttpd", key: "rewrite_limit", value: "2"}], function(){ @@ -494,10 +494,10 @@ couchTests.rewrite = function(debug) { // Assert serial execution is not spuriously counted as loop run_on_modified_server( - [{section: "httpd", + [{section: "chttpd", key: "rewrite_limit", value: "2"}, - {section: "httpd", + {section: "chttpd", key: "secure_rewrites", value: "false"}], function(){ |