cassette 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96f195cb7bcaeb31ea15bb7ab870d084e1beb2ee
4
- data.tar.gz: ce075408ddbab3dbfa707de84d955540b9cf8b6b
3
+ metadata.gz: 2207d12cec88feeab0f936075e621b924bf98715
4
+ data.tar.gz: d333d8797ee293dc73007c79b557773dcf617d00
5
5
  SHA512:
6
- metadata.gz: ac1b50ec10929eebe7a2b5320e364856ae02f378f0af0e0152e22c5c20fda0ed6747423bc7ddf3b814f895de835d3c566e790fb411260fd589171b4d80de863a
7
- data.tar.gz: 79089be4244d97eed085725dcc1ed8109a94f4479812990d1aab6f17187100c2ba7b13ef764e1f13d92b064e6a85836ad8d193ba59717272793966bd2b0e596e
6
+ metadata.gz: 66d9005bc75a259d73458ad96fd270a314bf26d52a235582a9b350b1f938440cd72d5e56ee5857f06d92f38ed5f485ef7765cbb3281b7492f8405c1f8086002b
7
+ data.tar.gz: 336efd0fdd11c68d7e5c623e3019ab9316e0914a112ddab422e139d8d42bc1a559814a1ada8b1796fd28f1b494f5e4189131bd2befcdda7c8e4f456aeb452349
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Cassette::Client
2
2
 
