diff options
author | elijah <elijah@riseup.net> | 2015-04-08 13:59:18 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2015-04-08 13:59:18 -0700 |
commit | 35df265409732086402dfa172356448d1a5d315b (patch) | |
tree | b93afc9a9003bef439a4a733ee426e4a056bf32e /tests/white-box | |
parent | 7bb8b2e0685b3738c7842e86c09b826c2732e8bd (diff) | |
parent | e3cfc2e1e7055ce2640fcce5bf810d6bd7930d2f (diff) |
Merge branch 'bugfix/rotatedb' into develop
Diffstat (limited to 'tests/white-box')
-rw-r--r-- | tests/white-box/couchdb.rb | 18 |
1 files changed, 10 insertions, 8 deletions
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 |