brine-dsl 0.11.0 → 0.12.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 +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +38 -19
- data/brine-dsl.gemspec +8 -8
- data/lib/brine.rb +12 -25
- data/lib/brine/assertions.rb +123 -0
- data/lib/brine/cleaning_up.rb +28 -18
- data/lib/brine/client_building.rb +22 -22
- data/lib/brine/coercing.rb +15 -15
- data/lib/brine/hooks.rb +1 -1
- data/lib/brine/mustache_expanding.rb +54 -23
- data/lib/brine/performing.rb +51 -25
- data/lib/brine/requesting.rb +97 -26
- data/lib/brine/selecting.rb +239 -35
- data/lib/brine/test_steps.rb +16 -19
- data/lib/brine/transforming.rb +30 -24
- data/lib/brine/type_checking.rb +25 -14
- metadata +7 -14
- data/lib/brine/rest_steps.rb +0 -119
- data/lib/brine/step_definitions/assertions.rb +0 -50
- data/lib/brine/step_definitions/assignment.rb +0 -42
- data/lib/brine/step_definitions/cleanup.rb +0 -4
- data/lib/brine/step_definitions/perform.rb +0 -16
- data/lib/brine/step_definitions/request_construction.rb +0 -28
- data/lib/brine/step_definitions/selection.rb +0 -49
- data/lib/brine/util.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a06ae7bee936f1179d45feff647eba71a2bb10832bba886861e0da74b81b68d5
|
4
|
+
data.tar.gz: 35dcc3f58a97e4ff814e84bed8e40d091405eb4a05f5b321212f3d0ed16b2a67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5105f8cd19c33eaf6f31d4daf366cb5219e5000452c50754a9fe570cc388ea9b3d2a42b51ee704bb8da70534822c86faa253461a7892172faa1f0961f53119d7
|
7
|
+
data.tar.gz: 15a09e7bd10ae9bfc4692ae7d35bf31a0a0f51e15b599b4c2d67184fe7a6e7742537b4da41922a1951c642b7a01e097dbf6f4f60cc885faa717cc2946a624a6e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.5
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brine-dsl (0.
|
5
|
-
cucumber (
|
4
|
+
brine-dsl (0.12.0)
|
5
|
+
cucumber (= 4.0.0.rc.1)
|
6
6
|
faraday (~> 0.12)
|
7
7
|
faraday_middleware (~> 0.12)
|
8
8
|
jsonpath (~> 0.8)
|
@@ -13,24 +13,42 @@ PATH
|
|
13
13
|
GEM
|
14
14
|
remote: http://rubygems.org/
|
15
15
|
specs:
|
16
|
+
backports (3.15.0)
|
16
17
|
builder (3.2.3)
|
17
|
-
|
18
|
+
c21e (1.1.9)
|
19
|
+
cucumber (4.0.0.rc.1)
|
18
20
|
builder (>= 2.1.2)
|
19
|
-
cucumber-core (~>
|
20
|
-
cucumber-
|
21
|
-
|
22
|
-
|
21
|
+
cucumber-core (~> 4.0)
|
22
|
+
cucumber-expressions (~> 6.0, >= 6.0.1)
|
23
|
+
cucumber-formatter-dots (~> 1.0)
|
24
|
+
cucumber-wire (~> 1.0)
|
25
|
+
diff-lcs (~> 1.3)
|
26
|
+
gherkin (~> 6.0)
|
23
27
|
multi_json (>= 1.7.5, < 2.0)
|
24
28
|
multi_test (>= 0.1.2)
|
25
|
-
cucumber-core (
|
26
|
-
|
27
|
-
|
29
|
+
cucumber-core (4.0.0)
|
30
|
+
backports (>= 3.8.0)
|
31
|
+
cucumber-tag_expressions (~> 1.1.0)
|
32
|
+
gherkin (~> 6.0)
|
33
|
+
cucumber-expressions (6.6.2)
|
34
|
+
cucumber-formatter-dots (1.1.0)
|
35
|
+
cucumber-messages
|
36
|
+
os
|
37
|
+
cucumber-messages (2.1.2)
|
38
|
+
google-protobuf (>= 3.2, <= 3.7)
|
39
|
+
cucumber-tag_expressions (1.1.1)
|
40
|
+
cucumber-wire (1.0.0)
|
41
|
+
cucumber-core (~> 4.0)
|
42
|
+
cucumber-expressions (~> 6.0)
|
28
43
|
diff-lcs (1.3)
|
29
|
-
faraday (0.
|
44
|
+
faraday (0.16.2)
|
30
45
|
multipart-post (>= 1.2, < 3)
|
31
46
|
faraday_middleware (0.13.1)
|
32
47
|
faraday (>= 0.7.4, < 1.0)
|
33
|
-
gherkin (
|
48
|
+
gherkin (6.0.17)
|
49
|
+
c21e (~> 1.1.9)
|
50
|
+
cucumber-messages (~> 2.1.2)
|
51
|
+
google-protobuf (3.7.0)
|
34
52
|
jsonpath (0.9.9)
|
35
53
|
multi_json
|
36
54
|
to_regexp (~> 0.2.1)
|
@@ -40,27 +58,28 @@ GEM
|
|
40
58
|
multi_xml (0.6.0)
|
41
59
|
multipart-post (2.1.1)
|
42
60
|
mustache (1.1.0)
|
43
|
-
oauth2 (1.4.
|
44
|
-
faraday (>= 0.8, <
|
61
|
+
oauth2 (1.4.2)
|
62
|
+
faraday (>= 0.8, < 2.0)
|
45
63
|
jwt (>= 1.0, < 3.0)
|
46
64
|
multi_json (~> 1.3)
|
47
65
|
multi_xml (~> 0.5)
|
48
66
|
rack (>= 1.2, < 3)
|
67
|
+
os (1.0.1)
|
49
68
|
rack (2.0.7)
|
50
|
-
rake (12.3.
|
69
|
+
rake (12.3.3)
|
51
70
|
rspec (3.8.0)
|
52
71
|
rspec-core (~> 3.8.0)
|
53
72
|
rspec-expectations (~> 3.8.0)
|
54
73
|
rspec-mocks (~> 3.8.0)
|
55
|
-
rspec-core (3.8.
|
74
|
+
rspec-core (3.8.2)
|
56
75
|
rspec-support (~> 3.8.0)
|
57
|
-
rspec-expectations (3.8.
|
76
|
+
rspec-expectations (3.8.5)
|
58
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
59
78
|
rspec-support (~> 3.8.0)
|
60
|
-
rspec-mocks (3.8.
|
79
|
+
rspec-mocks (3.8.2)
|
61
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
81
|
rspec-support (~> 3.8.0)
|
63
|
-
rspec-support (3.8.
|
82
|
+
rspec-support (3.8.3)
|
64
83
|
to_regexp (0.2.1)
|
65
84
|
|
66
85
|
PLATFORMS
|
data/brine-dsl.gemspec
CHANGED
@@ -13,15 +13,15 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.required_ruby_version = '>= 2.3.0'
|
15
15
|
|
16
|
-
s.add_runtime_dependency 'cucumber',
|
17
|
-
s.add_runtime_dependency 'mustache',
|
18
|
-
s.add_runtime_dependency 'oauth2',
|
19
|
-
s.add_runtime_dependency 'rspec',
|
20
|
-
s.add_runtime_dependency 'jsonpath',
|
21
|
-
s.add_runtime_dependency 'faraday',
|
22
|
-
s.add_runtime_dependency 'faraday_middleware',
|
16
|
+
s.add_runtime_dependency 'cucumber', '4.0.0.rc.1'
|
17
|
+
s.add_runtime_dependency 'mustache', '~> 1.0'
|
18
|
+
s.add_runtime_dependency 'oauth2', '~> 1.4'
|
19
|
+
s.add_runtime_dependency 'rspec', '~> 3.7'
|
20
|
+
s.add_runtime_dependency 'jsonpath', '~> 0.8'
|
21
|
+
s.add_runtime_dependency 'faraday', '~> 0.12'
|
22
|
+
s.add_runtime_dependency 'faraday_middleware', '~> 0.12'
|
23
23
|
|
24
|
-
s.add_development_dependency 'rake',
|
24
|
+
s.add_development_dependency 'rake', '~> 12.3'
|
25
25
|
|
26
26
|
s.files = `git ls-files`.split("\n")
|
27
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/brine.rb
CHANGED
@@ -1,37 +1,24 @@
|
|
1
1
|
##
|
2
2
|
# @file brine.rb
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# The primary goal of this file is to load all resources needed to use brine.
|
6
|
-
# A secondary goal which should inform how that is done is that loading this
|
7
|
-
# file by itself should provide new objects but not otherwise impact existing
|
8
|
-
# state such as by modifying the World or defining any Steps, Transforms, etc.
|
9
|
-
# Those types of changes should be done by @ref #brine_mix.
|
3
|
+
# Support loading Brine into the World.
|
10
4
|
##
|
11
5
|
|
12
|
-
require 'brine/cleaning_up'
|
13
|
-
require 'brine/mustache_expanding'
|
14
|
-
require 'brine/performing'
|
15
|
-
require 'brine/requesting'
|
16
|
-
require 'brine/selecting'
|
17
|
-
require 'brine/type_checking'
|
18
|
-
|
19
6
|
##
|
20
|
-
# Load
|
7
|
+
# Load all Brine files into the World.
|
21
8
|
#
|
22
9
|
# Expected to be called as `World(brine_mix)`
|
23
|
-
#
|
10
|
+
#
|
11
|
+
# @return [module] Return the `Brine` module.
|
24
12
|
##
|
25
13
|
def brine_mix
|
26
|
-
require 'brine/
|
27
|
-
require 'brine/
|
28
|
-
require 'brine/step_definitions/assertions'
|
29
|
-
require 'brine/step_definitions/cleanup'
|
30
|
-
require 'brine/step_definitions/perform'
|
31
|
-
require 'brine/step_definitions/selection'
|
32
|
-
|
33
|
-
require 'brine/transforming'
|
14
|
+
require 'brine/assertions'
|
15
|
+
require 'brine/cleaning_up'
|
34
16
|
require 'brine/hooks'
|
35
|
-
|
17
|
+
require 'brine/mustache_expanding'
|
18
|
+
require 'brine/performing'
|
19
|
+
require 'brine/requesting'
|
20
|
+
require 'brine/selecting'
|
21
|
+
require 'brine/transforming'
|
22
|
+
require 'brine/type_checking'
|
36
23
|
Brine
|
37
24
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
##
|
2
|
+
# @file assertions.rb
|
3
|
+
# Define assertion steps to be used with a Selector
|
4
|
+
##
|
5
|
+
|
6
|
+
require 'brine/transforming'
|
7
|
+
|
8
|
+
##
|
9
|
+
# Assert that the selected value is equal to the parameter.
|
10
|
+
#
|
11
|
+
# @param value [Object] Specify the value which the selection should equal.
|
12
|
+
##
|
13
|
+
Then('it is equal to {grave_param}') do |value|
|
14
|
+
perform { selector.assert_that(value, binding) {|v| eq v} }
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# Assert that the selected value is equal to the docstring.
|
19
|
+
#
|
20
|
+
# @param multi [String] Specify the value which the selection should equal.
|
21
|
+
##
|
22
|
+
Then('it is equal to:') do |value|
|
23
|
+
perform { selector.assert_that(transformed_parameter(value), binding) {|v| eq v} }
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Assert that the selected value matches the parameter.
|
28
|
+
#
|
29
|
+
# @param value [Object] Specify the pattern which the selection should match.
|
30
|
+
##
|
31
|
+
Then('it is matching {grave_param}') do |value|
|
32
|
+
perform { selector.assert_that(value, binding) {|v| match v} }
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Assert that the selected value matches the docstring.
|
37
|
+
#
|
38
|
+
# @param value [String] Specify the pattern which the selection should match.
|
39
|
+
##
|
40
|
+
Then('it is matching:') do |value|
|
41
|
+
perform { selector.assert_that(transformed_parameter(value), binding) {|v| match v} }
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Assert that the selected value is greater than the parameter.
|
46
|
+
#
|
47
|
+
# @param value [Object] Specify the value which the selection should be greater than.
|
48
|
+
##
|
49
|
+
Then('it is greater than {grave_param}') do |value|
|
50
|
+
perform { selector.assert_that(value, binding) {|v| be > v} }
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Assert that the selected value is greater than or equal to the parameter.
|
55
|
+
#
|
56
|
+
# @param value [Object] Specify the value which the selection should be greater than or equal to.
|
57
|
+
##
|
58
|
+
Then('it is greater than or equal to {grave_param}') do |value|
|
59
|
+
perform { selector.assert_that(value, binding) {|v| be >= v} }
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Assert that the selected value is less than the parameter.
|
64
|
+
#
|
65
|
+
# @param value [Object] Specify the value which the selection should be less than.
|
66
|
+
##
|
67
|
+
Then('it is less than {grave_param}') do |value|
|
68
|
+
perform { selector.assert_that(value, binding) {|v| be < v} }
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Assert that the selected value is less than or equal to the parameter.
|
73
|
+
#
|
74
|
+
# @param value [Object] Specify the value which the selection should be less than or equal to.
|
75
|
+
##
|
76
|
+
Then('it is less than or equal to {grave_param}') do |value|
|
77
|
+
perform { selector.assert_that(value, binding) {|v| be <= v} }
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Assert that the selected value is empty.
|
82
|
+
#
|
83
|
+
# This will be satisfied by nil or any object which returns a truthy #empty?
|
84
|
+
##
|
85
|
+
Then('it is empty') do
|
86
|
+
perform { selector.assert_that(nil, binding) do
|
87
|
+
satisfy{|i| i.nil? || (i.respond_to?(:empty?) && i.empty?) }
|
88
|
+
end }
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Assert that the selected value includes the parameter.
|
93
|
+
#
|
94
|
+
# @param value [Object] Specify content which should be within the selection.
|
95
|
+
##
|
96
|
+
Then('it is including {grave_param}') do |value|
|
97
|
+
perform { selector.assert_that(value, binding) {|v| include v } }
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Assert that the selected value includes the docstring.
|
102
|
+
#
|
103
|
+
# @param value [String] Specify content which should be within the selection.
|
104
|
+
##
|
105
|
+
Then('it is including:') do |value|
|
106
|
+
perform { selector.assert_that(transformed_parameter(value), binding) {|v| include v } }
|
107
|
+
end
|
108
|
+
|
109
|
+
##
|
110
|
+
# Asserted that the selected value has a length equal to the parameter.
|
111
|
+
#
|
112
|
+
# TODO: It may be better to support selection of the length attribute, maybe
|
113
|
+
# chain to another dynamic step such as `is of lenth that is ...`
|
114
|
+
#
|
115
|
+
# @param length [Object] Specify the length which the selection should have.
|
116
|
+
##
|
117
|
+
Then('it is of length {grave_param}') do |length|
|
118
|
+
perform do
|
119
|
+
selector.assert_that(length, binding) do |l|
|
120
|
+
satisfy{|i| i.respond_to?(:length) && i.length == l}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/brine/cleaning_up.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
# @file cleaning_up.rb
|
3
3
|
# Clean up resources created during test run.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
# in a hook.
|
5
|
+
# Issue DELETE calls for all tracked URLs: will normally be triggered in a hook.
|
7
6
|
#
|
8
7
|
# The present approach for this is to explicitly track created resources to
|
9
8
|
# which DELETE calls will be sent. Cleaning up of resources will be given some
|
@@ -13,9 +12,9 @@
|
|
13
12
|
module Brine
|
14
13
|
|
15
14
|
##
|
16
|
-
#
|
15
|
+
# Provide resource cleanup.
|
17
16
|
#
|
18
|
-
#
|
17
|
+
# Expose methods to keep a stack of DeleteCommands corresponding to each
|
19
18
|
# created resource which are then popped and invoked to perform the cleanup.
|
20
19
|
#
|
21
20
|
# LIFO behavior is adopted as it is more likely to preserve integrity,
|
@@ -24,7 +23,7 @@ module Brine
|
|
24
23
|
module CleaningUp
|
25
24
|
|
26
25
|
##
|
27
|
-
#
|
26
|
+
# Capture the delete command which will be executed as part of cleaning up.
|
28
27
|
#
|
29
28
|
# The command will be retried a specified number of times if an unsuccessful status code is received.
|
30
29
|
##
|
@@ -33,10 +32,11 @@ module Brine
|
|
33
32
|
##
|
34
33
|
# Construct a command with the required paramters to perform the delete.
|
35
34
|
#
|
36
|
-
# @param [Faraday::Connection, #delete]
|
37
|
-
# @param [String]
|
38
|
-
# @param [Array<Integer>]
|
39
|
-
#
|
35
|
+
# @param client [Faraday::Connection, #delete] Provide the Faraday client which will send the delete message.
|
36
|
+
# @param path [String] Specify the path of the resource to be deleted.
|
37
|
+
# @param oks [Array<Integer>] Indicate response status codes which should be considered successful)
|
38
|
+
# (defaults to [200,204]).
|
39
|
+
# @param attempts [Integer] Specify the number of times this command should be tried (defaults to 3).
|
40
40
|
##
|
41
41
|
def initialize(client, path, oks: [200,204], attempts: 3)
|
42
42
|
@client = client
|
@@ -48,14 +48,14 @@ module Brine
|
|
48
48
|
##
|
49
49
|
# Issue the delete based on the parameters provided during construction.
|
50
50
|
#
|
51
|
-
# @return [Boolean] true if a successful response is obtained, otherwise false.
|
51
|
+
# @return [Boolean] Return true if a successful response is obtained, otherwise false.
|
52
52
|
##
|
53
53
|
def cleanup
|
54
54
|
for _ in 1..@attempts
|
55
55
|
begin
|
56
56
|
resp=@client.delete(@path)
|
57
57
|
return true if @oks.include?(resp.status)
|
58
|
-
rescue ex
|
58
|
+
rescue Exception => ex
|
59
59
|
STDERR.puts "WARNING: #{ex}"
|
60
60
|
end
|
61
61
|
end
|
@@ -73,7 +73,7 @@ module Brine
|
|
73
73
|
# used to issue the creation requests and could therefore be passed to this
|
74
74
|
# method prior to use.
|
75
75
|
#
|
76
|
-
# @param [Faraday::Connection, #delete]
|
76
|
+
# @param client [Faraday::Connection, #delete] Provide the client to DELETE subsequently tracked resources.
|
77
77
|
##
|
78
78
|
def set_cleaning_client(client)
|
79
79
|
@client = client
|
@@ -82,7 +82,7 @@ module Brine
|
|
82
82
|
##
|
83
83
|
# Record resource to be later cleaned (pushes a DeleteCommand).
|
84
84
|
#
|
85
|
-
# @param [String]
|
85
|
+
# @param path [String] Specify the path for the created resource: will be issued a DELETE.
|
86
86
|
##
|
87
87
|
def track_created_resource(path)
|
88
88
|
cleanup_commands << DeleteCommand.new(@client, path)
|
@@ -91,7 +91,7 @@ module Brine
|
|
91
91
|
##
|
92
92
|
# Clean recorded resources (normally after a test run).
|
93
93
|
#
|
94
|
-
# @return [Boolean] true if all commands succeeded successfully, otherwise false.
|
94
|
+
# @return [Boolean] Return true if all commands succeeded successfully, otherwise false.
|
95
95
|
##
|
96
96
|
def cleanup_created_resources
|
97
97
|
# Avoid the use of any short circuiting folds.
|
@@ -101,11 +101,9 @@ module Brine
|
|
101
101
|
private
|
102
102
|
|
103
103
|
##
|
104
|
-
#
|
104
|
+
# Return the array which serves as the stack of DeleteCommands.
|
105
105
|
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
# @return [Array<DeleteCommand>]
|
106
|
+
# @return [Array<DeleteCommand>] Return the existing or new list of commands to execute for cleanup.
|
109
107
|
##
|
110
108
|
def cleanup_commands
|
111
109
|
@cleanup_commands ||= []
|
@@ -118,3 +116,15 @@ module Brine
|
|
118
116
|
##
|
119
117
|
include CleaningUp
|
120
118
|
end
|
119
|
+
|
120
|
+
require 'brine/transforming'
|
121
|
+
|
122
|
+
##
|
123
|
+
# Record a resource path which should be cleaned up.
|
124
|
+
#
|
125
|
+
# @param path [Object] Specify the path which should be DELETED.
|
126
|
+
# This should be a String or a Template.
|
127
|
+
##
|
128
|
+
When('a resource is created at {grave_param}') do |path|
|
129
|
+
perform { track_created_resource(path) }
|
130
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
##
|
2
2
|
# @file client_building.rb
|
3
|
-
#
|
3
|
+
# Construct a Faraday connection.
|
4
4
|
##
|
5
5
|
|
6
6
|
module Brine
|
7
7
|
|
8
8
|
##
|
9
|
-
#
|
9
|
+
# Allow construction of a Faraday connection with some common middleware.
|
10
10
|
##
|
11
11
|
module ClientBuilding
|
12
12
|
require 'oauth2'
|
13
13
|
|
14
14
|
##
|
15
|
-
#
|
15
|
+
# Define OAuth2 middleware configuration.
|
16
16
|
#
|
17
17
|
# This is essentially a thin wrapper around `https://github.com/oauth-xx/oauth2`
|
18
18
|
# to provide a mini-DSL and to facilitate the middleware configuration.
|
@@ -20,12 +20,12 @@ module Brine
|
|
20
20
|
class OAuth2Params
|
21
21
|
|
22
22
|
##
|
23
|
-
#
|
23
|
+
# Store the token which has been retrieved from the authorization server.
|
24
24
|
##
|
25
25
|
attr_accessor :token
|
26
26
|
|
27
27
|
##
|
28
|
-
#
|
28
|
+
# Specify the type of OAuth2 token which will be retrieved.
|
29
29
|
#
|
30
30
|
# Currently only `bearer` is supported.
|
31
31
|
##
|
@@ -44,14 +44,14 @@ module Brine
|
|
44
44
|
# The parameters are forwarded to OAuth2::Client.new which is used to
|
45
45
|
# retrieve the token.
|
46
46
|
#
|
47
|
-
# @param [String]
|
48
|
-
# @param [String]
|
49
|
-
# @param [Hash]
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# @option opts [String] :site
|
53
|
-
# @option opts [String] :token_url
|
54
|
-
# @option opts [Hash] :ssl SSL options to pass through to the transport client,
|
47
|
+
# @param id [String] Provide the login id credential with which to request authorization.
|
48
|
+
# @param secret [String] Provide the secret credential with which to request authorization.
|
49
|
+
# @param opts [Hash] Define options with which to create a client,
|
50
|
+
# see `https://github.com/oauth-xx/oauth2/blob/master/lib/oauth2/client.rb` for full details,
|
51
|
+
# common options will be duplicated here.
|
52
|
+
# @option opts [String] :site Specify the OAuth2 authorization server from which to request a token.
|
53
|
+
# @option opts [String] :token_url Specify the absolute or relative path to the Token endpoint on the authorization server.
|
54
|
+
# @option opts [Hash] :ssl Provide SSL options to pass through to the transport client,
|
55
55
|
# `{verify: false}` may be useful for self-signed certificates.
|
56
56
|
##
|
57
57
|
def fetch_from(id, secret, opts)
|
@@ -61,10 +61,10 @@ module Brine
|
|
61
61
|
end
|
62
62
|
|
63
63
|
##
|
64
|
-
# Acquire an OAuth2 token
|
64
|
+
# Acquire an OAuth2 token with the provided configuration block.
|
65
65
|
#
|
66
|
-
# @param [Block]
|
67
|
-
#
|
66
|
+
# @param [Block] Provide logic to execute with an OAuth2Params receiver;
|
67
|
+
# this will normally involve an OAuth2Params#fetch_from call.
|
68
68
|
##
|
69
69
|
def use_oauth2_token(&block)
|
70
70
|
@oauth2 = OAuth2Params.new
|
@@ -72,7 +72,7 @@ module Brine
|
|
72
72
|
end
|
73
73
|
|
74
74
|
##
|
75
|
-
#
|
75
|
+
# Expose the handlers/middleware that will be wired while constructing a client.
|
76
76
|
#
|
77
77
|
# This is represented as list of functions so that it can be more easily customized for
|
78
78
|
# unexpected use cases.
|
@@ -98,13 +98,13 @@ module Brine
|
|
98
98
|
end
|
99
99
|
|
100
100
|
##
|
101
|
-
#
|
101
|
+
# Return a client which will send requests to `host`.
|
102
102
|
#
|
103
|
-
#
|
103
|
+
# This will configure the client using `#connection_handlers`.
|
104
104
|
#
|
105
|
-
# @param [String]
|
106
|
-
# @param [String]
|
107
|
-
# @return [Faraday::Connection]
|
105
|
+
# @param host [String] Specify the hostname to which this client will send requests.
|
106
|
+
# @param logging [String] Indicate the desired logging level for this client.
|
107
|
+
# @return [Faraday::Connection] Return the configured client connection.
|
108
108
|
##
|
109
109
|
def client_for_host(host, logging: ENV['BRINE_LOG_HTTP'])
|
110
110
|
@logging = logging
|