From 74b420220315b9b0731a6ebb22ce3f4a837cf052 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 27 Jan 2015 14:19:13 -0800 Subject: skip tests that require user registration if it is disabled --- tests/white-box/webapp.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/white-box') diff --git a/tests/white-box/webapp.rb b/tests/white-box/webapp.rb index 9f104899..a0d64eea 100644 --- a/tests/white-box/webapp.rb +++ b/tests/white-box/webapp.rb @@ -42,11 +42,16 @@ class Webapp < LeapTest end def test_05_Can_create_and_authenticate_and_delete_user_via_API? - assert_tmp_user - pass + if property('webapp.allow_registration') + assert_tmp_user + pass + else + skip "New user registrations are disabled." + end end def test_06_Can_sync_Soledad? + return unless property('webapp.allow_registration') soledad_config = property('definition_files.soledad_service') if soledad_config && !soledad_config.empty? soledad_server = pick_soledad_server(soledad_config) -- cgit v1.2.3 From aab8376aa98f9e2acaa412aebadff64c458cfaa1 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 3 Feb 2015 12:17:35 -0800 Subject: increase the sleep time for soledad test --- tests/white-box/webapp.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/white-box') diff --git a/tests/white-box/webapp.rb b/tests/white-box/webapp.rb index a0d64eea..1e78c8a5 100644 --- a/tests/white-box/webapp.rb +++ b/tests/white-box/webapp.rb @@ -101,14 +101,14 @@ class Webapp < LeapTest def assert_user_db_exists(user) last_body, last_response, last_error = nil 3.times do - sleep 0.1 + sleep 0.2 get(couchdb_url("/user-#{user.id}/_design/docs")) do |body, response, error| last_body, last_response, last_error = body, response, error if response.code.to_i == 200 return end end - sleep 0.2 + sleep 0.5 end assert false, "Could not find user db for test user #{user.username}\nuuid=#{user.id}\nHTTP #{last_response.code} #{last_error} #{last_body}" end -- cgit v1.2.3 From e3cfc2e1e7055ce2640fcce5bf810d6bd7930d2f Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 8 Apr 2015 13:58:41 -0700 Subject: move rotated db creation to site_couchdb and fix rotated db tests --- tests/white-box/couchdb.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tests/white-box') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index 450c4201..d0f5ce88 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -82,7 +82,10 @@ class CouchDB < LeapTest end def test_05_Do_required_databases_exist? - dbs_that_should_exist = ["customers","identities","keycache","sessions","shared","tickets","tokens","users"] + dbs_that_should_exist = ["customers","identities","keycache","shared","tickets","users", "tmp_users"] + rotation_suffix = Time.now.utc.to_i / 2592000 # monthly + dbs_that_should_exist << "tokens_#{rotation_suffix}" + dbs_that_should_exist << "sessions_#{rotation_suffix}" dbs_that_should_exist.each do |db_name| url = couchdb_url("/"+db_name, :username => 'admin') assert_get(url) do |body| @@ -113,9 +116,9 @@ class CouchDB < LeapTest #end def test_07_Can_records_be_created? - token = Token.new - url = couchdb_url("/tokens", :username => 'admin') - assert_post(url, token, :format => :json) do |body| + record = DummyRecord.new + url = couchdb_url("/tmp_users", :username => 'admin') + assert_post(url, record, :format => :json) do |body| assert response = JSON.parse(body), "POST response should be JSON" assert response["ok"], "POST response should be OK" assert_delete(File.join(url, response["id"]), :rev => response["rev"]) do |body| @@ -144,11 +147,10 @@ class CouchDB < LeapTest require 'securerandom' require 'digest/sha2' - class Token < Hash + class DummyRecord < Hash def initialize - self['token'] = SecureRandom.urlsafe_base64(32).gsub(/^_*/, '') - self['_id'] = Digest::SHA512.hexdigest(self['token']) - self['last_seen_at'] = Time.now + self['data'] = SecureRandom.urlsafe_base64(32).gsub(/^_*/, '') + self['_id'] = Digest::SHA512.hexdigest(self['data']) end end -- cgit v1.2.3 From 051b80d25bd0fe400769976c3210718689f832b4 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 9 Apr 2015 09:38:56 -0700 Subject: fix tests (don't dump dummy records in tmp_users) --- tests/white-box/couchdb.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/white-box') diff --git a/tests/white-box/couchdb.rb b/tests/white-box/couchdb.rb index d0f5ce88..5ee12ff3 100644 --- a/tests/white-box/couchdb.rb +++ b/tests/white-box/couchdb.rb @@ -83,7 +83,6 @@ class CouchDB < LeapTest def test_05_Do_required_databases_exist? dbs_that_should_exist = ["customers","identities","keycache","shared","tickets","users", "tmp_users"] - rotation_suffix = Time.now.utc.to_i / 2592000 # monthly dbs_that_should_exist << "tokens_#{rotation_suffix}" dbs_that_should_exist << "sessions_#{rotation_suffix}" dbs_that_should_exist.each do |db_name| @@ -117,7 +116,7 @@ class CouchDB < LeapTest def test_07_Can_records_be_created? record = DummyRecord.new - url = couchdb_url("/tmp_users", :username => 'admin') + url = couchdb_url("/tokens_#{rotation_suffix}", :username => 'admin') assert_post(url, record, :format => :json) do |body| assert response = JSON.parse(body), "POST response should be JSON" assert response["ok"], "POST response should be OK" @@ -145,6 +144,10 @@ class CouchDB < LeapTest couchdb_url(path, options) end + def rotation_suffix + rotation_suffix = Time.now.utc.to_i / 2592000 # monthly + end + require 'securerandom' require 'digest/sha2' class DummyRecord < Hash -- cgit v1.2.3