couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r979642 - in /couchdb/trunk/share/www/script: couch.js couch_tests.js test/basics.js test/config.js test/http.js test/oauth.js test/replication.js test/security_validation.js
Date Tue, 27 Jul 2010 11:02:36 GMT
Author: rnewson
Date: Tue Jul 27 11:02:36 2010
New Revision: 979642

URL: http://svn.apache.org/viewvc?rev=979642&view=rev
Log:
fix CLI js test suite.

Modified:
    couchdb/trunk/share/www/script/couch.js
    couchdb/trunk/share/www/script/couch_tests.js
    couchdb/trunk/share/www/script/test/basics.js
    couchdb/trunk/share/www/script/test/config.js
    couchdb/trunk/share/www/script/test/http.js
    couchdb/trunk/share/www/script/test/oauth.js
    couchdb/trunk/share/www/script/test/replication.js
    couchdb/trunk/share/www/script/test/security_validation.js

Modified: couchdb/trunk/share/www/script/couch.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch.js [utf-8] Tue Jul 27 11:02:36 2010
@@ -402,8 +402,7 @@ CouchDB.request = function(method, uri, 
   options.headers["Content-Type"] = options.headers["Content-Type"] || options.headers["content-type"]
|| "application/json";
   options.headers["Accept"] = options.headers["Accept"] || options.headers["accept"] || "application/json";
   var req = CouchDB.newXhr();
-  var proto = window.location.protocol + "//";
-  if(uri.substr(0, proto.length) != proto) {
+  if(uri.substr(0, CouchDB.protocol.length) != CouchDB.protocol) {
     uri = CouchDB.urlPrefix + uri
   }
   req.open(method, uri, false);

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Tue Jul 27 11:02:36 2010
@@ -13,10 +13,12 @@
 // Used by replication test
 if (typeof window == 'undefined' || !window) {
   CouchDB.host = "127.0.0.1:5984";
+  CouchDB.protocol = "http://";
   CouchDB.inBrowser = false;
 } else {
   CouchDB.host = window.location.host;
   CouchDB.inBrowser = true;
+  CouchDB.protocol = window.location.protocol + "//";
 }
 
 CouchDB.urlPrefix = "..";

Modified: couchdb/trunk/share/www/script/test/basics.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/basics.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/basics.js (original)
+++ couchdb/trunk/share/www/script/test/basics.js Tue Jul 27 11:02:36 2010
@@ -37,9 +37,8 @@ couchTests.basics = function(debug) {
     TEquals(dbname,
       xhr.getResponseHeader("Location").substr(-dbname.length),
       "should return Location header to newly created document");
-    var expected = window.location.protocol + "//";
-    TEquals(expected,
-      xhr.getResponseHeader("Location").substr(0, expected.length),
+    TEquals(CouchDB.protocol,
+      xhr.getResponseHeader("Location").substr(0, CouchDB.protocol.length),
       "should return absolute Location header to newly created document");
   });
 
@@ -181,9 +180,8 @@ couchTests.basics = function(debug) {
   TEquals("/test_suite_db/newdoc",
     xhr.getResponseHeader("Location").substr(-21),
     "should return Location header to newly created document");
-  var expected = window.location.protocol + "//";
-  TEquals(expected,
-    xhr.getResponseHeader("Location").substr(0, expected.length),
+  TEquals(CouchDB.protocol,
+    xhr.getResponseHeader("Location").substr(0, CouchDB.protocol.length),
     "should return absolute Location header to newly created document");
 
   // deleting a non-existent doc should be 404

Modified: couchdb/trunk/share/www/script/test/config.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/config.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/config.js (original)
+++ couchdb/trunk/share/www/script/test/config.js Tue Jul 27 11:02:36 2010
@@ -28,22 +28,21 @@ couchTests.config = function(debug) {
     Overengineering FTW.
   */
   var server_port = CouchDB.host.split(':');
-  var proto = window.location.protocol;
   if(server_port.length == 1 && CouchDB.inBrowser) {
-    if(proto == "http:") {
+    if(CouchDB.protocol == "http://") {
       port = 80;
     }
-    if(proto == "https:") {
+    if(CouchDB.protocol == "https://") {
       port = 443;
     }
   } else {
     port = server_port.pop();
   }
 
-  if(proto == "http:") {
+  if(CouchDB.protocol == "http://") {
     config_port = config.httpd.port;
   }
-  if(proto == "https:") {
+  if(CouchDB.protocol == "https://") {
     config_port = config.ssl.port;
   }
 

Modified: couchdb/trunk/share/www/script/test/http.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/http.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/http.js (original)
+++ couchdb/trunk/share/www/script/test/http.js Tue Jul 27 11:02:36 2010
@@ -25,7 +25,7 @@ couchTests.http = function(debug) {
   var xhr = CouchDB.request("PUT", "/test_suite_db/test", {body: "{}"});
   var host = CouchDB.host;
 
-  TEquals(window.location.protocol + "//" + host + "/test_suite_db/test", 
+  TEquals(CouchDB.protocol + host + "/test_suite_db/test", 
     xhr.getResponseHeader("Location"),
     "should include ip address");
 
@@ -34,7 +34,7 @@ couchTests.http = function(debug) {
     headers: {"X-Forwarded-Host": "mysite.com"}
   });
 
-  TEquals(window.location.protocol + "//" + "mysite.com/test_suite_db/test2",
+  TEquals(CouchDB.protocol + "mysite.com/test_suite_db/test2",
     xhr.getResponseHeader("Location"),
     "should include X-Forwarded-Host");
 
@@ -47,7 +47,7 @@ couchTests.http = function(debug) {
         body: "{}",
         headers: {"X-Host": "mysite2.com"}
       });
-      TEquals(window.location.protocol + "//" + "mysite2.com/test_suite_db/test3",
+      TEquals(CouchDB.protocol + "mysite2.com/test_suite_db/test3",
         xhr.getResponseHeader("Location"),
         "should include X-Host");
     });

Modified: couchdb/trunk/share/www/script/test/oauth.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/oauth.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/oauth.js (original)
+++ couchdb/trunk/share/www/script/test/oauth.js Tue Jul 27 11:02:36 2010
@@ -71,7 +71,7 @@ couchTests.oauth = function(debug) {
   var host = CouchDB.host;
   var dbPair = {
     source: {
-      url: window.location.protocol + "//" + host + "/test_suite_db_a",
+      url: CouchDB.protocol + host + "/test_suite_db_a",
       auth: {
         oauth: {
           consumer_key: "key",
@@ -82,7 +82,7 @@ couchTests.oauth = function(debug) {
       }
     },
     target: {
-      url: window.location.protocol + "//" + host + "/test_suite_db_b",
+      url: CouchDB.protocol + host + "/test_suite_db_b",
       headers: {"Authorization": adminBasicAuthHeaderValue()}
     }
   };
@@ -90,7 +90,7 @@ couchTests.oauth = function(debug) {
   // this function will be called on the modified server
   var testFun = function () {
     try {
-      CouchDB.request("PUT", window.location.protocol + "//" + host + "/_config/admins/testadmin",
{
+      CouchDB.request("PUT", CouchDB.protocol + host + "/_config/admins/testadmin", {
         headers: {"X-Couch-Persist": "false"},
         body: JSON.stringify(testadminPassword)
       });
@@ -98,7 +98,7 @@ couchTests.oauth = function(debug) {
       waitForSuccess(function() {
         //loop until the couch server has processed the password
         i += 1;
-        var xhr = CouchDB.request("GET", window.location.protocol + "//" + host + "/_config/admins/testadmin?foo="+i,{
+        var xhr = CouchDB.request("GET", CouchDB.protocol + host + "/_config/admins/testadmin?foo="+i,{
             headers: {
               "Authorization": adminBasicAuthHeaderValue()
             }});
@@ -109,7 +109,7 @@ couchTests.oauth = function(debug) {
 
       CouchDB.newUuids(2); // so we have one to make the salt
 
-      CouchDB.request("PUT", window.location.protocol + "//" + host + "/_config/couch_httpd_auth/require_valid_user",
{
+      CouchDB.request("PUT", CouchDB.protocol + host + "/_config/couch_httpd_auth/require_valid_user",
{
         headers: {
           "X-Couch-Persist": "false",
           "Authorization": adminBasicAuthHeaderValue()
@@ -157,11 +157,11 @@ couchTests.oauth = function(debug) {
           };
 
           // Get request token via Authorization header
-          xhr = oauthRequest("GET", window.location.protocol + "//" + host + "/_oauth/request_token",
message, accessor);
+          xhr = oauthRequest("GET", CouchDB.protocol + host + "/_oauth/request_token", message,
accessor);
           T(xhr.status == expectedCode);
 
           // GET request token via query parameters
-          xhr = oauthRequest("GET", window.location.protocol + "//" + host + "/_oauth/request_token",
message, accessor);
+          xhr = oauthRequest("GET", CouchDB.protocol + host + "/_oauth/request_token", message,
accessor);
           T(xhr.status == expectedCode);
 
           responseMessage = OAuth.decodeForm(xhr.responseText);
@@ -171,7 +171,7 @@ couchTests.oauth = function(debug) {
           //xhr = CouchDB.request("GET", authorization_url + '?oauth_token=' + responseMessage.oauth_token);
           //T(xhr.status == expectedCode);
 
-          xhr = oauthRequest("GET", window.location.protocol + "//" + host + "/_session",
message, accessor);
+          xhr = oauthRequest("GET", CouchDB.protocol + host + "/_session", message, accessor);
           T(xhr.status == expectedCode);
           if (xhr.status == expectedCode == 200) {
             data = JSON.parse(xhr.responseText);
@@ -179,11 +179,11 @@ couchTests.oauth = function(debug) {
             T(data.roles[0] == "test");
           }
 
-          xhr = oauthRequest("GET", window.location.protocol + "//" + host + "/_session?foo=bar",
message, accessor);
+          xhr = oauthRequest("GET", CouchDB.protocol + host + "/_session?foo=bar", message,
accessor);
           T(xhr.status == expectedCode);
 
           // Test HEAD method
-          xhr = oauthRequest("HEAD", window.location.protocol + "//" + host + "/_session?foo=bar",
message, accessor);
+          xhr = oauthRequest("HEAD", CouchDB.protocol + host + "/_session?foo=bar", message,
accessor);
           T(xhr.status == expectedCode);
 
           // Replication
@@ -207,7 +207,7 @@ couchTests.oauth = function(debug) {
               oauth_version: "1.0"
             }
           };
-          xhr = oauthRequest("GET", window.location.protocol + "//" + host + "/_session?foo=bar",
message, adminAccessor);
+          xhr = oauthRequest("GET", CouchDB.protocol + host + "/_session?foo=bar", message,
adminAccessor);
           if (xhr.status == expectedCode == 200) {
             data = JSON.parse(xhr.responseText);
             T(data.name == "testadmin");
@@ -216,13 +216,13 @@ couchTests.oauth = function(debug) {
 
           // Test when the user's token doesn't exist.
           message.parameters.oauth_token = "not a token!";
-          xhr = oauthRequest("GET", window.location.protocol + "//" + host + "/_session?foo=bar",
+          xhr = oauthRequest("GET", CouchDB.protocol + host + "/_session?foo=bar",
                   message, adminAccessor);
           T(xhr.status == 400, "Request should be invalid.");
         }
       }
     } finally {
-      var xhr = CouchDB.request("PUT", window.location.protocol + "//" + host + "/_config/couch_httpd_auth/require_valid_user",
{
+      var xhr = CouchDB.request("PUT", CouchDB.protocol + host + "/_config/couch_httpd_auth/require_valid_user",
{
         headers: {
           "Authorization": adminBasicAuthHeaderValue(),
           "X-Couch-Persist": "false"
@@ -231,7 +231,7 @@ couchTests.oauth = function(debug) {
       });
       T(xhr.status == 200);
 
-      var xhr = CouchDB.request("DELETE", window.location.protocol + "//" + host + "/_config/admins/testadmin",
{
+      var xhr = CouchDB.request("DELETE", CouchDB.protocol + host + "/_config/admins/testadmin",
{
         headers: {
           "Authorization": adminBasicAuthHeaderValue(),
           "X-Couch-Persist": "false"

Modified: couchdb/trunk/share/www/script/test/replication.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/replication.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/replication.js (original)
+++ couchdb/trunk/share/www/script/test/replication.js Tue Jul 27 11:02:36 2010
@@ -17,11 +17,11 @@ couchTests.replication = function(debug)
     {source:"test_suite_db_a",
       target:"test_suite_db_b"},
     {source:"test_suite_db_a",
-      target:window.location.protocol + "//" + host + "/test_suite_db_b"},
-    {source:window.location.protocol + "//" + host + "/test_suite_db_a",
+      target:CouchDB.protocol + host + "/test_suite_db_b"},
+    {source:CouchDB.protocol + host + "/test_suite_db_a",
       target:"test_suite_db_b"},
-    {source:window.location.protocol + "//" + host + "/test_suite_db_a",
-      target:window.location.protocol + "//" + host + "/test_suite_db_b"}
+    {source:CouchDB.protocol + host + "/test_suite_db_a",
+      target:CouchDB.protocol + host + "/test_suite_db_b"}
   ]
   var dbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});
   var dbB = new CouchDB("test_suite_db_b", {"X-Couch-Full-Commit":"false"});
@@ -296,7 +296,7 @@ couchTests.replication = function(debug)
 
   // remote
   dbB.deleteDb();
-  CouchDB.replicate(dbA.name, window.location.protocol + "//" + CouchDB.host + "/test_suite_db_b",
{
+  CouchDB.replicate(dbA.name, CouchDB.protocol + CouchDB.host + "/test_suite_db_b", {
     body: {"create_target": true}
   });
   TEquals("test_suite_db_b", dbB.info().db_name,
@@ -372,11 +372,11 @@ couchTests.replication = function(debug)
     {source:"test_suite_rep_docs_db_a",
       target:"test_suite_rep_docs_db_b"},
     {source:"test_suite_rep_docs_db_a",
-      target:window.location.protocol + "//" + host + "/test_suite_rep_docs_db_b"},
-    {source:window.location.protocol + "//" + host + "/test_suite_rep_docs_db_a",
+      target:CouchDB.protocol + host + "/test_suite_rep_docs_db_b"},
+    {source:CouchDB.protocol + host + "/test_suite_rep_docs_db_a",
       target:"test_suite_rep_docs_db_b"},
-    {source:window.location.protocol + "//" + host + "/test_suite_rep_docs_db_a",
-      target:window.location.protocol + "//" + host + "/test_suite_rep_docs_db_b"}
+    {source:CouchDB.protocol + host + "/test_suite_rep_docs_db_a",
+      target:CouchDB.protocol + host + "/test_suite_rep_docs_db_b"}
   ];
 
   var target_doc_ids = [
@@ -481,11 +481,11 @@ couchTests.replication = function(debug)
     {source:"test_suite_filtered_rep_db_a",
       target:"test_suite_filtered_rep_db_b"},
     {source:"test_suite_filtered_rep_db_a",
-      target:window.location.protocol + "//" + host + "/test_suite_filtered_rep_db_b"},
-    {source:window.location.protocol + "//" + host + "/test_suite_filtered_rep_db_a",
+      target:CouchDB.protocol + host + "/test_suite_filtered_rep_db_b"},
+    {source:CouchDB.protocol + host + "/test_suite_filtered_rep_db_a",
       target:"test_suite_filtered_rep_db_b"},
-    {source:window.location.protocol + "//" + host + "/test_suite_filtered_rep_db_a",
-      target:window.location.protocol + "//" + host + "/test_suite_filtered_rep_db_b"}
+    {source:CouchDB.protocol + host + "/test_suite_filtered_rep_db_a",
+      target:CouchDB.protocol + host + "/test_suite_filtered_rep_db_b"}
   ];
 
   for (var i = 0; i < dbPairs.length; i++) {

Modified: couchdb/trunk/share/www/script/test/security_validation.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/security_validation.js?rev=979642&r1=979641&r2=979642&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/security_validation.js (original)
+++ couchdb/trunk/share/www/script/test/security_validation.js Tue Jul 27 11:02:36 2010
@@ -235,16 +235,16 @@ couchTests.security_validation = functio
           target:"test_suite_db_b"},
 
         {source:"test_suite_db_a",
-          target:{url: window.location.protocol + "//" + host + "/test_suite_db_b",
+          target:{url: CouchDB.protocol + host + "/test_suite_db_b",
                   headers: AuthHeaders}},
 
-        {source:{url:window.location.protocol + "//" + host + "/test_suite_db_a",
+        {source:{url:CouchDB.protocol + host + "/test_suite_db_a",
                  headers: AuthHeaders},
           target:"test_suite_db_b"},
 
-        {source:{url:window.location.protocol + "//" + host + "/test_suite_db_a",
+        {source:{url:CouchDB.protocol + host + "/test_suite_db_a",
                  headers: AuthHeaders},
-         target:{url:window.location.protocol + "//" + host + "/test_suite_db_b",
+         target:{url:CouchDB.protocol + host + "/test_suite_db_b",
                  headers: AuthHeaders}},
       ]
       var adminDbA = new CouchDB("test_suite_db_a", {"X-Couch-Full-Commit":"false"});



Mime
View raw message