cassette 1.1.2 → 1.1.3

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: b2916988a617098684131fad562314e3eae49f88
4
- data.tar.gz: e0a670ce68abfd324c412eb4809bcfc1681bb5ca
3
+ metadata.gz: 01f1d6811c1335b5b176f69010aa6708b3c7ff3d
4
+ data.tar.gz: ca010544b44694b470487d336701aeaf2c3e0f21
5
5
  SHA512:
6
- metadata.gz: 0a3a6e85b8cbc6d7a634bff8faf8868452af4466aa85b9a5d9b16bdc258746e6564e46801dcd4490e6354736007313bb114840690a5e5ef4bf573b90914333f8
7
- data.tar.gz: a32dc5f60fa5f3caa1a2a02330f83f82d6177f4f4a1c68ef3e7be9157c30abde936c4002a7249f5cb969e399e416e4bbe105de54940dc6cb1d904343fa9da3af
6
+ metadata.gz: a5af0a94f26e3403311e14eff8869d52424a86b63ffbcb46822e7b15fab64f0aa346d93942a2bc53316dcc20ca1cee663126091157f06bdd92ab5a4a105a9650
7
+ data.tar.gz: 2e3421d3b9669cf44e778186f47b9c8d08be0a96b7965fbc10b291268597c450c69cf6746073884c9a855cf93a02e8c65c2cf70720b4fac89296536f645911e4
@@ -10,7 +10,7 @@ module Cassette
10
10
  def initialize(opts = {})
11
11
  self.config = opts.fetch(:config, Cassette.config)
12
12
  self.logger = opts.fetch(:logger, Cassette.logger)
13
- self.http = opts.fetch(:http_client, Cassette::Http::Request)
13
+ self.http = opts.fetch(:http_client, Cassette::Http::Request.new(config))
14
14
  self.cache = opts.fetch(:cache, Cassette::Authentication::Cache.new(logger))
15
15
  end
16
16
 
@@ -29,9 +29,9 @@ module Cassette
29
29
  def ticket_user(ticket, service = config.service)
30
30
  cache.fetch_authentication(ticket, service) do
31
31
  begin
32
- logger.info("Validating #{ticket} on #{validate_uri}")
32
+ logger.info("Validating #{ticket} on #{validate_path}")
33
33
 
34
- response = http.post(validate_uri, ticket: ticket, service: service).body
34
+ response = http.post(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}")
@@ -77,8 +77,8 @@ module Cassette
77
77
  end
78
78
  end
79
79
 
80
- def validate_uri
81
- "#{config.base.gsub(/\/?$/, '')}/serviceValidate"
80
+ def validate_path
81
+ "/serviceValidate"
82
82
  end
83
83
  end
84
84
  end
@@ -10,7 +10,7 @@ module Cassette
10
10
  def initialize(opts = {})
11
11
  self.config = opts.fetch(:config, Cassette.config)
12
12
  self.logger = opts.fetch(:logger, Cassette.logger)
13
- self.http = opts.fetch(:http_client, Cassette)
13
+ self.http = opts.fetch(:http_client, Cassette::Http::Request.new(config))
14
14
  self.cache = opts.fetch(:cache, Cassette::Client::Cache.new(logger))
15
15
  end
16
16
 
@@ -21,7 +21,7 @@ module Cassette
21
21
  def tgt(usr, pwd, force = false)
22
22
  logger.info 'Requesting TGT'
23
23
  cache.fetch_tgt(force: force) do
24
- response = http.post(tickets_uri, username: usr, password: pwd)
24
+ response = http.post(tickets_path, username: usr, password: pwd)
25
25
  tgt = Regexp.last_match(1) if response.headers['Location'] =~ /tickets\/(.*)/
26
26
  logger.info "TGT is #{tgt}"
27
27
  tgt
@@ -32,7 +32,7 @@ module Cassette
32
32
  logger.info "Requesting ST for #{service}"
33
33
  cache.fetch_st(service, force: force) do
34
34
  tgt = tgt_param.respond_to?(:call) ? tgt_param[] : tgt_param
35
- response = http.post("#{tickets_uri}/#{tgt}", service: service)
35
+ response = http.post("#{tickets_path}/#{tgt}", service: service)
36
36
  response.body.tap do |st|
37
37
  logger.info "ST is #{st}"
38
38
  end
@@ -57,8 +57,8 @@ module Cassette
57
57
  retry
58
58
  end
59
59
 
60
- def tickets_uri
61
- "#{config.base.gsub(/\/?$/, '')}/v1/tickets"
60
+ def tickets_path
61
+ "/v1/tickets"
62
62
  end
63
63
  end
64
64
  end
@@ -1,27 +1,36 @@
1
1
  module Cassette
2
2
  module Http
3
- module Request
4
- extend self
3
+ class Request
4
+ def self.method_missing(name, *args)
5
+ @default_http ||= new
6
+ @default_http.send(name, *args)
7
+ end
8
+
9
+ def initialize(config = Cassette.config)
10
+ self.config = config
11
+ end
5
12
 
6
- def post(uri, payload, timeout = DEFAULT_TIMEOUT)
7
- perform(:post, uri, timeout) do |request|
8
- request.body = URI.encode_www_form(payload)
13
+ def post(path, payload, timeout = DEFAULT_TIMEOUT)
14
+ perform(:post, path) do |req|
15
+ req.body = URI.encode_www_form(payload)
16
+ req.options.timeout = timeout
9
17
  end
