Skip to content

Commit

Permalink
COUCHDB-1060 - Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rnewson committed Apr 6, 2012
1 parent bdc0385 commit 7fbf213
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions share/www/script/test/cookie_auth.js
Expand Up @@ -278,6 +278,8 @@ couchTests.cookie_auth = function(debug) {
[
{section: "couch_httpd_auth",
key: "authentication_db", value: "test_suite_users"},
{section: "couch_httpd_auth",
key: "iterations", value: "1"},
{section: "admins",
key: "jan", value: "apple"}
],
Expand Down
2 changes: 1 addition & 1 deletion share/www/script/test/oauth.js
Expand Up @@ -105,7 +105,7 @@ couchTests.oauth = function(debug) {
headers: {
"Authorization": adminBasicAuthHeaderValue()
}});
if (xhr.responseText.indexOf("\"-hashed-") != 0) {
if (xhr.responseText.indexOf("\"-pbkdf2-") != 0) {
throw("still waiting");
}
}, "wait-for-admin");
Expand Down
10 changes: 10 additions & 0 deletions share/www/script/test/replicator_db.js
Expand Up @@ -578,6 +578,11 @@ couchTests.replicator_db = function(debug) {
}).ok);

var server_admins_config = [
{
section: "couch_httpd_auth",
key: "iterations",
value: "1"
},
{
section: "admins",
key: "fdmanana",
Expand Down Expand Up @@ -1436,6 +1441,11 @@ couchTests.replicator_db = function(debug) {

// run all the tests
var server_config = [
{
section: "couch_httpd_auth",
key: "iterations",
value: "1"
},
{
section: "replicator",
key: "db",
Expand Down
19 changes: 13 additions & 6 deletions share/www/script/test/users_db_security.js
Expand Up @@ -75,9 +75,9 @@ couchTests.users_db_security = function(debug) {
usersDb.deleteDb();

// _users db
// a doc with a field 'password' should be hashed to 'password_sha'
// a doc with a field 'password' should be hashed to 'derived_key'
// with salt and salt stored in 'salt', 'password' is set to null.
// Exising 'password_sha' and 'salt' fields are overwritten with new values
// Exising 'derived_key' and 'salt' fields are overwritten with new values
// when a non-null 'password' field exists.
// anonymous should be able to create a user document
var userDoc = {
Expand All @@ -92,11 +92,16 @@ couchTests.users_db_security = function(debug) {
TEquals(true, usersDb.save(userDoc).ok, "should save document");
userDoc = usersDb.open("org.couchdb.user:jchris");
TEquals(undefined, userDoc.password, "password field should be null 1");
TEquals(40, userDoc.password_sha.length, "password_sha should exist");
TEquals(40, userDoc.derived_key.length, "derived_key should exist");
TEquals(32, userDoc.salt.length, "salt should exist");

// create server admin
run_on_modified_server([
{
section: "couch_httpd_auth",
key: "iterations",
value: "1"
},
{
section: "admins",
key: "jan",
Expand Down Expand Up @@ -131,12 +136,12 @@ couchTests.users_db_security = function(debug) {
var jchrisDoc = open_as(usersDb, "org.couchdb.user:jchris", "jchris1");

TEquals(undefined, jchrisDoc.password, "password field should be null 2");
TEquals(40, jchrisDoc.password_sha.length, "password_sha should exist");
TEquals(40, jchrisDoc.derived_key.length, "derived_key should exist");
TEquals(32, jchrisDoc.salt.length, "salt should exist");

TEquals(true, userDoc.salt != jchrisDoc.salt, "should have new salt");
TEquals(true, userDoc.password_sha != jchrisDoc.password_sha,
"should have new password_sha");
TEquals(true, userDoc.derived_key != jchrisDoc.derived_key,
"should have new derived_key");

// user should not be able to read another user's user document
var fdmananaDoc = {
Expand Down Expand Up @@ -248,6 +253,8 @@ couchTests.users_db_security = function(debug) {
usersDb.deleteDb();
run_on_modified_server(
[{section: "couch_httpd_auth",
key: "iterations", value: "1"},
{section: "couch_httpd_auth",
key: "authentication_db", value: usersDb.name}],
testFun
);
Expand Down

0 comments on commit 7fbf213

Please sign in to comment.