You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2013/03/11 22:36:15 UTC

[6/41] git commit: * server/tests/test_helper.rb: save/load scrubbed config data for each driver

* 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 <lu...@redhat.com>
Authored: Mon Mar 11 12:09:05 2013 -0700
Committer: David Lutterkort <lu...@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