From 61441a85b2a96cedd33c7bdc5940f0b8858de7be Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 17 Mar 2016 16:53:33 -0700 Subject: mx test: query identities table for a random record. closes #6406 --- tests/helpers/couchdb_helper.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/helpers/couchdb_helper.rb') diff --git a/tests/helpers/couchdb_helper.rb b/tests/helpers/couchdb_helper.rb index d4d3c0e0..312e38ac 100644 --- a/tests/helpers/couchdb_helper.rb +++ b/tests/helpers/couchdb_helper.rb @@ -66,6 +66,7 @@ class LeapTest # port: 5984 # def couchdb_url_via_localhost(path="", options=nil) + path = path.gsub('"', '%22') port = (options && options[:port]) || assert_property('couch.port') if options && options[:username] password = property("couch.users.%{username}.password" % options) -- cgit v1.2.3 From 966120293ec289636874edda6089b99dc49cb9ae Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 18 Mar 2016 09:40:41 -0700 Subject: tests: fix mx test, ensure password is redacted. --- tests/helpers/couchdb_helper.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/helpers/couchdb_helper.rb') diff --git a/tests/helpers/couchdb_helper.rb b/tests/helpers/couchdb_helper.rb index 312e38ac..27dabfcb 100644 --- a/tests/helpers/couchdb_helper.rb +++ b/tests/helpers/couchdb_helper.rb @@ -15,6 +15,7 @@ class LeapTest # connect_port: 15984 # def couchdb_urls_via_stunnel(path="", options=nil) + path = path.gsub('"', '%22') if options && options[:username] && options[:password] userpart = "%{username}:%{password}@" % options else @@ -46,6 +47,7 @@ class LeapTest # writable: true # def couchdb_url_via_haproxy(path="", options=nil) + path = path.gsub('"', '%22') if options && options[:username] && options[:password] userpart = "%{username}:%{password}@" % options else -- cgit v1.2.3 From eac3056c237d523f4786593922fe8f88eb65dff7 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 29 Mar 2016 13:27:01 -0700 Subject: testing: adds mx delivery tests --- tests/helpers/couchdb_helper.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/helpers/couchdb_helper.rb') diff --git a/tests/helpers/couchdb_helper.rb b/tests/helpers/couchdb_helper.rb index 27dabfcb..b9085c1e 100644 --- a/tests/helpers/couchdb_helper.rb +++ b/tests/helpers/couchdb_helper.rb @@ -103,4 +103,40 @@ class LeapTest end end + def assert_destroy_user_db(user_id, options=nil) + db_name = "user-#{user_id}" + url = couchdb_url("/#{db_name}", options) + http_options = {:ok_codes => [200, 404]} # ignore missing dbs + assert_delete(url, nil, http_options) + end + + def assert_create_user_db(user_id, options=nil) + db_name = "user-#{user_id}" + url = couchdb_url("/#{db_name}", options) + http_options = {:ok_codes => [200, 404]} # ignore missing dbs + assert_put(url, nil, :format => :json) do |body| + assert response = JSON.parse(body), "PUT response should be JSON" + assert response["ok"], "PUT response should be OK" + end + end + + # + # returns true if the per-user db created by soledad-server exists. + # + def user_db_exists?(user_id, options=nil) + db_name = "user-#{user_id}" + url = couchdb_url("/#{db_name}", options) + get(url) do |body, response, error| + if response.nil? + fail "could not query couchdb #{url}: #{error}\n#{body}" + elsif response.code.to_i == 200 + return true + elsif response.code.to_i == 404 + return false + else + fail ["could not query couchdb #{url}: expected response code 200 or 404, but got #{response.code}.", error, body].compact.join("\n") + end + end + end + end \ No newline at end of file -- cgit v1.2.3