summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Wallace <mikewallace@apache.org>2014-12-01 13:22:46 +0000
committerMike Wallace <mikewallace@apache.org>2014-12-03 19:11:13 +0000
commited4a4a9e2bfbc906bc2339007fe7ef13137eba88 (patch)
treeafcae4acb21935fd5da9d38d3a709fc0628f6dd2
parent23d79b3f606245ab657900fe7b1bc6ef77ace16e (diff)
downloadcouchdb-2452-users-db-security-on-clustered-interface.tar.gz
Make users_db_security.js use N=1 clusters only2452-users-db-security-on-clustered-interface
The users_db_security.js test will not work against a multi-node cluster because it relies on config settings being made by the test code. Because there is no generic way of discovering the locations of the other nodes on a dev cluster (they may be on unexpected ports for one reason or another) it is only possible to guarantee those settings are made on a single node. This commit therefore forces the users_db_security.js test to run against a single node cluster by: - setting the cluster variables to N=Q=R=W=1 - excluding the test in the Makefile and running it explicitly with `dev/run -n 1` - teaching run_on_modified_server to correctly preserve the old config settings when nested run_on_modified_server calls are made COUCHDB-2452
-rw-r--r--Makefile1
-rw-r--r--share/www/script/couch_test_runner.js8
-rw-r--r--share/www/script/test/users_db_security.js43
-rwxr-xr-xtest/javascript/run7
4 files changed, 50 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 986d2dc95..7f57830d3 100644
--- a/Makefile
+++ b/Makefile
@@ -69,3 +69,4 @@ eunit: compile
javascript: compile
@dev/run -q test/javascript/run
+ @dev/run -n 1 -q test/javascript/run share/www/script/test/users_db_security.js
diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js
index efc4dc242..0617efd18 100644
--- a/share/www/script/couch_test_runner.js
+++ b/share/www/script/couch_test_runner.js
@@ -363,6 +363,14 @@ function makeDocs(start, end, templateDoc) {
}
function run_on_modified_server(settings, fun) {
+ // Clone settings so we don't overwrite oldValue when making nested run_on_modified_server calls
+ var settings = settings.map(function(s) {
+ return {
+ section: s.section,
+ key: s.key,
+ value: s.value
+ };
+ });
try {
// set the settings
for(var i=0; i < settings.length; i++) {
diff --git a/share/www/script/test/users_db_security.js b/share/www/script/test/users_db_security.js
index ae139508f..3eb446cf3 100644
--- a/share/www/script/test/users_db_security.js
+++ b/share/www/script/test/users_db_security.js
@@ -10,7 +10,34 @@
// License for the specific language governing permissions and limitations under
// the License.
couchTests.users_db_security = function(debug) {
+ var clusterVars = [{
+ section: "cluster",
+ key: "q",
+ value: "1"
+ },
+ {
+ section: "cluster",
+ key: "n",
+ value: "1"
+ },
+ {
+ section: "cluster",
+ key: "w",
+ value: "1"
+ },
+ {
+ section: "cluster",
+ key: "r",
+ value: "1"
+ }
+ ];
function run_test_against_url(url) {
+ // Ensure users DB is created with desired Q/N
+ run_on_modified_server(clusterVars, function() {
+ CouchDB.urlPrefix = url;
+ new CouchDB("test_suite_users", {"X-Couch-Full-Commit":"false"});
+ });
+
CouchDB.urlPrefix = url;
var usersDb = new CouchDB("test_suite_users", {"X-Couch-Full-Commit":"false"});
if (debug) debugger;
@@ -113,7 +140,7 @@ couchTests.users_db_security = function(debug) {
CouchDB.urlPrefix = '';
// create server admin
- run_on_modified_server([
+ run_on_modified_server(clusterVars.concat([
{
section: "couch_httpd_auth",
key: "iterations",
@@ -124,7 +151,7 @@ couchTests.users_db_security = function(debug) {
key: "jan",
value: "apple"
}
- ], function() {
+ ]), function() {
CouchDB.urlPrefix = url;
// anonymous should not be able to read an existing user's user document
@@ -327,7 +354,7 @@ couchTests.users_db_security = function(debug) {
TEquals(true, CouchDB.login("jan", "apple").ok);
});
- run_on_modified_server([
+ run_on_modified_server(clusterVars.concat([
{
section: "couch_httpd_auth",
key: "iterations",
@@ -363,7 +390,7 @@ couchTests.users_db_security = function(debug) {
key: "jan",
value: "apple"
}
- ], function() {
+ ]), function() {
var res = usersDb.open("org.couchdb.user:jchris");
TEquals("jchris", res.name);
TEquals("user", res.type);
@@ -396,7 +423,7 @@ couchTests.users_db_security = function(debug) {
TEquals(true, CouchDB.login("jan", "apple").ok);
});
- run_on_modified_server([
+ run_on_modified_server(clusterVars.concat([
{
section: "couch_httpd_auth",
key: "iterations",
@@ -432,7 +459,7 @@ couchTests.users_db_security = function(debug) {
key: "jan",
value: "apple"
}
- ], function() {
+ ]), function() {
TEquals(true, CouchDB.login("jchris", "couch").ok);
try {
@@ -455,13 +482,13 @@ couchTests.users_db_security = function(debug) {
};
usersDb.deleteDb();
- run_on_modified_server(
+ run_on_modified_server(clusterVars.concat(
[{section: "couch_httpd_auth",
key: "iterations", value: "1"},
{section: "couch_httpd_auth",
key: "authentication_db", value: usersDb.name},
{section: "chttpd_auth",
- key: "authentication_db", value: usersDb.name}],
+ key: "authentication_db", value: usersDb.name}]),
testFun
);
usersDb.deleteDb(); // cleanup
diff --git a/test/javascript/run b/test/javascript/run
index ab145b108..4b272ba25 100755
--- a/test/javascript/run
+++ b/test/javascript/run
@@ -37,6 +37,10 @@ SCRIPTS = """
test/javascript/test_setup.js
""".split()
+EXCLUDE = """
+ share/www/script/test/users_db_security.js
+""".split()
+
RUNNER = "test/javascript/cli_runner.js"
@@ -109,7 +113,8 @@ def main():
args = ["share/www/script/test"]
for name in args:
if os.path.isdir(name):
- tests.extend(glob.glob(os.path.join(name, "*.js")))
+ tests_in_dir = glob.glob(os.path.join(name, "*.js"))
+ tests.extend([t for t in tests_in_dir if not t in EXCLUDE])
elif os.path.isfile(name):
tests.append(name)
else: