deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [6/41] git commit: * server/tests/test_helper.rb: save/load scrubbed config data for each driver
Date Mon, 11 Mar 2013 21:36:15 GMT
* server/tests/test_helper.rb: save/load scrubbed config data for each driver

Anonymize user/password and give tests a chance to modify other things
before writing.

For some tests, like RHEV-M, the provider URL contains sensitive
information, like the hostname, which should not be recorded. At the same
time, we need to preserve the URL structure so that VCR matches requests on
playback.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/e60829e8
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/e60829e8
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/e60829e8

Branch: refs/heads/master
Commit: e60829e8cf46fa78443d10f4f7356adfad9468f3
Parents: 7252099
Author: David Lutterkort <lutter@redhat.com>
Authored: Mon Mar 11 12:09:05 2013 -0700
Committer: David Lutterkort <lutter@redhat.com>
Committed: Mon Mar 11 12:29:09 2013 -0700

----------------------------------------------------------------------
 server/tests/test_helper.rb |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/e60829e8/server/tests/test_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 5ba791d..94a7773 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -127,6 +127,23 @@ module Deltacloud
       def preferences(driver)
         @hash[driver.to_s]["preferred"]
       end
+
+      def save(driver, dir, &block)
+        h = @hash[driver.to_s].dup
+        h["user"] = "fakeuser"
+        h["password"] = "fakepassword"
+        yield(h) if block_given?
+        File::open(prefs_file(dir), "w") { |f| f.write(h.to_yaml) }
+      end
+
+      def load(driver, dir)
+        @hash[driver.to_s] = YAML::load(File::open(prefs_file(dir), "r"))
+      end
+
+      private
+      def prefs_file(dir)
+        File.join(dir, 'fixtures', 'preferences.yml')
+      end
     end
 
     def self.config


Mime
View raw message