Skip to content

Commit adf6d1f

Browse files
author
Michael C. Beck
committed
added optional redis credential key to be set
1 parent 3ef99c7 commit adf6d1f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/google/api_client/auth/storages/redis_store.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ class RedisStore
2424
# Initializes the RedisStore object.
2525
#
2626
# @params [Object] Redis instance
27-
def initialize(redis)
27+
def initialize(redis, key = nil)
2828
@redis= redis
29+
@redis_credentials_key = key
2930
end
3031

3132
##
@@ -36,7 +37,7 @@ def load_credentials
3637
end
3738

3839
def redis_credentials_key
39-
"google_api_credentials"
40+
@redis_credentials_key || "google_api_credentials"
4041
end
4142

4243
##

spec/google/api_client/auth/storages/redis_store_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@
4343
end
4444
end
4545

46+
describe 'redis_credentials_key' do
47+
context 'without given key' do
48+
it 'should return default key' do
49+
subject.redis_credentials_key.should == "google_api_credentials"
50+
end
51+
end
52+
context 'with given key' do
53+
let(:redis_store) { Google::APIClient::RedisStore.new('a redis instance', 'another_google_api_credentials') }
54+
it 'should use given key' do
55+
redis_store.redis_credentials_key.should == "another_google_api_credentials"
56+
end
57+
end
58+
59+
end
60+
4661
describe 'write credentials' do
4762

4863
it 'should write credentials' do

0 commit comments

Comments
 (0)