mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #504 from ktheory/fog_credentials
[core] Allow FOG_CREDENTIAL variable for config
This commit is contained in:
commit
c4c0f1537e
2 changed files with 19 additions and 2 deletions
|
@ -13,7 +13,7 @@ module Fog
|
|||
|
||||
# @return [String, Symbol] The credential to use in Fog
|
||||
def self.credential
|
||||
@credential ||= :default
|
||||
@credential ||= ENV["FOG_CREDENTIAL"] || :default
|
||||
end
|
||||
|
||||
# @return [String] The path for configuration_file
|
||||
|
|
|
@ -2,12 +2,29 @@ Shindo.tests do
|
|||
before do
|
||||
@old_home = ENV['HOME']
|
||||
@old_rc = ENV['FOG_RC']
|
||||
@old_credential = ENV['FOG_CREDENTIAL']
|
||||
Fog.instance_variable_set('@credential_path', nil) # kill memoization
|
||||
Fog.instance_variable_set('@credential', nil) # kill memoization
|
||||
end
|
||||
|
||||
after do
|
||||
ENV['HOME'] = @old_home
|
||||
ENV['FOG_RC'] = @ld_rc
|
||||
ENV['FOG_RC'] = @old_rc
|
||||
ENV['FOG_CREDENTIAL'] = @old_credential
|
||||
end
|
||||
|
||||
tests('credential') do
|
||||
returns(:default, "is :default") { Fog.credential }
|
||||
|
||||
returns("foo", "can be set directly") do
|
||||
Fog.credential = "foo"
|
||||
Fog.credential
|
||||
end
|
||||
|
||||
returns("bar", "can be set with environment variable") do
|
||||
ENV["FOG_CREDENTIAL"] = "bar"
|
||||
Fog.credential
|
||||
end
|
||||
end
|
||||
|
||||
tests('credentials_path') do
|
||||
|
|
Loading…
Add table
Reference in a new issue