10
18
  end
11
19
 
12
20
  private
13
21
 
14
- def perform(http_verb, uri, timeout, &block)
15
- request(uri, timeout)
22
+ attr_accessor :config
23
+
24
+ def perform(http_verb, path, &block)
25
+ request
16
26
  .tap(&log_request)
17
- .public_send(http_verb, &block)
27
+ .public_send(http_verb, path, &block)
18
28
  .tap(&check_response)
19
29
  end
20
30
 
21
- def request(uri, timeout)
22
- Faraday.new(url: uri, ssl: { verify: false, version: 'TLSv1' }) do |con|
23
- con.adapter Faraday.default_adapter
24
- con.options.timeout = timeout
31
+ def request
32
+ @request ||= Faraday.new(url: config.base, ssl: { verify: false, version: 'TLSv1' }) do |conn|
33
+ conn.adapter Faraday.default_adapter
25
34
  end
26
35
  end
27
36
 
@@ -2,7 +2,7 @@ module Cassette
2
2
  class Version
3
3
  MAJOR = '1'
4
4
  MINOR = '1'
5
- PATCH = '2'
5
+ PATCH = '3'
6
6
 
7
7
  def self.version
8
8
  [MAJOR, MINOR, PATCH].join('.')
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  describe Cassette::Authentication do
3
3
  let(:cache) { instance_double(Cassette::Authentication::Cache) }
4
- let(:http) { class_double(Cassette) }
4
+ let(:http) { instance_double(Cassette::Http::Request) }
5
5
 
6
6
  subject(:authentication) do
7
7
  Cassette::Authentication.new(cache: cache, http_client: http)
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Cassette::Client do
6
- let(:http) { class_double(Cassette) }
6
+ let(:http) { instance_double(Cassette::Http::Request) }
7
7
  let(:cache) { instance_double(Cassette::Client::Cache) }
8
8
  let(:options) do
9
9
  {
@@ -2,9 +2,10 @@ describe Cassette::Http::Request do
2
2
  subject(:request) { described_class }
3
3
 
4
4
  describe '.post' do
5
- subject(:post) { request.post(uri, payload) }
5
+ subject(:post) { request.post(path, payload) }
6
6
 
7
- let(:uri) { 'http://example.org/' }
7
+ let(:uri) { "#{Cassette.config.base}#{path}" }
8
+ let(:path) { "/something" }
8
9
  let(:payload) { { ping: :pong } }
9
10
  let(:response) do
10
11
  {
metadata CHANGED
@@ -1,223 +1,223 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassette
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
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: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>'
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>'
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: libxml-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>'
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>'
52
+ - - ">"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-its
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubycas-client
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov-rcov
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: simplecov-gem-adapter
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rspec_junit_formatter
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: webmock
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - '>='
206
+ - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: faker
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - '>='
213
+ - - ">="
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - '>='
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  description: Client for generating and validating CAS TGT/STs
@@ -228,29 +228,29 @@ extensions: []
228
228
  extra_rdoc_files: []
229
229
  files:
230
230
  - README.md
231
+ - lib/cassette.rb
232
+ - lib/cassette/authentication.rb
231
233
  - lib/cassette/authentication/authorities.rb
232
234
  - lib/cassette/authentication/cache.rb
233
235
  - lib/cassette/authentication/filter.rb
234
236
  - lib/cassette/authentication/user.rb
235
- - lib/cassette/authentication.rb
236
237
  - lib/cassette/cache.rb
237
- - lib/cassette/client/cache.rb
238
238
  - lib/cassette/client.rb
239
+ - lib/cassette/client/cache.rb
240
+ - lib/cassette/errors.rb
239
241
  - lib/cassette/errors/not_a_customer.rb
240
242
  - lib/cassette/errors/not_an_employee.rb
241
- - lib/cassette/errors.rb
243
+ - lib/cassette/http.rb
242
244
  - lib/cassette/http/parsed_response.rb
243
245
  - lib/cassette/http/request.rb
244
246
  - lib/cassette/http/ticket_response.rb
245
- - lib/cassette/http.rb
247
+ - lib/cassette/rubycas.rb
246
248
  - lib/cassette/rubycas/helper.rb
247
249
  - lib/cassette/rubycas/not_single_sign_out_constraint.rb
248
250
  - lib/cassette/rubycas/routing_constraint.rb
249
251
  - lib/cassette/rubycas/single_sign_out_constraint.rb
250
252
  - lib/cassette/rubycas/user_factory.rb
251
- - lib/cassette/rubycas.rb
252
253
  - lib/cassette/version.rb
253
- - lib/cassette.rb
254
254
  - spec/cassette/authentication/authorities_spec.rb
255
255
  - spec/cassette/authentication/cache_spec.rb
256
256
  - spec/cassette/authentication/filter_spec.rb
@@ -281,17 +281,17 @@ require_paths:
281
281
  - lib
282
282
  required_ruby_version: !ruby/object:Gem::Requirement
283
283
  requirements:
284
- - - '>='
284
+ - - ">="
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  requirements:
289
- - - '>='
289
+ - - ">="
290
290
  - !ruby/object:Gem::Version
291
291
  version: '0'
292
292
  requirements: []
293
293
  rubyforge_project:
294
- rubygems_version: 2.0.14
294
+ rubygems_version: 2.5.1
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Generates, validates and caches TGTs and STs