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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fbcdd696d85e564a90a002d6e685cffbaae6bb8
|
4
|
+
data.tar.gz: fbfe54f223e754a75c577722ab6ca01f7bbd2eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
14
|
-
|
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
|
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
|
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
|
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
|
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
|
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
|
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.
|
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/"
|
data/spec/stub_client_spec.rb
CHANGED
@@ -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'
|