cassette 1.2.4 → 1.2.5

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
  SHA256:
3
- metadata.gz: 6541e55b06cc97ea1e68cd330af18791328e1cc72a9b04f9e93aa6e2f1032bc3
4
- data.tar.gz: 765652bf692b0dd1c8b3ef1b6bd7eaac59a2da11d0fd5569e8c565b8963aed9a
3
+ metadata.gz: c9ed73a897ba8ecc5a7f0133132d28388b9f4a90bc2d0e8a1fe3d1ec21f9b4b3
4
+ data.tar.gz: bdbe2968131cbddb9527ba973d68aaff7f5008be1b4fe6f662a26c7f5468edd1
5
5
  SHA512:
6
- metadata.gz: a0d7e79d8ab928c6e3179bda6271eab2f6744662a37057b2dba53f92c1f5cc8b9486b6e86382f71cd2fddba069121ca49d392e28a7731db8b2c650e4dd77ebb0
7
- data.tar.gz: 2721a7af21ff3a47ca13f495ae73c9c9e623bce36fb7d6d3418c5d69dac286760573aa2b653a791f25ab545abdaeea04e8a5824bdea9004f81f7bbca98eb4fe7
6
+ metadata.gz: 259b435580d9ebe186553374624dcab25e84d33b392ea00997dbc1729b0fd1fada1b1e5de3bf129aca440146c9bf5b94544525d7868c54b11509cbfc54b0e9b5
7
+ data.tar.gz: 02fc9b53c0a2e873b0dde28d2757e1d23f59b62d949ace7f789466c1e37f874477d9d4489d03c2e48536bf25016eef2da358e9dbe4dcb5e99943f7dd56ac94be
@@ -30,8 +30,9 @@ module Cassette
30
30
 
31
31
  def st(tgt_param, service, force = false)
32
32
  logger.info "Requesting ST for #{service}"
33
- cache.fetch_st(service, force: force) do
34
- tgt = tgt_param.respond_to?(:call) ? tgt_param[] : tgt_param
33
+ tgt = tgt_param.respond_to?(:call) ? tgt_param[] : tgt_param
34
+
35
+ cache.fetch_st(tgt, service, force: force) do
35
36
  response = http.post("#{tickets_path}/#{tgt}", service: service)
36
37
  response.body.tap do |st|
37
38
  logger.info "ST is #{st}"
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'cassette/client'
4
4
  require 'cassette/cache'
5
+ require 'digest'
5
6
 
6
7
  module Cassette
7
8
  class Client
@@ -15,15 +16,16 @@ module Cassette
15
16
  def fetch_tgt(options = {}, &_block)
16
17
  options = { expires_in: 4 * 3600, max_uses: 5000, force: false }.merge(options)
17
18
  fetch('Cassette::Client.tgt', options) do
18
- self.clear_st_cache!
19
19
  logger.info 'TGT is not cached'
20
20
  yield
21
21
  end
22
22
  end
23
23
 
24
- def fetch_st(service, options = {}, &_block)
24
+ def fetch_st(tgt, service, options = {}, &_block)
25
25
  options = { max_uses: 2000, expires_in: 252, force: false }.merge(options)
26
- fetch("Cassette::Client.st(#{service})", options) do
26
+ hash = Digest::MD5.hexdigest(tgt)
27
+
28
+ fetch("Cassette::Client.st(#{hash}, #{service})", options) do
27
29
  logger.info "ST for #{service} is not cached"
28
30
  yield
29
31
  end
@@ -35,8 +37,7 @@ module Cassette
35
37
  end
36
38
 
37
39
  def clear_st_cache!
38
- backend.delete_matched('Cassette::Client.st*')
39
- backend.delete_matched("#{uses_key('Cassette::Client.st')}*")
40
+ # this is a noop now, since clearing the TGT "moves" ST cache keys.
40
41
  end
41
42
 
42
43
  protected
@@ -2,7 +2,7 @@ module Cassette
2
2
  class Version
3
3
  MAJOR = '1'
4
4
  MINOR = '2'
5
- PATCH = '4'
5
+ PATCH = '5'
6
6
 
7
7
  def self.version
8
8
  [MAJOR, MINOR, PATCH].join('.')
@@ -160,7 +160,7 @@ describe Cassette::Client do
160
160
 
161
161
  context 'cache control' do
162
162
  before do
163
- allow(cache).to receive(:fetch_st).with(service, hash_including(force: force))
163
+ allow(cache).to receive(:fetch_st).with(tgt, service, hash_including(force: force))
164
164
  .and_return(st)
165
165
  end
166
166
 
@@ -170,7 +170,7 @@ describe Cassette::Client do
170
170
  it 'forwards force to the cache' do
171
171
  subject
172
172
 
173
- expect(cache).to have_received(:fetch_st).with(service, hash_including(force: force))
173
+ expect(cache).to have_received(:fetch_st).with(tgt, service, hash_including(force: force))
174
174
  end
175
175
  end
176
176
 
@@ -198,7 +198,7 @@ describe Cassette::Client do
198
198
  context 'when tgt and st are not cached' do
199
199
  before do
200
200
  allow(cache).to receive(:fetch_tgt).with(hash_including(force: false)).and_yield
201
- allow(cache).to receive(:fetch_st).with(service, hash_including(force: false)).and_yield
201
+ allow(cache).to receive(:fetch_st).with(tgt, service, hash_including(force: false)).and_yield
202
202
 
203
203
  allow(http).to receive(:post)
204
204
  .with(%r{/v1/tickets\z}, username: Cassette.config.username, password: Cassette.config.password)
@@ -232,7 +232,7 @@ describe Cassette::Client do
232
232
  context 'when tgt is cached but st is not' do
233
233
  before do
234
234
  allow(cache).to receive(:fetch_tgt).with(hash_including(force: false)).and_return(tgt)
235
- allow(cache).to receive(:fetch_st).with(service, hash_including(force: false)).and_yield
235
+ allow(cache).to receive(:fetch_st).with(tgt, service, hash_including(force: false)).and_yield
236
236
 
237
237
  allow(http).to receive(:post).with(%r{/v1/tickets/#{tgt}\z}, service: service)
238
238
  .and_return(st_response)
@@ -253,7 +253,8 @@ describe Cassette::Client do
253
253
 
254
254
  context 'when st is cached' do
255
255
  before do
256
- allow(cache).to receive(:fetch_st).with(service, hash_including(force: false)).and_return(st)
256
+ allow(cache).to receive(:fetch_st).with(tgt, service, hash_including(force: false)).and_return(st)
257
+ allow(cache).to receive(:fetch_tgt).and_return(tgt)
257
258
  end
258
259
 
259
260
  it 'returns the cached value' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassette
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Hermida Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-10 00:00:00.000000000 Z
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday