auth_token_store_provider 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 614b617bfe0780889bfe68b6bb3d7ed19ce49830
4
- data.tar.gz: 9a7f3000546fac484c423cd42448e7845c330ca9
3
+ metadata.gz: 3fbcdd696d85e564a90a002d6e685cffbaae6bb8
4
+ data.tar.gz: fbfe54f223e754a75c577722ab6ca01f7bbd2eb7
5
5
  SHA512:
6
- metadata.gz: 4b442d5637943c7eeee030abebc11e2f7cd4b899b5708b8da0802ebb7ec4de7f8685ca2edbc7b86ac107e50d2f560fbc65af95b275661c2f31779f9788133ed5
7
- data.tar.gz: 40d6869eaf3eef585e6a8928744868eff5f847780d2e2184bf3b974e245438babd2b1db9b14214e673f9d6003059d277547273367177106e7f554dcc1fd07cc2
6
+ metadata.gz: f526ac61b29fea3b7b2965431146910c42570cc82cc757bbb17323ea4660aa8f5cdca2af55bc0dc35f32290cad70289504a5ae47d6248fa132da4cd293c85dfc
7
+ data.tar.gz: f863f37b7ccbf2753d57d46fa60d934f3642c2b0854c8e40d9dc10973a083c1c1f7410eb42099782cd30ddd5ebb8c68c55b66b8b86f8061fb86fd061c8245962
@@ -10,12 +10,19 @@ module AuthTokenStoreProvider
10
10
  end
11
11
  end
12
12
 
13
- def simulate_store_failure
14
- @store_failure = true
13
+ def store_failure(state = true)
14
+ $stderr.puts "setting store failure to #{state}"
15
+ @@store_failure = state
16
+ $stderr.puts "store failure is #{@@store_failure}"
17
+ end
18
+
19
+ def store_failure?
20
+ @@store_failure ||= false
21
+ @@store_failure
15
22
  end
16
23
 
17
24
  def add(token_identifier:, authenticated_identifier:, token_issue_time:, token_expiry_time:, flow_identifier: nil)
18
- raise RuntimeError, 'Failure accessing store' if @store_failure
25
+ raise RuntimeError, 'Failure accessing store' if store_failure?
19
26
  store << { token_identifier: token_identifier,
20
27
  authenticated_identifier: authenticated_identifier,
21
28
  token_issue_time: token_issue_time,
@@ -23,13 +30,13 @@ module AuthTokenStoreProvider
23
30
  end
24
31
 
25
32
  def remove(token_identifier:, flow_identifier: nil)
26
- raise RuntimeError, 'Failure accessing store' if @store_failure
33
+ raise RuntimeError, 'Failure accessing store' if store_failure?
27
34
  store.delete_if { |x| x[:token_identifier] == token_identifier }
28
35
  true
29
36
  end
30
37
 
31
38
  def token_exist?(token_identifier:, authenticated_identifier:, token_issue_time:, token_expiry_time:, flow_identifier: nil)
32
- raise RuntimeError, 'Failure accessing store' if @store_failure
39
+ raise RuntimeError, 'Failure accessing store' if store_failure?
33
40
 
34
41
  store.each { |x|
35
42
  if ((x[:token_identifier] == token_identifier) and
@@ -43,13 +50,13 @@ module AuthTokenStoreProvider
43
50
  end
44
51
 
45
52
  def remove_tokens_for(authenticated_identifier:, flow_identifier: nil)
46
- raise RuntimeError, 'Failure accessing store' if @store_failure
53
+ raise RuntimeError, 'Failure accessing store' if store_failure?
47
54
  store.delete_if { |x| x[:authenticated_identifier] == authenticated_identifier }
48
55
  true
49
56
  end
50
57
 
51
58
  def list_tokens_for(authenticated_identifier:, flow_identifier: nil)
52
- raise RuntimeError, 'Failure accessing store' if @store_failure
59
+ raise RuntimeError, 'Failure accessing store' if store_failure?
53
60
  store.select { |x| x[:authenticated_identifier] == authenticated_identifier}
54
61
  end
55
62
  end
@@ -1,3 +1,3 @@
1
1
  module AuthenticationTokenStore
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  def simulate_storage_failure(subject)
12
12
  if subject.class == AuthTokenStoreProvider::StubClient
13
- subject.simulate_store_failure
13
+ subject.store_failure(true)
14
14
  end
15
15
  if subject.class == AuthTokenStoreProvider::Client
16
16
  subject.instance_variable_get("@configuration")['service_url'] = "http://authentication-token-store:1111/"
@@ -6,6 +6,7 @@ describe AuthTokenStoreProvider::StubClient do
6
6
  subject { AuthTokenStoreProvider::StubClient.new }
7
7
 
8
8
  before :each do
9
+ AuthTokenStoreProvider::StubClient.new.store_failure(false)
9
10
  @test_token_identifier = create_test_token_identifier
10
11
  @test_token_identifier_2 = create_test_token_identifier
11
12
  @test_authenticated_identifier = 'someone'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_token_store_provider
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barney de Villiers