You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2015/02/09 21:00:04 UTC
[03/57] [abbrv] couchdb commit: updated
refs/heads/developer-preview-2.0 to 849b334
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/script/jspec/jspec.xhr.js
----------------------------------------------------------------------
diff --git a/share/www/script/jspec/jspec.xhr.js b/share/www/script/jspec/jspec.xhr.js
deleted file mode 100644
index 6164879..0000000
--- a/share/www/script/jspec/jspec.xhr.js
+++ /dev/null
@@ -1,195 +0,0 @@
-
-// JSpec - XHR - Copyright TJ Holowaychuk <tj...@vision-media.ca> (MIT Licensed)
-
-(function(){
-
- var lastRequest
-
- // --- Original XMLHttpRequest
-
- var OriginalXMLHttpRequest = 'XMLHttpRequest' in this ?
- XMLHttpRequest :
- function(){}
- var OriginalActiveXObject = 'ActiveXObject' in this ?
- ActiveXObject :
- undefined
-
- // --- MockXMLHttpRequest
-
- var MockXMLHttpRequest = function() {
- this.requestHeaders = {}
- }
-
- MockXMLHttpRequest.prototype = {
- status: 0,
- async: true,
- readyState: 0,
- responseText: '',
- abort: function(){},
- onreadystatechange: function(){},
-
- /**
- * Return response headers hash.
- */
-
- getAllResponseHeaders : function(){
- return this.responseHeaders
- },
-
- /**
- * Return case-insensitive value for header _name_.
- */
-
- getResponseHeader : function(name) {
- return this.responseHeaders[name.toLowerCase()]
- },
-
- /**
- * Set case-insensitive _value_ for header _name_.
- */
-
- setRequestHeader : function(name, value) {
- this.requestHeaders[name.toLowerCase()] = value
- },
-
- /**
- * Open mock request.
- */
-
- open : function(method, url, async, user, password) {
- this.user = user
- this.password = password
- this.url = url
- this.readyState = 1
- this.method = method.toUpperCase()
- if (async != undefined) this.async = async
- if (this.async) this.onreadystatechange()
- },
-
- /**
- * Send request _data_.
- */
-
- send : function(data) {
- var self = this
- this.data = data
- this.readyState = 4
- if (this.method == 'HEAD') this.responseText = null
- this.responseHeaders['content-length'] = (this.responseText || '').length
- if(this.async) this.onreadystatechange()
- lastRequest = function(){
- return self
- }
- }
- }
-
- // --- Response status codes
-
- JSpec.statusCodes = {
- 100: 'Continue',
- 101: 'Switching Protocols',
- 200: 'OK',
- 201: 'Created',
- 202: 'Accepted',
- 203: 'Non-Authoritative Information',
- 204: 'No Content',
- 205: 'Reset Content',
- 206: 'Partial Content',
- 300: 'Multiple Choice',
- 301: 'Moved Permanently',
- 302: 'Found',
- 303: 'See Other',
- 304: 'Not Modified',
- 305: 'Use Proxy',
- 307: 'Temporary Redirect',
- 400: 'Bad Request',
- 401: 'Unauthorized',
- 402: 'Payment Required',
- 403: 'Forbidden',
- 404: 'Not Found',
- 405: 'Method Not Allowed',
- 406: 'Not Acceptable',
- 407: 'Proxy Authentication Required',
- 408: 'Request Timeout',
- 409: 'Conflict',
- 410: 'Gone',
- 411: 'Length Required',
- 412: 'Precondition Failed',
- 413: 'Request Entity Too Large',
- 414: 'Request-URI Too Long',
- 415: 'Unsupported Media Type',
- 416: 'Requested Range Not Satisfiable',
- 417: 'Expectation Failed',
- 422: 'Unprocessable Entity',
- 500: 'Internal Server Error',
- 501: 'Not Implemented',
- 502: 'Bad Gateway',
- 503: 'Service Unavailable',
- 504: 'Gateway Timeout',
- 505: 'HTTP Version Not Supported'
- }
-
- /**
- * Mock XMLHttpRequest requests.
- *
- * mockRequest().and_return('some data', 'text/plain', 200, { 'X-SomeHeader' : 'somevalue' })
- *
- * @return {hash}
- * @api public
- */
-
- function mockRequest() {
- return { and_return : function(body, type, status, headers) {
- XMLHttpRequest = MockXMLHttpRequest
- ActiveXObject = false
- status = status || 200
- headers = headers || {}
- headers['content-type'] = type
- JSpec.extend(XMLHttpRequest.prototype, {
- responseText: body,
- responseHeaders: headers,
- status: status,
- statusText: JSpec.statusCodes[status]
- })
- }}
- }
-
- /**
- * Unmock XMLHttpRequest requests.
- *
- * @api public
- */
-
- function unmockRequest() {
- XMLHttpRequest = OriginalXMLHttpRequest
- ActiveXObject = OriginalActiveXObject
- }
-
- JSpec.include({
- name: 'Mock XHR',
-
- // --- Utilities
-
- utilities : {
- mockRequest: mockRequest,
- unmockRequest: unmockRequest
- },
-
- // --- Hooks
-
- afterSpec : function() {
- unmockRequest()
- },
-
- // --- DSLs
-
- DSLs : {
- snake : {
- mock_request: mockRequest,
- unmock_request: unmockRequest,
- last_request: function(){ return lastRequest() }
- }
- }
-
- })
-})()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/script/oauth.js
----------------------------------------------------------------------
diff --git a/share/www/script/oauth.js b/share/www/script/oauth.js
deleted file mode 100644
index ada00a2..0000000
--- a/share/www/script/oauth.js
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- * Copyright 2008 Netflix, Inc.
- *
- * 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.
- */
-
-/* Here's some JavaScript software for implementing OAuth.
-
- This isn't as useful as you might hope. OAuth is based around
- allowing tools and websites to talk to each other. However,
- JavaScript running in web browsers is hampered by security
- restrictions that prevent code running on one website from
- accessing data stored or served on another.
-
- Before you start hacking, make sure you understand the limitations
- posed by cross-domain XMLHttpRequest.
-
- On the bright side, some platforms use JavaScript as their
- language, but enable the programmer to access other web sites.
- Examples include Google Gadgets, and Microsoft Vista Sidebar.
- For those platforms, this library should come in handy.
-*/
-
-// The HMAC-SHA1 signature method calls b64_hmac_sha1, defined by
-// http://pajhome.org.uk/crypt/md5/sha1.js
-
-/* An OAuth message is represented as an object like this:
- {method: "GET", action: "http://server.com/path", parameters: ...}
-
- The parameters may be either a map {name: value, name2: value2}
- or an Array of name-value pairs [[name, value], [name2, value2]].
- The latter representation is more powerful: it supports parameters
- in a specific sequence, or several parameters with the same name;
- for example [["a", 1], ["b", 2], ["a", 3]].
-
- Parameter names and values are NOT percent-encoded in an object.
- They must be encoded before transmission and decoded after reception.
- For example, this message object:
- {method: "GET", action: "http://server/path", parameters: {p: "x y"}}
- ... can be transmitted as an HTTP request that begins:
- GET /path?p=x%20y HTTP/1.0
- (This isn't a valid OAuth request, since it lacks a signature etc.)
- Note that the object "x y" is transmitted as x%20y. To encode
- parameters, you can call OAuth.addToURL, OAuth.formEncode or
- OAuth.getAuthorization.
-
- This message object model harmonizes with the browser object model for
- input elements of an form, whose value property isn't percent encoded.
- The browser encodes each value before transmitting it. For example,
- see consumer.setInputs in example/consumer.js.
- */
-var OAuth; if (OAuth == null) OAuth = {};
-
-OAuth.setProperties = function setProperties(into, from) {
- if (into != null && from != null) {
- for (var key in from) {
- into[key] = from[key];
- }
- }
- return into;
-}
-
-OAuth.setProperties(OAuth, // utility functions
-{
- percentEncode: function percentEncode(s) {
- if (s == null) {
- return "";
- }
- if (s instanceof Array) {
- var e = "";
- for (var i = 0; i < s.length; ++i) {
- if (e != "") e += '&';
- e += percentEncode(s[i]);
- }
- return e;
- }
- s = encodeURIComponent(s);
- // Now replace the values which encodeURIComponent doesn't do
- // encodeURIComponent ignores: - _ . ! ~ * ' ( )
- // OAuth dictates the only ones you can ignore are: - _ . ~
- // Source: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent
- s = s.replace(/\!/g, "%21");
- s = s.replace(/\*/g, "%2A");
- s = s.replace(/\'/g, "%27");
- s = s.replace(/\(/g, "%28");
- s = s.replace(/\)/g, "%29");
- return s;
- }
-,
- decodePercent: function decodePercent(s) {
- if (s != null) {
- // Handle application/x-www-form-urlencoded, which is defined by
- // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
- s = s.replace(/\+/g, " ");
- }
- return decodeURIComponent(s);
- }
-,
- /** Convert the given parameters to an Array of name-value pairs. */
- getParameterList: function getParameterList(parameters) {
- if (parameters == null) {
- return [];
- }
- if (typeof parameters != "object") {
- return decodeForm(parameters + "");
- }
- if (parameters instanceof Array) {
- return parameters;
- }
- var list = [];
- for (var p in parameters) {
- list.push([p, parameters[p]]);
- }
- return list;
- }
-,
- /** Convert the given parameters to a map from name to value. */
- getParameterMap: function getParameterMap(parameters) {
- if (parameters == null) {
- return {};
- }
- if (typeof parameters != "object") {
- return getParameterMap(decodeForm(parameters + ""));
- }
- if (parameters instanceof Array) {
- var map = {};
- for (var p = 0; p < parameters.length; ++p) {
- var key = parameters[p][0];
- if (map[key] === undefined) { // first value wins
- map[key] = parameters[p][1];
- }
- }
- return map;
- }
- return parameters;
- }
-,
- getParameter: function getParameter(parameters, name) {
- if (parameters instanceof Array) {
- for (var p = 0; p < parameters.length; ++p) {
- if (parameters[p][0] == name) {
- return parameters[p][1]; // first value wins
- }
- }
- } else {
- return OAuth.getParameterMap(parameters)[name];
- }
- return null;
- }
-,
- formEncode: function formEncode(parameters) {
- var form = "";
- var list = OAuth.getParameterList(parameters);
- for (var p = 0; p < list.length; ++p) {
- var value = list[p][1];
- if (value == null) value = "";
- if (form != "") form += '&';
- form += OAuth.percentEncode(list[p][0])
- +'='+ OAuth.percentEncode(value);
- }
- return form;
- }
-,
- decodeForm: function decodeForm(form) {
- var list = [];
- var nvps = form.split('&');
- for (var n = 0; n < nvps.length; ++n) {
- var nvp = nvps[n];
- if (nvp == "") {
- continue;
- }
- var equals = nvp.indexOf('=');
- var name;
- var value;
- if (equals < 0) {
- name = OAuth.decodePercent(nvp);
- value = null;
- } else {
- name = OAuth.decodePercent(nvp.substring(0, equals));
- value = OAuth.decodePercent(nvp.substring(equals + 1));
- }
- list.push([name, value]);
- }
- return list;
- }
-,
- setParameter: function setParameter(message, name, value) {
- var parameters = message.parameters;
- if (parameters instanceof Array) {
- for (var p = 0; p < parameters.length; ++p) {
- if (parameters[p][0] == name) {
- if (value === undefined) {
- parameters.splice(p, 1);
- } else {
- parameters[p][1] = value;
- value = undefined;
- }
- }
- }
- if (value !== undefined) {
- parameters.push([name, value]);
- }
- } else {
- parameters = OAuth.getParameterMap(parameters);
- parameters[name] = value;
- message.parameters = parameters;
- }
- }
-,
- setParameters: function setParameters(message, parameters) {
- var list = OAuth.getParameterList(parameters);
- for (var i = 0; i < list.length; ++i) {
- OAuth.setParameter(message, list[i][0], list[i][1]);
- }
- }
-,
- /** Fill in parameters to help construct a request message.
- This function doesn't fill in every parameter.
- The accessor object should be like:
- {consumerKey:'foo', consumerSecret:'bar', accessorSecret:'nurn', token:'krelm', tokenSecret:'blah'}
- The accessorSecret property is optional.
- */
- completeRequest: function completeRequest(message, accessor) {
- if (message.method == null) {
- message.method = "GET";
- }
- var map = OAuth.getParameterMap(message.parameters);
- if (map.oauth_consumer_key == null) {
- OAuth.setParameter(message, "oauth_consumer_key", accessor.consumerKey || "");
- }
- if (map.oauth_token == null && accessor.token != null) {
- OAuth.setParameter(message, "oauth_token", accessor.token);
- }
- if (map.oauth_version == null) {
- OAuth.setParameter(message, "oauth_version", "1.0");
- }
- if (map.oauth_timestamp == null) {
- OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
- }
- if (map.oauth_nonce == null) {
- OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
- }
- OAuth.SignatureMethod.sign(message, accessor);
- }
-,
- setTimestampAndNonce: function setTimestampAndNonce(message) {
- OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
- OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
- }
-,
- addToURL: function addToURL(url, parameters) {
- newURL = url;
- if (parameters != null) {
- var toAdd = OAuth.formEncode(parameters);
- if (toAdd.length > 0) {
- var q = url.indexOf('?');
- if (q < 0) newURL += '?';
- else newURL += '&';
- newURL += toAdd;
- }
- }
- return newURL;
- }
-,
- /** Construct the value of the Authorization header for an HTTP request. */
- getAuthorizationHeader: function getAuthorizationHeader(realm, parameters) {
- var header = 'OAuth realm="' + OAuth.percentEncode(realm) + '"';
- var list = OAuth.getParameterList(parameters);
- for (var p = 0; p < list.length; ++p) {
- var parameter = list[p];
- var name = parameter[0];
- if (name.indexOf("oauth_") == 0) {
- header += ',' + OAuth.percentEncode(name) + '="' + OAuth.percentEncode(parameter[1]) + '"';
- }
- }
- return header;
- }
-,
- timestamp: function timestamp() {
- var d = new Date();
- return Math.floor(d.getTime()/1000);
- }
-,
- nonce: function nonce(length) {
- var chars = OAuth.nonce.CHARS;
- var result = "";
- for (var i = 0; i < length; ++i) {
- var rnum = Math.floor(Math.random() * chars.length);
- result += chars.substring(rnum, rnum+1);
- }
- return result;
- }
-});
-
-OAuth.nonce.CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
-
-/** Define a constructor function,
- without causing trouble to anyone who was using it as a namespace.
- That is, if parent[name] already existed and had properties,
- copy those properties into the new constructor.
- */
-OAuth.declareClass = function declareClass(parent, name, newConstructor) {
- var previous = parent[name];
- parent[name] = newConstructor;
- if (newConstructor != null && previous != null) {
- for (var key in previous) {
- if (key != "prototype") {
- newConstructor[key] = previous[key];
- }
- }
- }
- return newConstructor;
-}
-
-/** An abstract algorithm for signing messages. */
-OAuth.declareClass(OAuth, "SignatureMethod", function OAuthSignatureMethod(){});
-
-OAuth.setProperties(OAuth.SignatureMethod.prototype, // instance members
-{
- /** Add a signature to the message. */
- sign: function sign(message) {
- var baseString = OAuth.SignatureMethod.getBaseString(message);
- var signature = this.getSignature(baseString);
- OAuth.setParameter(message, "oauth_signature", signature);
- return signature; // just in case someone's interested
- }
-,
- /** Set the key string for signing. */
- initialize: function initialize(name, accessor) {
- var consumerSecret;
- if (accessor.accessorSecret != null
- && name.length > 9
- && name.substring(name.length-9) == "-Accessor")
- {
- consumerSecret = accessor.accessorSecret;
- } else {
- consumerSecret = accessor.consumerSecret;
- }
- this.key = OAuth.percentEncode(consumerSecret)
- +"&"+ OAuth.percentEncode(accessor.tokenSecret);
- }
-});
-
-/* SignatureMethod expects an accessor object to be like this:
- {tokenSecret: "lakjsdflkj...", consumerSecret: "QOUEWRI..", accessorSecret: "xcmvzc..."}
- The accessorSecret property is optional.
- */
-// Class members:
-OAuth.setProperties(OAuth.SignatureMethod, // class members
-{
- sign: function sign(message, accessor) {
- var name = OAuth.getParameterMap(message.parameters).oauth_signature_method;
- if (name == null || name == "") {
- name = "HMAC-SHA1";
- OAuth.setParameter(message, "oauth_signature_method", name);
- }
- OAuth.SignatureMethod.newMethod(name, accessor).sign(message);
- }
-,
- /** Instantiate a SignatureMethod for the given method name. */
- newMethod: function newMethod(name, accessor) {
- var impl = OAuth.SignatureMethod.REGISTERED[name];
- if (impl != null) {
- var method = new impl();
- method.initialize(name, accessor);
- return method;
- }
- var err = new Error("signature_method_rejected");
- var acceptable = "";
- for (var r in OAuth.SignatureMethod.REGISTERED) {
- if (acceptable != "") acceptable += '&';
- acceptable += OAuth.percentEncode(r);
- }
- err.oauth_acceptable_signature_methods = acceptable;
- throw err;
- }
-,
- /** A map from signature method name to constructor. */
- REGISTERED : {}
-,
- /** Subsequently, the given constructor will be used for the named methods.
- The constructor will be called with no parameters.
- The resulting object should usually implement getSignature(baseString).
- You can easily define such a constructor by calling makeSubclass, below.
- */
- registerMethodClass: function registerMethodClass(names, classConstructor) {
- for (var n = 0; n < names.length; ++n) {
- OAuth.SignatureMethod.REGISTERED[names[n]] = classConstructor;
- }
- }
-,
- /** Create a subclass of OAuth.SignatureMethod, with the given getSignature function. */
- makeSubclass: function makeSubclass(getSignatureFunction) {
- var superClass = OAuth.SignatureMethod;
- var subClass = function() {
- superClass.call(this);
- };
- subClass.prototype = new superClass();
- // Delete instance variables from prototype:
- // delete subclass.prototype... There aren't any.
- subClass.prototype.getSignature = getSignatureFunction;
- subClass.prototype.constructor = subClass;
- return subClass;
- }
-,
- getBaseString: function getBaseString(message) {
- var URL = message.action;
- var q = URL.indexOf('?');
- var parameters;
- if (q < 0) {
- parameters = message.parameters;
- } else {
- // Combine the URL query string with the other parameters:
- parameters = OAuth.decodeForm(URL.substring(q + 1));
- var toAdd = OAuth.getParameterList(message.parameters);
- for (var a = 0; a < toAdd.length; ++a) {
- parameters.push(toAdd[a]);
- }
- }
- return OAuth.percentEncode(message.method.toUpperCase())
- +'&'+ OAuth.percentEncode(OAuth.SignatureMethod.normalizeUrl(URL))
- +'&'+ OAuth.percentEncode(OAuth.SignatureMethod.normalizeParameters(parameters));
- }
-,
- normalizeUrl: function normalizeUrl(url) {
- var uri = OAuth.SignatureMethod.parseUri(url);
- var scheme = uri.protocol.toLowerCase();
- var authority = uri.authority.toLowerCase();
- var dropPort = (scheme == "http" && uri.port == 80)
- || (scheme == "https" && uri.port == 443);
- if (dropPort) {
- // find the last : in the authority
- var index = authority.lastIndexOf(":");
- if (index >= 0) {
- authority = authority.substring(0, index);
- }
- }
- var path = uri.path;
- if (!path) {
- path = "/"; // conforms to RFC 2616 section 3.2.2
- }
- // we know that there is no query and no fragment here.
- return scheme + "://" + authority + path;
- }
-,
- parseUri: function parseUri (str) {
- /* This function was adapted from parseUri 1.2.1
- http://stevenlevithan.com/demo/parseuri/js/assets/parseuri.js
- */
- var o = {key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
- parser: {strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ }};
- var m = o.parser.strict.exec(str);
- var uri = {};
- var i = 14;
- while (i--) uri[o.key[i]] = m[i] || "";
- return uri;
- }
-,
- normalizeParameters: function normalizeParameters(parameters) {
- if (parameters == null) {
- return "";
- }
- var list = OAuth.getParameterList(parameters);
- var sortable = [];
- for (var p = 0; p < list.length; ++p) {
- var nvp = list[p];
- if (nvp[0] != "oauth_signature") {
- sortable.push([ OAuth.percentEncode(nvp[0])
- + " " // because it comes before any character that can appear in a percentEncoded string.
- + OAuth.percentEncode(nvp[1])
- , nvp]);
- }
- }
- sortable.sort(function(a,b) {
- if (a[0] < b[0]) return -1;
- if (a[0] > b[0]) return 1;
- return 0;
- });
- var sorted = [];
- for (var s = 0; s < sortable.length; ++s) {
- sorted.push(sortable[s][1]);
- }
- return OAuth.formEncode(sorted);
- }
-});
-
-OAuth.SignatureMethod.registerMethodClass(["PLAINTEXT", "PLAINTEXT-Accessor"],
- OAuth.SignatureMethod.makeSubclass(
- function getSignature(baseString) {
- return this.key;
- }
- ));
-
-OAuth.SignatureMethod.registerMethodClass(["HMAC-SHA1", "HMAC-SHA1-Accessor"],
- OAuth.SignatureMethod.makeSubclass(
- function getSignature(baseString) {
- b64pad = '=';
- var signature = b64_hmac_sha1(this.key, baseString);
- return signature;
- }
- ));
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/script/replicator_db_inc.js
----------------------------------------------------------------------
diff --git a/share/www/script/replicator_db_inc.js b/share/www/script/replicator_db_inc.js
deleted file mode 100644
index 23f8587..0000000
--- a/share/www/script/replicator_db_inc.js
+++ /dev/null
@@ -1,96 +0,0 @@
-// 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.
-
-var replicator_db = {};
-replicator_db.wait_rep_doc = 500; // number of millisecs to wait after saving a Rep Doc
-replicator_db.dbA = new CouchDB("test_suite_rep_db_a", {"X-Couch-Full-Commit":"false"});
-replicator_db.dbB = new CouchDB("test_suite_rep_db_b", {"X-Couch-Full-Commit":"false"});
-replicator_db.repDb = new CouchDB("test_suite_rep_db", {"X-Couch-Full-Commit":"false"});
-replicator_db.usersDb = new CouchDB("test_suite_auth", {"X-Couch-Full-Commit":"false"});
-
-replicator_db.docs1 = [
- {
- _id: "foo1",
- value: 11
- },
- {
- _id: "foo2",
- value: 22
- },
- {
- _id: "foo3",
- value: 33
- }
-];
-
-replicator_db.waitForRep = function waitForSeq(repDb, repDoc, state) {
- var newRep,
- t0 = new Date(),
- t1,
- ms = 3000;
-
- do {
- newRep = repDb.open(repDoc._id);
- t1 = new Date();
- } while (((t1 - t0) <= ms) && newRep._replication_state !== state);
-}
-
-replicator_db.waitForSeq = function waitForSeq(sourceDb, targetDb) {
- var targetSeq,
- sourceSeq = sourceDb.info().update_seq,
- t0 = new Date(),
- t1,
- ms = 3000;
-
- do {
- targetSeq = targetDb.info().update_seq;
- t1 = new Date();
- } while (((t1 - t0) <= ms) && targetSeq < sourceSeq);
-}
-
-replicator_db.waitForDocPos = function waitForDocPos(db, docId, pos) {
- var doc, curPos, t0, t1,
- maxWait = 3000;
-
- doc = db.open(docId);
- curPos = Number(doc._rev.split("-", 1));
- t0 = t1 = new Date();
-
- while ((curPos < pos) && ((t1 - t0) <= maxWait)) {
- doc = db.open(docId);
- curPos = Number(doc._rev.split("-", 1));
- t1 = new Date();
- }
-
- return doc;
-}
-
-replicator_db.wait = function wait(ms) {
- var t0 = new Date(), t1;
- do {
- CouchDB.request("GET", "/");
- t1 = new Date();
- } while ((t1 - t0) <= ms);
-}
-
-
-replicator_db.populate_db = function populate_db(db, docs) {
- if (db.name !== replicator_db.usersDb.name) {
- db.deleteDb();
- db.createDb();
- }
- for (var i = 0; i < docs.length; i++) {
- var d = docs[i];
- delete d._rev;
- T(db.save(d).ok);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/script/sha1.js
----------------------------------------------------------------------
diff --git a/share/www/script/sha1.js b/share/www/script/sha1.js
deleted file mode 100644
index ee73a63..0000000
--- a/share/www/script/sha1.js
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
- * in FIPS PUB 180-1
- * Version 2.1a Copyright Paul Johnston 2000 - 2002.
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
- * Distributed under the BSD License
- * See http://pajhome.org.uk/crypt/md5 for details.
- */
-
-/*
- * Configurable variables. You may need to tweak these to be compatible with
- * the server-side, but the defaults work in most cases.
- */
-var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
-var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */
-var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
-
-/*
- * These are the functions you'll usually want to call
- * They take string arguments and return either hex or base-64 encoded strings
- */
-function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
-function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
-function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
-function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
-function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
-function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
-
-/*
- * Perform a simple self-test to see if the VM is working
- */
-function sha1_vm_test()
-{
- return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
-}
-
-/*
- * Calculate the SHA-1 of an array of big-endian words, and a bit length
- */
-function core_sha1(x, len)
-{
- /* append padding */
- x[len >> 5] |= 0x80 << (24 - len % 32);
- x[((len + 64 >> 9) << 4) + 15] = len;
-
- var w = Array(80);
- var a = 1732584193;
- var b = -271733879;
- var c = -1732584194;
- var d = 271733878;
- var e = -1009589776;
-
- for(var i = 0; i < x.length; i += 16)
- {
- var olda = a;
- var oldb = b;
- var oldc = c;
- var oldd = d;
- var olde = e;
-
- for(var j = 0; j < 80; j++)
- {
- if(j < 16) w[j] = x[i + j];
- else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
- var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
- safe_add(safe_add(e, w[j]), sha1_kt(j)));
- e = d;
- d = c;
- c = rol(b, 30);
- b = a;
- a = t;
- }
-
- a = safe_add(a, olda);
- b = safe_add(b, oldb);
- c = safe_add(c, oldc);
- d = safe_add(d, oldd);
- e = safe_add(e, olde);
- }
- return Array(a, b, c, d, e);
-
-}
-
-/*
- * Perform the appropriate triplet combination function for the current
- * iteration
- */
-function sha1_ft(t, b, c, d)
-{
- if(t < 20) return (b & c) | ((~b) & d);
- if(t < 40) return b ^ c ^ d;
- if(t < 60) return (b & c) | (b & d) | (c & d);
- return b ^ c ^ d;
-}
-
-/*
- * Determine the appropriate additive constant for the current iteration
- */
-function sha1_kt(t)
-{
- return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
- (t < 60) ? -1894007588 : -899497514;
-}
-
-/*
- * Calculate the HMAC-SHA1 of a key and some data
- */
-function core_hmac_sha1(key, data)
-{
- var bkey = str2binb(key);
- if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
-
- var ipad = Array(16), opad = Array(16);
- for(var i = 0; i < 16; i++)
- {
- ipad[i] = bkey[i] ^ 0x36363636;
- opad[i] = bkey[i] ^ 0x5C5C5C5C;
- }
-
- var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
- return core_sha1(opad.concat(hash), 512 + 160);
-}
-
-/*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
-function safe_add(x, y)
-{
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
-}
-
-/*
- * Bitwise rotate a 32-bit number to the left.
- */
-function rol(num, cnt)
-{
- return (num << cnt) | (num >>> (32 - cnt));
-}
-
-/*
- * Convert an 8-bit or 16-bit string to an array of big-endian words
- * In 8-bit function, characters >255 have their hi-byte silently ignored.
- */
-function str2binb(str)
-{
- var bin = Array();
- var mask = (1 << chrsz) - 1;
- for(var i = 0; i < str.length * chrsz; i += chrsz)
- bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
- return bin;
-}
-
-/*
- * Convert an array of big-endian words to a string
- */
-function binb2str(bin)
-{
- var str = "";
- var mask = (1 << chrsz) - 1;
- for(var i = 0; i < bin.length * 32; i += chrsz)
- str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
- return str;
-}
-
-/*
- * Convert an array of big-endian words to a hex string.
- */
-function binb2hex(binarray)
-{
- var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
- var str = "";
- for(var i = 0; i < binarray.length * 4; i++)
- {
- str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
- hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
- }
- return str;
-}
-
-/*
- * Convert an array of big-endian words to a base-64 string
- */
-function binb2b64(binarray)
-{
- var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- var str = "";
- for(var i = 0; i < binarray.length * 4; i += 3)
- {
- var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
- | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
- | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
- for(var j = 0; j < 4; j++)
- {
- if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
- else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
- }
- }
- return str;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/session.html
----------------------------------------------------------------------
diff --git a/share/www/session.html b/share/www/session.html
deleted file mode 100644
index 922f738..0000000
--- a/share/www/session.html
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE html>
-<!--
-
-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.
-
--->
-<html lang="en">
- <head>
- <title>Session</title>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
- <link rel="stylesheet" href="style/layout.css?0.11.0" type="text/css">
- <script src="script/json2.js"></script>
- <script src="script/sha1.js"></script>
- <script src="script/jquery.js"></script>
- <script src="script/jquery.couch.js"></script>
- <script src="script/jquery.dialog.js"></script>
- <script src="script/futon.js"></script>
- <script src="script/futon.browse.js"></script>
- <script src="script/futon.format.js"></script>
- <script>
- $(function() {
- var ret, reason, q = window.location.search, qps = q.split("&");
- $.map(qps, function(qp) {
- var m = qp.match(/return=(.*)/);
- if (m) {
- ret = decodeURIComponent(m[1]);
- }
- m = qp.match(/reason=(.*)/);
- if (m) {
- reason = $.futon.escape(decodeURIComponent(m[1]));
- }
- });
- if (reason) {
- $("#aboutSession").append('<p>The application says: <em>'+reason+'</em></p>');
- }
- if (ret) {
- $("#aboutSession").append($('<p>Once you are logged in, click this link to return to your application: </p>').append($("<a></a>").attr("href", ret).text(ret)));
- // todo this needs to look different if you are already logged in
- // a note about you are logged in but you can't access this
- }
- // do the sidebar but in the middle without the sidebar
- $.futon.storage.set("sidebar", "hidden");
- setTimeout(function() {
- var ctx = $$("#userCtx").userCtx;
- $.futon.storage.set("sidebar", "show");
- if (ctx && ctx.name) {
- $("#aboutSession").append("<p>It looks like you are logged in, maybe you don't have access to that url.</p>");
- }
- },100);
- });
- </script>
- </head>
- <body>
- <div id="wrap">
- <h1><a href="index.html">Overview</a>
- <strong>Session</strong></h1>
- <div id="content">
- <h2>Establish or Modify Your Session</h2>
- <div id="loginSignup">
- <div id="aboutSession"></div>
- <span id="userCtx">
- <span class="loggedout">
- <a href="#" class="signup">Signup</a> or <a href="#" class="login">Login</a>
- </span>
- <span class="loggedin">
- Welcome <a class="name">?</a>!
- <br/>
- <a href="#" class="logout">Logout</a>
- </span>
- <span class="loggedinadmin">
- Welcome <a class="name">?</a>!
- <br/>
- <a href="#" class="createadmin">Setup more admins</a> or
- <a href="#" class="logout">Logout</a>
- </span>
- <span class="adminparty">
- Welcome to Admin Party!
- <br/>
- Everyone is admin. <a href="#" class="createadmin">Fix this</a>
- </span>
- </span>
- </div>
- </div>
-
- </div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/spec/couch_js_class_methods_spec.js
----------------------------------------------------------------------
diff --git a/share/www/spec/couch_js_class_methods_spec.js b/share/www/spec/couch_js_class_methods_spec.js
deleted file mode 100644
index fc8db36..0000000
--- a/share/www/spec/couch_js_class_methods_spec.js
+++ /dev/null
@@ -1,401 +0,0 @@
-// 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.
-
-// Specs for couch.js lines 313-470
-
-describe 'CouchDB class'
- describe 'session stuff'
- before
- useTestUserDb();
- end
-
- after
- useOldUserDb();
- end
-
- before_each
- userDoc = users_db.save(CouchDB.prepareUserDoc({name: "Gaius Baltar", roles: ["president"]}, "secretpass"));
- end
-
- after_each
- users_db.deleteDoc({_id : userDoc.id, _rev : userDoc.rev})
- end
-
- describe '.login'
- it 'should return ok true'
- CouchDB.login("Gaius Baltar", "secretpass").ok.should.be_true
- end
-
- it 'should return the name of the logged in user'
- CouchDB.login("Gaius Baltar", "secretpass").name.should.eql "Gaius Baltar"
- end
-
- it 'should return the roles of the logged in user'
- CouchDB.login("Gaius Baltar", "secretpass").roles.should.eql ["president"]
- end
-
- it 'should post _session'
- CouchDB.should.receive("request", "once").with_args("POST", "/_session")
- CouchDB.login("Gaius Baltar", "secretpass");
- end
-
- it 'should create a session'
- CouchDB.login("Gaius Baltar", "secretpass");
- CouchDB.session().userCtx.name.should.eql "Gaius Baltar"
- end
- end
-
- describe '.logout'
- before_each
- CouchDB.login("Gaius Baltar", "secretpass");
- end
-
- it 'should return ok true'
- CouchDB.logout().ok.should.be_true
- end
-
- it 'should delete _session'
- CouchDB.should.receive("request", "once").with_args("DELETE", "/_session")
- CouchDB.logout();
- end
-
- it 'should result in an invalid session'
- CouchDB.logout();
- CouchDB.session().name.should.be_null
- end
- end
-
- describe '.session'
- before_each
- CouchDB.login("Gaius Baltar", "secretpass");
- end
-
- it 'should return ok true'
- CouchDB.session().ok.should.be_true
- end
-
- it 'should return the users name'
- CouchDB.session().userCtx.name.should.eql "Gaius Baltar"
- end
-
- it 'should return the users roles'
- CouchDB.session().userCtx.roles.should.eql ["president"]
- end
-
- it 'should return the name of the authentication db'
- CouchDB.session().info.authentication_db.should.eql "spec_users_db"
- end
-
- it 'should return the active authentication handler'
- CouchDB.session().info.authenticated.should.eql "cookie"
- end
- end
- end
-
- describe 'db stuff'
- before_each
- db = new CouchDB("spec_db", {"X-Couch-Full-Commit":"false"});
- db.createDb();
- end
-
- after_each
- db.deleteDb();
- end
-
- describe '.prepareUserDoc'
- before_each
- userDoc = CouchDB.prepareUserDoc({name: "Laura Roslin"}, "secretpass");
- end
-
- it 'should return the users name'
- userDoc.name.should.eql "Laura Roslin"
- end
-
- it 'should prefix the id with the CouchDB user_prefix'
- userDoc._id.should.eql "org.couchdb.user:Laura Roslin"
- end
-
- it 'should return the users roles'
- var userDocWithRoles = CouchDB.prepareUserDoc({name: "William Adama", roles: ["admiral", "commander"]}, "secretpass")
- userDocWithRoles.roles.should.eql ["admiral", "commander"]
- end
-
- it 'should return the hashed password'
- userDoc.password_sha.length.should.be_at_least 30
- userDoc.password_sha.should.be_a String
- end
- end
-
- describe '.allDbs'
- it 'should get _all_dbs'
- CouchDB.should.receive("request", "once").with_args("GET", "/_all_dbs");
- CouchDB.allDbs();
- end
-
- it 'should return an array that includes a created database'
- temp_db = new CouchDB("temp_spec_db", {"X-Couch-Full-Commit":"false"});
- temp_db.createDb();
- CouchDB.allDbs().should.include("temp_spec_db");
- temp_db.deleteDb();
- end
-
- it 'should return an array that does not include a database that does not exist'
- CouchDB.allDbs().should.not.include("not_existing_temp_spec_db");
- end
- end
-
- describe '.allDesignDocs'
- it 'should return the total number of documents'
- CouchDB.allDesignDocs().spec_db.total_rows.should.eql 0
- db.save({'type':'battlestar', 'name':'galactica'});
- CouchDB.allDesignDocs().spec_db.total_rows.should.eql 1
- end
-
- it 'should return undefined when the db does not exist'
- CouchDB.allDesignDocs().non_existing_db.should.be_undefined
- end
-
- it 'should return no documents when there are no design documents'
- CouchDB.allDesignDocs().spec_db.rows.should.eql []
- end
-
- it 'should return all design documents'
- var designDoc = {
- "views" : {
- "people" : {
- "map" : "function(doc) { emit(doc._id, doc); }"
- }
- },
- "_id" : "_design/spec_db"
- };
- db.save(designDoc);
-
- var allDesignDocs = CouchDB.allDesignDocs();
- allDesignDocs.spec_db.rows[0].id.should.eql "_design/spec_db"
- allDesignDocs.spec_db.rows[0].key.should.eql "_design/spec_db"
- allDesignDocs.spec_db.rows[0].value.rev.length.should.be_at_least 30
- end
- end
-
- describe '.getVersion'
- it 'should get the CouchDB version'
- CouchDB.should.receive("request", "once").with_args("GET", "/")
- CouchDB.getVersion();
- end
-
- it 'should return the CouchDB version'
- CouchDB.getVersion().should_match /^\d\d?\.\d\d?\.\d\d?.*/
- end
- end
-
- describe '.replicate'
- before_each
- db2 = new CouchDB("spec_db_2", {"X-Couch-Full-Commit":"false"});
- db2.createDb();
- host = window.location.protocol + "//" + window.location.host ;
- end
-
- after_each
- db2.deleteDb();
- end
-
- it 'should return no_changes true when there are no changes between the dbs'
- CouchDB.replicate(host + db.uri, host + db2.uri).no_changes.should.be_true
- end
-
- it 'should return the session ID'
- db.save({'type':'battlestar', 'name':'galactica'});
- CouchDB.replicate(host + db.uri, host + db2.uri).session_id.length.should.be_at_least 30
- end
-
- it 'should return source_last_seq'
- db.save({'type':'battlestar', 'name':'galactica'});
- db.save({'type':'battlestar', 'name':'pegasus'});
-
- CouchDB.replicate(host + db.uri, host + db2.uri).source_last_seq.should.eql 2
- end
-
- it 'should return the replication history'
- db.save({'type':'battlestar', 'name':'galactica'});
- db.save({'type':'battlestar', 'name':'pegasus'});
-
- var result = CouchDB.replicate(host + db.uri, host + db2.uri);
- result.history[0].docs_written.should.eql 2
- result.history[0].start_last_seq.should.eql 0
- end
-
- it 'should pass through replication options'
- db.save({'type':'battlestar', 'name':'galactica'});
- db2.deleteDb();
- -{CouchDB.replicate(host + db.uri, host + db2.uri)}.should.throw_error
- var result = CouchDB.replicate(host + db.uri, host + db2.uri, {"body" : {"create_target":true}});
-
- result.ok.should.eql true
- result.history[0].docs_written.should.eql 1
- db2.info().db_name.should.eql "spec_db_2"
- end
- end
-
- describe '.newXhr'
- it 'should return a XMLHTTPRequest'
- CouchDB.newXhr().should.have_prop 'readyState'
- CouchDB.newXhr().should.have_prop 'responseText'
- CouchDB.newXhr().should.have_prop 'status'
- end
- end
-
- describe '.request'
- it 'should return a XMLHttpRequest'
- var req = CouchDB.request("GET", '/');
- req.should.include "readyState"
- req.should.include "responseText"
- req.should.include "statusText"
- end
-
- it 'should pass through the options headers'
- var xhr = CouchDB.newXhr();
- stub(CouchDB, 'newXhr').and_return(xhr);
-
- xhr.should.receive("setRequestHeader", "once").with_args("X-Couch-Full-Commit", "true")
- CouchDB.request("GET", "/", {'headers': {"X-Couch-Full-Commit":"true"}});
- end
-
- it 'should pass through the options body'
- var xhr = CouchDB.newXhr();
- stub(CouchDB, 'newXhr').and_return(xhr);
-
- xhr.should.receive("send", "once").with_args({"body_key":"body_value"})
- CouchDB.request("GET", "/", {'body': {"body_key":"body_value"}});
- end
-
- it 'should prepend the urlPrefix to the uri'
- var oldPrefix = CouchDB.urlPrefix;
- CouchDB.urlPrefix = "/_utils";
-
- var xhr = CouchDB.newXhr();
- stub(CouchDB, 'newXhr').and_return(xhr);
-
- xhr.should.receive("open", "once").with_args("GET", "/_utils/", false)
- CouchDB.request("GET", "/", {'headers': {"X-Couch-Full-Commit":"true"}});
-
- CouchDB.urlPrefix = oldPrefix;
- end
- end
-
- describe '.requestStats'
- it 'should get the stats for specified path'
- var stats = CouchDB.requestStats(['couchdb', 'open_databases'], null);
- stats.description.should.eql 'number of open databases'
- stats.current.should.be_a Number
- end
-
- it 'should add flush true to the request when there is a test argument'
- CouchDB.should.receive("request", "once").with_args("GET", "/_stats/httpd/requests?flush=true")
- CouchDB.requestStats(['couchdb', 'httpd', 'requests'], 'test');
- end
-
- it 'should still work when there is a test argument'
- var stats = CouchDB.requestStats(['couchdb', 'httpd_status_codes', 200], 'test');
- stats.description.should.eql 'number of HTTP 200 OK responses'
- stats.sum.should.be_a Number
- end
- end
-
- describe '.newUuids'
- after_each
- CouchDB.uuids_cache = [];
- end
-
- it 'should return the specified amount of uuids'
- var uuids = CouchDB.newUuids(45);
- uuids.should.have_length 45
- end
-
- it 'should return an array with uuids'
- var uuids = CouchDB.newUuids(1);
- uuids[0].should.be_a String
- uuids[0].should.have_length 32
- end
-
- it 'should leave the uuids_cache with 100 uuids when theres no buffer size specified'
- CouchDB.newUuids(23);
- CouchDB.uuids_cache.should.have_length 100
- end
-
- it 'should leave the uuids_cache with the specified buffer size'
- CouchDB.newUuids(23, 150);
- CouchDB.uuids_cache.should.have_length 150
- end
-
- it 'should get the uuids from the uuids_cache when there are enough uuids in there'
- CouchDB.newUuids(10);
- CouchDB.newUuids(25);
- CouchDB.uuids_cache.should.have_length 75
- end
-
- it 'should create new uuids and add as many as specified to the uuids_cache when there are not enough uuids in the cache'
- CouchDB.newUuids(10);
- CouchDB.newUuids(125, 60);
- CouchDB.uuids_cache.should.have_length 160
- end
- end
-
- describe '.maybeThrowError'
- it 'should throw an error when the request has status 404'
- var req = CouchDB.request("GET", "/nonexisting_db");
- -{CouchDB.maybeThrowError(req)}.should.throw_error
- end
-
- it 'should throw an error when the request has status 412'
- var req = CouchDB.request("PUT", "/spec_db");
- -{CouchDB.maybeThrowError(req)}.should.throw_error
- end
-
- it 'should throw an error when the request has status 405'
- var req = CouchDB.request("DELETE", "/_utils");
- -{CouchDB.maybeThrowError(req)}.should.throw_error
- end
-
- it 'should throw the responseText of the request'
- var req = CouchDB.request("GET", "/nonexisting_db");
- try {
- CouchDB.maybeThrowError(req)
- } catch(e) {
- e.error.should.eql JSON.parse(req.responseText).error
- e.reason.should.eql JSON.parse(req.responseText).reason
- }
- end
-
- it 'should throw an unknown error when the responseText is invalid json'
- mock_request().and_return("invalid json...", "application/json", 404, {})
- try {
- CouchDB.maybeThrowError(CouchDB.newXhr())
- } catch(e) {
- e.error.should.eql "unknown"
- e.reason.should.eql "invalid json..."
- }
- end
- end
-
- describe '.params'
- it 'should turn a json object into a http params string'
- var params = CouchDB.params({"president":"laura", "cag":"lee"})
- params.should.eql "president=laura&cag=lee"
- end
-
- it 'should return a blank string when the object is empty'
- var params = CouchDB.params({})
- params.should.eql ""
- end
- end
- end
-end
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/spec/couch_js_instance_methods_1_spec.js
----------------------------------------------------------------------
diff --git a/share/www/spec/couch_js_instance_methods_1_spec.js b/share/www/spec/couch_js_instance_methods_1_spec.js
deleted file mode 100644
index 7f23bd2..0000000
--- a/share/www/spec/couch_js_instance_methods_1_spec.js
+++ /dev/null
@@ -1,311 +0,0 @@
-// 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.
-
-// Specs for couch.js lines 1-130
-
-describe 'CouchDB instance'
- before_each
- db = new CouchDB("spec_db", {"X-Couch-Full-Commit":"false"});
- end
-
- describe '.request'
- before_each
- db.createDb();
- end
-
- after_each
- db.deleteDb();
- end
-
- it 'should return a XMLHttpRequest'
- var req = db.request("GET", "/spec_db");
- req.should.include "readyState"
- req.should.include "responseText"
- req.should.include "statusText"
- // in Safari a XMLHttpRequest is actually a XMLHttpRequestConstructor,
- // otherwise we could just do:
- // req.should.be_a XMLHttpRequest
- end
-
- it 'should set the options the CouchDB instance has got as httpHeaders'
- CouchDB.should.receive("request", "once").with_args("GET", "/spec_db", {headers: {"X-Couch-Full-Commit": "false"}})
- db.request("GET", "/spec_db");
- end
-
- it 'should pass through the options'
- CouchDB.should.receive("request", "once").with_args("GET", "/spec_db", {"X-Couch-Persist": "true", headers: {"X-Couch-Full-Commit": "false"}})
- db.request("GET", "/spec_db", {"X-Couch-Persist":"true"});
- end
- end
-
- describe '.createDb'
- after_each
- db.deleteDb();
- end
-
- it 'should create the db'
- db.createDb();
- db.last_req.status.should.eql 201
- end
-
- it 'should return the ok true'
- db.createDb().should.eql {"ok" : true}
- end
-
- it 'should result in a created db'
- db.createDb();
- try{
- db.createDb();
- } catch(e) {
- e.error.should.eql "file_exists"
- }
- end
-
- it 'should have create a db with update sequence 0'
- db.createDb();
- db.info().update_seq.should.eql 0
- end
- end
-
- describe '.deleteDb'
- before_each
- db.createDb();
- end
-
- it 'should delete the db'
- db.deleteDb();
- db.last_req.status.should.eql 200
- end
-
- it 'should return the responseText of the request'
- db.deleteDb().should.eql {"ok" : true}
- end
-
- it 'should result in a deleted db'
- db.deleteDb();
- db.deleteDb();
- db.last_req.status.should.eql 404
- end
- end
-
- describe 'document methods'
- before_each
- doc = {"Name" : "Kara Thrace", "Callsign" : "Starbuck"};
- db.createDb();
- end
-
- after_each
- db.deleteDb();
- end
-
- describe '.save'
- it 'should save the document'
- db.save(doc);
- db.last_req.status.should.eql 201
- end
-
- it 'should return ok true'
- db.save(doc).ok.should.be_true
- end
-
- it 'should return ID and revision of the document'
- var response = db.save(doc);
- response.id.should.be_a String
- response.id.should.have_length 32
- response.rev.should.be_a String
- response.rev.length.should.be_at_least 30
- end
-
- it 'should result in a saved document with generated ID'
- var response = db.save(doc);
- var saved_doc = db.open(response.id);
- saved_doc.Name.should.eql "Kara Thrace"
- saved_doc.Callsign.should.eql "Starbuck"
- end
-
- it 'should save the document with the specified ID'
- doc._id = "123";
- var response = db.save(doc);
- response.id.should.eql "123"
- end
-
- it 'should pass through the options'
- doc._id = "123";
- CouchDB.should.receive("request", "once").with_args("PUT", "/spec_db/123?batch=ok")
- db.save(doc, {"batch" : "ok"});
- end
- end
-
- describe '.open'
- before_each
- doc._id = "123";
- db.save(doc);
- end
-
- it 'should open the document'
- db.open("123").should.eql doc
- end
-
- it 'should return null when there is no document with the given ID'
- db.open("non_existing").should.be_null
- end
-
- it 'should pass through the options'
- CouchDB.should.receive("request", "once").with_args("GET", "/spec_db/123?revs=true")
- db.open("123", {"revs" : "true"});
- end
- end
-
- describe '.deleteDoc'
- before_each
- doc._id = "123";
- saved_doc = db.save(doc);
- delete_response = db.deleteDoc({_id : "123", _rev : saved_doc.rev});
- delete_last_req = db.last_req;
- db.open("123");
- end
-
- it 'should send a successful request'
- delete_last_req.status.should.eql 200
- end
-
- it 'should result in a deleted document'
- db.open("123").should.be_null
- end
-
- it 'should return ok true, the ID and the revision of the deleted document'
- delete_response.ok.should.be_true
- delete_response.id.should.eql "123"
- delete_response.rev.should.be_a String
- delete_response.rev.length.should.be_at_least 30
- end
-
- it 'should mark the document as deleted'
- var responseText = db.request("GET", "/spec_db/123").responseText;
- JSON.parse(responseText).should.eql {"error":"not_found","reason":"deleted"}
- end
-
- it 'should record the revision in the deleted document'
- var responseText = db.request("GET", "/spec_db/123?rev=" + delete_response.rev).responseText;
- var deleted_doc = JSON.parse(responseText);
- deleted_doc._rev.should.eql delete_response.rev
- deleted_doc._id.should.eql delete_response.id
- deleted_doc._deleted.should.be_true
- end
- end
-
- describe '.deleteDocAttachment'
- before_each
- doc._id = "123";
- doc._attachments = {
- "friend.txt" : {
- "content_type": "text\/plain",
- // base64 encoded
- "data": "TGVlIEFkYW1hIGlzIGEgZm9ybWVyIENvbG9uaWFsIEZsZWV0IFJlc2VydmUgb2ZmaWNlci4="
- }
- };
- saved_doc = db.save(doc);
- end
-
- it 'should be executed on a document with attachment'
- db.open("123")._attachments.should.include "friend.txt"
- db.open("123")._attachments["friend.txt"].stub.should.be_true
- end
-
- describe 'after delete'
- before_each
- delete_response = db.deleteDocAttachment({_id : "123", _rev : saved_doc.rev}, "friend.txt");
- db.open("123");
- end
-
- it 'should send a successful request'
- db.last_req.status.should.eql 200
- end
-
- it 'should leave the document untouched'
- db.open("123").Callsign.should.eql "Starbuck"
- end
-
- it 'should result in a deleted document attachment'
- db.open("123").should.not.include "_attachments"
- end
-
- it 'should record the revision in the document whose attachment has been deleted'
- var responseText = db.request("GET", "/spec_db/123?rev=" + delete_response.rev).responseText;
- var deleted_doc = JSON.parse(responseText);
- deleted_doc._rev.should.eql delete_response.rev
- deleted_doc._id.should.eql delete_response.id
- end
-
- it 'should return ok true, the ID and the revision of the document whose attachment has been deleted'
- delete_response.ok.should.be_true
- delete_response.id.should.eql "123"
- delete_response.should.have_property 'rev'
- end
- end
- end
-
- describe '.bulkSave'
- before_each
- doc = {"Name" : "Kara Thrace", "Callsign" : "Starbuck"};
- doc2 = {"Name" : "Karl C. Agathon", "Callsign" : "Helo"};
- doc3 = {"Name" : "Sharon Valerii", "Callsign" : "Boomer"};
- docs = [doc, doc2, doc3];
- end
-
- it 'should save the documents'
- db.bulkSave(docs);
- db.last_req.status.should.eql 201
- end
-
- it 'should return ID and revision of the documents'
- var response = db.bulkSave(docs);
- response[0].id.should.be_a String
- response[0].id.should.have_length 32
- response[0].rev.should.be_a String
- response[0].rev.length.should.be_at_least 30
- response[1].id.should.be_a String
- response[1].id.should.have_length 32
- response[1].rev.should.be_a String
- response[1].rev.length.should.be_at_least 30
- response[2].id.should.be_a String
- response[2].id.should.have_length 32
- response[2].rev.should.be_a String
- response[2].rev.length.should.be_at_least 30
- end
-
- it 'should result in saved documents'
- var response = db.bulkSave(docs);
- db.open(response[0].id).Name.should.eql "Kara Thrace"
- db.open(response[1].id).Name.should.eql "Karl C. Agathon"
- db.open(response[2].id).Name.should.eql "Sharon Valerii"
- end
-
- it 'should save the document with specified IDs'
- doc._id = "123";
- doc2._id = "456";
- docs = [doc, doc2, doc3];
- var response = db.bulkSave(docs);
- response[0].id.should.eql "123"
- response[1].id.should.eql "456"
- response[2].id.should.have_length 32
- end
-
- it 'should pass through the options'
- doc._id = "123";
- docs = [doc];
- CouchDB.should.receive("request", "once").with_args("POST", "/spec_db/_bulk_docs", {body: '{"docs":[{"Name":"Kara Thrace","Callsign":"Starbuck","_id":"123"}],"batch":"ok"}'})
- db.bulkSave(docs, {"batch" : "ok"});
- end
- end
- end
-end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/spec/couch_js_instance_methods_2_spec.js
----------------------------------------------------------------------
diff --git a/share/www/spec/couch_js_instance_methods_2_spec.js b/share/www/spec/couch_js_instance_methods_2_spec.js
deleted file mode 100644
index 76df636..0000000
--- a/share/www/spec/couch_js_instance_methods_2_spec.js
+++ /dev/null
@@ -1,246 +0,0 @@
-// 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.
-
-// Specs for couch.js lines 132-199
-
-describe 'CouchDB instance'
- before_each
- db = new CouchDB("spec_db", {"X-Couch-Full-Commit":"false"});
- db.createDb();
- end
-
- after_each
- db.deleteDb();
- end
-
- describe '.ensureFullCommit'
- it 'should return ok true'
- db.ensureFullCommit().ok.should.be_true
- end
-
- it 'should return the instance start time'
- db.ensureFullCommit().instance_start_time.should.have_length 16
- end
-
- it 'should post _ensure_full_commit to the db'
- db.should.receive("request", "once").with_args("POST", "/spec_db/_ensure_full_commit")
- db.ensureFullCommit();
- end
- end
-
- describe '.query'
- before_each
- db.save({"Name" : "Cally Tyrol", "job" : "deckhand", "_id" : "789"});
- db.save({"Name" : "Felix Gaeta", "job" : "officer", "_id" : "123"});
- db.save({"Name" : "Samuel T. Anders", "job" : "pilot", "_id" : "456"});
- map_function = "function(doc) { emit(doc._id, 1); }";
- reduce_function = "function(key, values, rereduce) { return sum(values); }";
- end
-
- it 'should apply the map function'
- var result = db.query(map_function);
-
- result.rows.should.have_length 3
- result.rows[0].id.should.eql "123"
- result.rows[0].key.should.eql "123"
- result.rows[0].value.should.eql 1
- result.rows[1].id.should.eql "456"
- result.rows[1].key.should.eql "456"
- result.rows[1].value.should.eql 1
- result.rows[2].id.should.eql "789"
- result.rows[2].key.should.eql "789"
- result.rows[2].value.should.eql 1
- end
-
- it 'should apply the reduce function'
- var result = db.query(map_function, reduce_function);
-
- result.rows.should.have_length 1
- result.rows[0].key.should.be_null
- result.rows[0].value.should_eql 3
- end
-
- it 'should pass through the options'
- var result = db.query(map_function, null, {"startkey":"456"});
-
- result.rows.should.have_length 2
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.should.eql 1
- result.rows[1].id.should.eql "789"
- result.rows[1].key.should.eql "789"
- result.rows[1].value.should.eql 1
- end
-
- it 'should pass through the keys'
- var result = db.query(map_function, null, {}, ["456", "123"]);
-
- result.rows.should.have_length 2
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.should.eql 1
- result.rows[1].id.should.eql "123"
- result.rows[1].key.should.eql "123"
- result.rows[1].value.should.eql 1
- end
-
- it 'should pass through the options and the keys'
- var result = db.query(map_function, null, {"include_docs":"true"}, ["456"]);
-
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.should.eql 1
- result.rows[0].doc["job"].should.eql "pilot"
- result.rows[0].doc["_rev"].length.should.be_at_least 30
- end
-
- it 'should apply a view in erlang also'
- // when this test fails, read this: http://wiki.apache.org/couchdb/EnableErlangViews
- var erlang_map = 'fun({Doc}) -> ' +
- 'ID = proplists:get_value(<<"_id">>, Doc, null), ' +
- 'Emit(ID, 1) ' +
- 'end.';
- var result = db.query(erlang_map, null, null, null, "erlang");
-
- result.rows.should.have_length 3
- result.rows[0].id.should.eql "123"
- result.rows[0].key.should.eql "123"
- result.rows[0].value.should.eql 1
- result.rows[1].id.should.eql "456"
- result.rows[1].key.should.eql "456"
- result.rows[1].value.should.eql 1
- result.rows[2].id.should.eql "789"
- result.rows[2].key.should.eql "789"
- result.rows[2].value.should.eql 1
- end
- end
-
- describe '.view'
- before_each
- db.save({"Name" : "Cally Tyrol", "job" : "deckhand", "_id" : "789"});
- db.save({"Name" : "Felix Gaeta", "job" : "officer", "_id" : "123"});
- db.save({"Name" : "Samuel T. Anders", "job" : "pilot", "_id" : "456"});
- view = {
- "views" : {
- "people" : {
- "map" : "function(doc) { emit(doc._id, doc.Name); }"
- }
- },
- "_id" : "_design/spec_db"
- };
- db.save(view);
- end
-
- it 'should apply the view'
- var result = db.view('spec_db/people');
-
- result.rows.should.have_length 3
- result.rows[0].id.should.eql "123"
- result.rows[0].key.should.eql "123"
- result.rows[0].value.should.eql "Felix Gaeta"
- result.rows[1].id.should.eql "456"
- result.rows[1].key.should.eql "456"
- result.rows[1].value.should.eql "Samuel T. Anders"
- result.rows[2].id.should.eql "789"
- result.rows[2].key.should.eql "789"
- result.rows[2].value.should.eql "Cally Tyrol"
- end
-
- it 'should pass through the options'
- var result = db.view('spec_db/people', {"skip":"2"});
-
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "789"
- result.rows[0].key.should.eql "789"
- result.rows[0].value.should.eql "Cally Tyrol"
- end
-
- it 'should pass through the keys'
- var result = db.view('spec_db/people', {}, ["456", "123"]);
-
- result.rows.should.have_length 2
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.should.eql "Samuel T. Anders"
- result.rows[1].id.should.eql "123"
- result.rows[1].key.should.eql "123"
- result.rows[1].value.should.eql "Felix Gaeta"
- end
-
- it 'should pass through the options and the keys'
- var result = db.view('spec_db/people', {"include_docs":"true"}, ["456"]);
-
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.should.eql "Samuel T. Anders"
- result.rows[0].doc["job"].should.eql "pilot"
- result.rows[0].doc["_rev"].length.should.be_at_least 30
- end
-
- it 'should return null when the view doesnt exist'
- var result = db.view('spec_db/non_existing_view');
-
- result.should.be_null
- end
- end
-
- describe '.info'
- before_each
- result = db.info();
- end
-
- it 'should return the name of the database'
- result.db_name.should.eql "spec_db"
- end
-
- it 'should return the number of documents'
- result.doc_count.should.eql 0
- end
-
- it 'should return the start time of the db instance'
- result.instance_start_time.should.have_length 16
- end
- end
-
- describe '.designInfo'
- before_each
- designDoc = {
- "views" : {
- "people" : {
- "map" : "function(doc) { emit(doc._id, doc); }"
- }
- },
- "_id" : "_design/spec_db"
- };
- db.save(designDoc);
- result = db.designInfo("_design/spec_db");
- end
-
- it 'should return the database name'
- result.name.should.eql "spec_db"
- end
-
- it 'should return a views language'
- result.view_index.language.should.eql "javascript"
- end
-
- it 'should return a views update sequence'
- result.view_index.update_seq.should.eql 0
- end
-
- it 'should return a views signature'
- result.view_index.signature.should.have_length 32
- end
- end
-end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/spec/couch_js_instance_methods_3_spec.js
----------------------------------------------------------------------
diff --git a/share/www/spec/couch_js_instance_methods_3_spec.js b/share/www/spec/couch_js_instance_methods_3_spec.js
deleted file mode 100644
index 4e5c99f..0000000
--- a/share/www/spec/couch_js_instance_methods_3_spec.js
+++ /dev/null
@@ -1,215 +0,0 @@
-// 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.
-
-// Specs for couch.js lines 201-265
-
-describe 'CouchDB instance'
- before_each
- db = new CouchDB("spec_db", {"X-Couch-Full-Commit":"false"});
- db.createDb();
- end
-
- after_each
- db.deleteDb();
- end
-
- describe '.allDocs'
- it 'should return no docs when there arent any'
- db.allDocs().total_rows.should.eql 0
- db.allDocs().rows.should.eql []
- end
-
- describe 'with docs'
- before_each
- db.save({"Name" : "Felix Gaeta", "_id" : "123"});
- db.save({"Name" : "Samuel T. Anders", "_id" : "456"});
- end
-
- it 'should return all docs'
- var result = db.allDocs();
-
- result.total_rows.should.eql 2
- result.rows.should.have_length 2
- result.rows[0].id.should.eql "123"
- result.rows[0].key.should.eql "123"
- result.rows[0].value.rev.length.should.be_at_least 30
- result.rows[1].id.should.eql "456"
- end
-
- it 'should pass through the options'
- var result = db.allDocs({"startkey": "123", "limit": "1"});
-
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "123"
- end
-
- it 'should pass through the keys'
- var result = db.allDocs({}, ["456"]);
-
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.rev.length.should.be_at_least 30
- end
-
- it 'should pass through the options and the keys'
- var result = db.allDocs({"include_docs":"true"}, ["456"]);
-
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "456"
- result.rows[0].key.should.eql "456"
- result.rows[0].value.rev.length.should.be_at_least 30
- result.rows[0].doc["Name"].should.eql "Samuel T. Anders"
- result.rows[0].doc["_rev"].length.should.be_at_least 30
- end
-
- end
- end
-
- describe '.designDocs'
- it 'should return nothing when there arent any design docs'
- db.save({"Name" : "Felix Gaeta", "_id" : "123"});
- db.designDocs().rows.should.eql []
- end
-
- it 'should return all design docs'
- var designDoc = {
- "views" : {
- "people" : {
- "map" : "function(doc) { emit(doc._id, doc); }"
- }
- },
- "_id" : "_design/spec_db"
- };
- db.save(designDoc);
- db.save({"Name" : "Felix Gaeta", "_id" : "123"});
-
- var result = db.designDocs();
-
- result.total_rows.should.eql 2
- result.rows.should.have_length 1
- result.rows[0].id.should.eql "_design/spec_db"
- result.rows[0].key.should.eql "_design/spec_db"
- result.rows[0].value.rev.length.should.be_at_least 30
- end
- end
-
- describe '.changes'
- it 'should return no changes when there arent any'
- db.changes().last_seq.should.eql 0
- db.changes().results.should.eql []
- end
-
- describe 'with changes'
- before_each
- db.save({"Name" : "Felix Gaeta", "_id" : "123"});
- db.save({"Name" : "Samuel T. Anders", "_id" : "456"});
- end
-
- it 'should return changes'
- var result = db.changes();
-
- result.last_seq.should.eql 2
- result.results[0].id.should.eql "123"
- result.results[0].seq.should.eql 1
- result.results[0].changes[0].rev.length.should.be_at_least 30
- result.results[1].id.should.eql "456"
- result.results[1].seq.should.eql 2
- result.results[1].changes[0].rev.length.should.be_at_least 30
- end
-
- it 'should pass through the options'
- var result = db.changes({"since":"1"});
-
- result.last_seq.should.eql 2
- result.results[0].id.should.eql "456"
- end
- end
- end
-
- describe '.compact'
- it 'should return ok true'
- db.compact().ok.should.be_true
- end
-
- it 'should post _compact to the db'
- db.should.receive("request", "once").with_args("POST", "/spec_db/_compact")
- db.compact();
- end
- end
-
- describe '.viewCleanup'
- it 'should return ok true'
- db.viewCleanup().ok.should.be_true
- end
-
- it 'should post _view_cleanup to the db'
- db.should.receive("request", "once").with_args("POST", "/spec_db/_view_cleanup")
- db.viewCleanup();
- end
- end
-
- describe '.setDbProperty'
- it 'should return ok true'
- db.setDbProperty("_revs_limit", 1500).ok.should.be_true
- end
-
- it 'should set a db property'
- db.setDbProperty("_revs_limit", 1500);
- db.getDbProperty("_revs_limit").should.eql 1500
- db.setDbProperty("_revs_limit", 1200);
- db.getDbProperty("_revs_limit").should.eql 1200
- end
- end
-
- describe '.getDbProperty'
- it 'should get a db property'
- db.setDbProperty("_revs_limit", 1200);
- db.getDbProperty("_revs_limit").should.eql 1200
- end
-
- it 'should throw an error when the property doesnt exist'
- function(){ db.getDbProperty("_doesnt_exist")}.should.throw_error
- end
- end
-
- describe '.setSecObj'
- it 'should return ok true'
- db.setSecObj({"members":{"names":["laura"],"roles":["president"]}}).ok.should.be_true
- end
-
- it 'should save a well formed object into the _security object '
- db.should.receive("request", "once").with_args("PUT", "/spec_db/_security", {body: '{"members":{"names":["laura"],"roles":["president"]}}'})
- db.setSecObj({"members": {"names" : ["laura"], "roles" : ["president"]}})
- end
-
- it 'should throw an error when the members or admins object is malformed'
- -{ db.setSecObj({"admins":["cylon"]}) }.should.throw_error
- end
-
- it 'should save any other object into the _security object'
- db.setSecObj({"something" : "anything"})
- db.getSecObj().should.eql {"something" : "anything"}
- end
- end
-
- describe '.getSecObj'
- it 'should get the security object'
- db.setSecObj({"admins" : {"names" : ["bill"], "roles" : ["admiral"]}})
- db.getSecObj().should.eql {"admins" : {"names": ["bill"], "roles": ["admiral"]}}
- end
-
- it 'should return an empty object when there is no security object'
- db.getSecObj().should.eql {}
- end
- end
-end
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/78f367cf/share/www/spec/custom_helpers.js
----------------------------------------------------------------------
diff --git a/share/www/spec/custom_helpers.js b/share/www/spec/custom_helpers.js
deleted file mode 100644
index d29ee87..0000000
--- a/share/www/spec/custom_helpers.js
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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.
-
-function stubAlert(){
- if(typeof(old_alert) == 'undefined'){
- old_alert = alert;
- }
- alert = function(msg){
- alert_msg = msg;
- };
-}
-
-function destubAlert(){
- alert = old_alert;
-}
-
-function errorCallback(status, error, reason){
- console.log("Unexpected " + status + " error: " + error + " - " + reason)
- throw("Unexpected " + status + " error: " + error + " - " + reason);
-}
-
-function successCallback(resp){
- console.log("No error message here unexpectedly, successful response instead.")
- throw("No error message here unexpectedly, successful response instead.");
-}
-
-function useTestUserDb(){
- users_db = new CouchDB("spec_users_db");
- var xhr = CouchDB.request("PUT", "/_config/couch_httpd_auth/authentication_db", {
- body: JSON.stringify("spec_users_db")
- });
- if(typeof(old_auth_db) == 'undefined'){
- old_auth_db = xhr.responseText.replace(/\n/,'').replace(/"/g,'');
- }
-}
-
-function useOldUserDb(){
- CouchDB.request("PUT", "/_config/couch_httpd_auth/authentication_db", {
- body: JSON.stringify(old_auth_db)
- });
- users_db.deleteDb();
-}
\ No newline at end of file