deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [12/15] git commit: * server/tests/test_helper.rb: read credentials from a file
Date Tue, 28 Aug 2012 00:16:55 GMT
* server/tests/test_helper.rb: read credentials from a file

This only puts the code to do that into place - it's not used yet.


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

Branch: refs/heads/master
Commit: 00b2815f25e15c5a6ba5541a41210f17bcb4d379
Parents: 457a6e3
Author: David Lutterkort <lutter@redhat.com>
Authored: Fri Aug 24 17:09:58 2012 -0700
Committer: David Lutterkort <lutter@redhat.com>
Committed: Fri Aug 24 17:49:31 2012 -0700

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


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/00b2815f/server/tests/test_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index bf9f2ca..75c69d9 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -6,6 +6,8 @@ require 'nokogiri'
 require 'pp'
 require 'require_relative' if RUBY_VERSION < '1.9'
 
+require 'singleton'
+
 require_relative '../lib/deltacloud/api.rb'
 
 ENV['RACK_ENV'] = 'test'
@@ -35,3 +37,36 @@ def xml; Nokogiri::XML(response_body); end
 def json; JSON::parse(response_body); end
 def formats; [ 'application/xml', 'application/json', 'text/html' ]; end
 def root_url(url=''); Deltacloud.default_frontend.root_url + url; end
+
+module Deltacloud
+  module Test
+    class Config
+      include Singleton
+
+      def initialize
+        fname = ENV["CONFIG"] || File::expand_path("~/.deltacloud/config")
+        begin
+          @hash = YAML.load(File::open(fname))
+        rescue Errno::ENOENT
+          @hash = {}
+        end
+      end
+
+      def credentials(driver)
+        driver = driver.to_s
+        if @hash.has_key?(driver)
+          user = @hash[driver]["user"]
+          password = @hash[driver]["password"]
+        else
+          user = "fakeuser"
+          password = "fakepassword"
+        end
+        { :user => user, :password => password }
+      end
+    end
+
+    def self.config
+      Config::instance
+    end
+  end
+end


Mime
View raw message