cassette 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/lib/cassette.rb +9 -1
- data/lib/cassette/http/request.rb +2 -1
- data/lib/cassette/version.rb +3 -3
- data/spec/cassette_spec.rb +72 -0
- data/spec/config.yml +7 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33c8ac4e79e63b44d3a2806fd7725ad5098605409abc8fe89f0c4d0dd5313eb8
|
4
|
+
data.tar.gz: 6165b70c92ab25a0123bbe7cd9c6d4f9e407e9c715219337bcaa57b6a3210465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd380df4df71bea613ee498eac11874fd938773a1008ca08b7a5499b47e1ec52a9e9029a71578acd51b4e0f8894f9b8fb018fe008b0f1aedf791922ffb55e87
|
7
|
+
data.tar.gz: 2a57fdbb03ce6ae51b99fe9b4eab39791c94d2c2f33b62b4bd8b1edc17f92ed5a0c7c892ac28f0175f9fbcb11a2f3cd99bec212b5c672fbd4dff4bae4f37801c
|
data/README.md
CHANGED
@@ -25,10 +25,18 @@ $ bundle
|
|
25
25
|
Require this library and create an intializer to set its configuration:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
|
28
|
+
Cassete.config = OpenStruct.new(
|
29
|
+
username: 'user',
|
30
|
+
password: 'secret',
|
31
|
+
service: 'test-api.example.org',
|
32
|
+
base: 'https://some-cas.example.org',
|
33
|
+
base_authority: 'CASTEST',
|
34
|
+
verify_ssl: true, # If not defined, the default value will be: false.
|
35
|
+
tls_version: 'TLSv1_2' # if not defined, the default value will be: 'TLSv1'.
|
36
|
+
)
|
29
37
|
```
|
30
38
|
|
31
|
-
where config is an
|
39
|
+
where config is an OpenStruct that responds to the methods `base` for the base CAS uri, `username` and `password` if you are authenticating on other systems and `service` and `base_authority` if you are using the authentication filter to authenticate your app.
|
32
40
|
|
33
41
|
You may also set the caching backend using the .backend= module method:
|
34
42
|
|
data/lib/cassette.rb
CHANGED
@@ -21,7 +21,9 @@ module Cassette
|
|
21
21
|
|
22
22
|
attr_writer :config, :logger
|
23
23
|
|
24
|
-
DEFAULT_TIMEOUT
|
24
|
+
DEFAULT_TIMEOUT = 10
|
25
|
+
DEFAULT_TLS_VERSION = 'TLSv1'.freeze
|
26
|
+
DEFAULT_VERIFY_SSL = false
|
25
27
|
|
26
28
|
def logger
|
27
29
|
@logger ||= begin
|
@@ -35,6 +37,12 @@ module Cassette
|
|
35
37
|
|
36
38
|
def config
|
37
39
|
@config if defined?(@config)
|
40
|
+
|
41
|
+
@config.tls_version = DEFAULT_TLS_VERSION if @config.tls_version.nil?
|
42
|
+
|
43
|
+
@config.verify_ssl = DEFAULT_VERIFY_SSL if @config.verify_ssl.nil?
|
44
|
+
|
45
|
+
@config
|
38
46
|
end
|
39
47
|
|
40
48
|
def cache_backend
|
@@ -36,7 +36,8 @@ module Cassette
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def request
|
39
|
-
@request ||= Faraday.new(url: config.base, ssl:
|
39
|
+
@request ||= Faraday.new(url: config.base, ssl:
|
40
|
+
{ verify: config.verify_ssl, version: config.tls_version }) do |conn|
|
40
41
|
conn.adapter Faraday.default_adapter
|
41
42
|
end
|
42
43
|
end
|
data/lib/cassette/version.rb
CHANGED
data/spec/cassette_spec.rb
CHANGED
@@ -7,6 +7,78 @@ describe Cassette do
|
|
7
7
|
Cassette.logger = original_logger
|
8
8
|
end
|
9
9
|
|
10
|
+
describe '.config' do
|
11
|
+
it 'defines Cassette initial configuration based on a OpenStruct' do
|
12
|
+
|
13
|
+
config = OpenStruct.new(
|
14
|
+
YAML.load_file('spec/config.yml')
|
15
|
+
)
|
16
|
+
|
17
|
+
Cassette.config = config
|
18
|
+
|
19
|
+
expect(Cassette.config)
|
20
|
+
.to eq(config)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when tls_version was not specified' do
|
24
|
+
it 'uses default TLS version: TLSv1' do
|
25
|
+
config = OpenStruct.new(
|
26
|
+
YAML.load_file('spec/config.yml')
|
27
|
+
)
|
28
|
+
|
29
|
+
# Removing tls_version field
|
30
|
+
config.delete_field(:tls_version)
|
31
|
+
|
32
|
+
Cassette.config = config
|
33
|
+
|
34
|
+
expect(Cassette.config.tls_version)
|
35
|
+
.to eq('TLSv1')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when tls_version is specified' do
|
40
|
+
it 'uses this version' do
|
41
|
+
config = OpenStruct.new(
|
42
|
+
YAML.load_file('spec/config.yml')
|
43
|
+
)
|
44
|
+
|
45
|
+
Cassette.config = config
|
46
|
+
|
47
|
+
expect(Cassette.config.tls_version)
|
48
|
+
.to eq('TLSv1_2')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when verify_ssl was not specified' do
|
53
|
+
it 'uses default verify_ssl value: false' do
|
54
|
+
config = OpenStruct.new(
|
55
|
+
YAML.load_file('spec/config.yml')
|
56
|
+
)
|
57
|
+
|
58
|
+
# Removing verify_ssl field
|
59
|
+
config.delete_field(:verify_ssl)
|
60
|
+
|
61
|
+
Cassette.config = config
|
62
|
+
|
63
|
+
expect(Cassette.config.verify_ssl)
|
64
|
+
.to be false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when verify_ssl is specified' do
|
69
|
+
it 'uses this value' do
|
70
|
+
config = OpenStruct.new(
|
71
|
+
YAML.load_file('spec/config.yml')
|
72
|
+
)
|
73
|
+
|
74
|
+
Cassette.config = config
|
75
|
+
|
76
|
+
expect(Cassette.config.verify_ssl)
|
77
|
+
.to be true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
10
82
|
describe '.logger' do
|
11
83
|
it 'returns a default instance' do
|
12
84
|
expect(Cassette.logger).not_to be_nil
|
data/spec/config.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
username:
|
2
|
-
password:
|
3
|
-
service:
|
4
|
-
base:
|
5
|
-
base_authority:
|
1
|
+
username: 'user'
|
2
|
+
password: 'secret'
|
3
|
+
service: 'test-api.example.org'
|
4
|
+
base: 'https://some-cas.example.org'
|
5
|
+
base_authority: 'CASTEST'
|
6
|
+
verify_ssl: true
|
7
|
+
tls_version: 'TLSv1_2'
|
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.
|
4
|
+
version: 1.4.0
|
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: 2020-03-
|
11
|
+
date: 2020-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|