3
+ [![Build Status](https://travis-ci.org/locaweb/cassette.svg)](https://travis-ci.org/locaweb/cassette)
4
+
5
+ [![Test Coverage](https://codeclimate.com/github/locaweb/cassette/badges/coverage.svg)](https://codeclimate.com/github/locaweb/cassette/coverage)
6
+
3
7
  Library to generate and validate STs and TGTs
4
8
 
5
9
  ## Installation
@@ -31,7 +31,7 @@ module Cassette
31
31
  begin
32
32
  logger.info("Validating #{ticket} on #{validate_path}")
33
33
 
34
- response = http.post(validate_path, ticket: ticket, service: service).body
34
+ response = http.get(validate_path, ticket: ticket, service: service).body
35
35
  ticket_response = Http::TicketResponse.new(response)
36
36
 
37
37
  logger.info("Validation resut: #{response.inspect}")
@@ -10,7 +10,7 @@ module Cassette
10
10
  def clear
11
11
  end
12
12
 
13
- def read(_key, _options)
13
+ def read(_key, _options = {})
14
14
  nil
15
15
  end
16
16
 
@@ -18,15 +18,15 @@ module Cassette
18
18
  true
19
19
  end
20
20
 
21
- def write(_key, _value, _options)
21
+ def write(_key, _value, _options = {})
22
22
  true
23
23
  end
24
24
 
25
- def increment(_key)
25
+ def increment(_key, _by = 1, _options = {})
26
26
  0
27
27
  end
28
28
 
29
- def fetch(_key, _options, &block)
29
+ def fetch(_key, _options = {}, &block)
30
30
  block.call
31
31
  end
32
32
  end
@@ -17,6 +17,13 @@ module Cassette
17
17
  end
18
18
  end
19
19
 
20
+ def get(path, payload, timeout = DEFAULT_TIMEOUT)
21
+ perform(:get, path) do |req|
22
+ req.params = payload
23
+ req.options.timeout = timeout
24
+ end
25
+ end
26
+
20
27
  private
21
28
 
22
29
  attr_accessor :config
@@ -2,7 +2,7 @@ module Cassette
2
2
  class Version
3
3
  MAJOR = '1'
4
4
  MINOR = '2'
5
- PATCH = '0'
5
+ PATCH = '1'
6
6
 
7
7
  def self.version
8
8
  [MAJOR, MINOR, PATCH].join('.')
@@ -45,13 +45,13 @@ describe Cassette::Authentication do
45
45
  end
46
46
 
47
47
  it 'raises a Forbidden exception on any exceptions' do
48
- allow(http).to receive(:post).with(anything, anything).and_raise(Cassette::Errors::BadRequest)
48
+ allow(http).to receive(:get).with(anything, anything).and_raise(Cassette::Errors::BadRequest)
49
49
  expect { subject.ticket_user('ticket') }.to raise_error(Cassette::Errors::Forbidden)
50
50
  end
51
51
 
52
52
  context 'with a failed CAS response' do
53
53
  before do
54
- allow(http).to receive(:post).with(anything, anything)
54
+ allow(http).to receive(:get).with(anything, anything)
55
55
  .and_return(OpenStruct.new(body: fixture('cas/fail.xml')))
56
56
  end
57
57
 
@@ -62,7 +62,7 @@ describe Cassette::Authentication do
62
62
 
63
63
  context 'with a successful CAS response' do
64
64
  before do
65
- allow(http).to receive(:post).with(anything, anything)
65
+ allow(http).to receive(:get).with(anything, anything)
66
66
  .and_return(OpenStruct.new(body: fixture('cas/success.xml')))
67
67
  end
68
68
 
@@ -0,0 +1,78 @@
1
+ # encoding: utf-8
2
+
3
+ require "cassette/cache/null_store"
4
+
5
+ describe Cassette::Cache::NullStore do
6
+ subject(:cache) { described_class.new }
7
+
8
+ describe '#read' do
9
+ it 'always return nils' do
10
+ expect(cache.read("key")).to be_nil
11
+
12
+ cache.write("key", "value")
13
+
14
+ expect(cache.read("key")).to be_nil
15
+ end
16
+
17
+ it 'accepts options' do
18
+ expect(cache.read("key", raw: true)).to be_nil
19
+ end
20
+ end
21
+
22
+ describe '#delete_matched' do
23
+ it 'returns true' do
24
+ expect(cache.delete_matched('key*')).to eq(true)
25
+ end
26
+ end
27
+
28
+ describe '#write' do
29
+ it 'returns true' do
30
+ expect(cache.write("key", "value")).to eq(true)
31
+ end
32
+
33
+ it 'accepts options' do
34
+ expect(cache.write("key", "value", expires_in: 3600)).to eq(true)
35
+ end
36
+
37
+ it 'does not actually write' do
38
+ cache.write("key", "value")
39
+
40
+ expect(cache.read("key")).to be_nil
41
+ end
42
+ end
43
+
44
+ describe "#increment" do
45
+ it 'returns 0' do
46
+ expect(cache.increment("key")).to be_zero
47
+ end
48
+
49
+ it '"accepts" a value to increment by' do
50
+ expect(cache.increment("key", 2)).to be_zero
51
+ end
52
+
53
+ it '"accepts" options' do
54
+ expect(cache.increment("key", 2, raw: true)).to be_zero
55
+ end
56
+
57
+ it 'does not really increment' do
58
+ cache.increment("key")
59
+
60
+ expect(cache.increment("key")).to be_zero
61
+ end
62
+ end
63
+
64
+ describe "#fetch" do
65
+ it "always calls the block" do
66
+ counter = 0
67
+
68
+ cache.fetch("key") { counter += 1 }
69
+ cache.fetch("key") { counter += 1 }
70
+
71
+ expect(counter).to eq(2)
72
+ end
73
+
74
+ it "accepts options" do
75
+ expect(cache.fetch("key", expires_in: 3600) { 0 }).to eq(0)
76
+ end
77
+ end
78
+ end
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.0
4
+ version: 1.2.1
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: 2017-08-10 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.5
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.5
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +178,20 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: codeclimate-test-reporter
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 1.0.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 1.0.0
167
195
  - !ruby/object:Gem::Dependency
168
196
  name: rspec_junit_formatter
169
197
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +271,7 @@ files:
243
271
  - spec/cassette/authentication/user_factory_spec.rb
244
272
  - spec/cassette/authentication/user_spec.rb
245
273
  - spec/cassette/authentication_spec.rb
274
+ - spec/cassette/cache/null_store_spec.rb
246
275
  - spec/cassette/cache_spec.rb
247
276
  - spec/cassette/client/cache_spec.rb
248
277
  - spec/cassette/client_spec.rb
@@ -276,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
305
  version: '0'
277
306
  requirements: []
278
307
  rubyforge_project:
279
- rubygems_version: 2.4.5.1
308
+ rubygems_version: 2.6.11
280
309
  signing_key:
281
310
  specification_version: 4
282
311
  summary: Generates, validates and caches TGTs and STs
@@ -287,6 +316,7 @@ test_files:
287
316
  - spec/cassette/authentication/user_factory_spec.rb
288
317
  - spec/cassette/authentication/user_spec.rb
289
318
  - spec/cassette/authentication_spec.rb
319
+ - spec/cassette/cache/null_store_spec.rb
290
320
  - spec/cassette/cache_spec.rb
291
321
  - spec/cassette/client/cache_spec.rb
292
322
  - spec/cassette/client_spec.rb