cassette 1.3.0 → 1.4.0

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
  SHA256:
3
- metadata.gz: 27cfa48a748bedca25340e26864baeed00a733ce246892a309891228ccdc132d
4
- data.tar.gz: cff0103bee5189300805c36ff24f3d559911c82d919c4eac294101b8f78aa3e0
3
+ metadata.gz: 33c8ac4e79e63b44d3a2806fd7725ad5098605409abc8fe89f0c4d0dd5313eb8
4
+ data.tar.gz: 6165b70c92ab25a0123bbe7cd9c6d4f9e407e9c715219337bcaa57b6a3210465
5
5
  SHA512:
6
- metadata.gz: 823da9e1561d8521c0aa7e17e590df027ded2eca1ea7671aff54373dbbeeb89917db759c57e5dee709c07a75ca5913cefae46e609c60b77aea23edfd9e0e6cc0
7
- data.tar.gz: 07da8bc42bd54cde6cd190596fa33ef93157a4b99bdf97258a1d90c6f3f95a8d38394661e6c4b83dbfff83415a73d4154951800bba0eb4123c43446f69025f41
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
- Cassette.config = config
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 object 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.
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 = 10
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: { verify: false, version: 'TLSv1' }) do |conn|
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
@@ -1,8 +1,8 @@
1
1
  module Cassette
2
2
  class Version
3
- MAJOR = '1'
4
- MINOR = '3'
5
- PATCH = '0'
3
+ MAJOR = '1'.freeze
4
+ MINOR = '4'.freeze
5
+ PATCH = '0'.freeze
6
6
 
7
7
  def self.version
8
8
  [MAJOR, MINOR, PATCH].join('.')
@@ -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: "user"
2
- password: "secret"
3
- service: "test-api.example.org"
4
- base: "https://some-cas.example.org"
5
- base_authority: "CASTEST"
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.3.0
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-19 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday