mrkt 1.0.1 → 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 +4 -4
- data/.github/dependabot.yml +19 -0
- data/.github/workflows/ruby.yml +41 -0
- data/.rubocop.yml +18 -36
- data/Gemfile.lock +71 -48
- data/README.md +1 -0
- data/lib/mrkt/concerns/crud_program_members.rb +31 -0
- data/lib/mrkt/errors.rb +20 -1
- data/lib/mrkt/version.rb +1 -1
- data/lib/mrkt.rb +2 -0
- data/mrkt.gemspec +9 -5
- data/spec/concerns/authentication_spec.rb +31 -34
- data/spec/concerns/crud_activities_spec.rb +20 -13
- data/spec/concerns/crud_asset_folders_spec.rb +12 -12
- data/spec/concerns/crud_asset_static_lists_spec.rb +4 -4
- data/spec/concerns/crud_campaigns_spec.rb +18 -17
- data/spec/concerns/crud_custom_activities_spec.rb +14 -15
- data/spec/concerns/crud_custom_objects_spec.rb +15 -15
- data/spec/concerns/crud_leads_spec.rb +17 -14
- data/spec/concerns/crud_lists_spec.rb +7 -5
- data/spec/concerns/crud_program_members_spec.rb +141 -0
- data/spec/concerns/crud_programs_spec.rb +5 -5
- data/spec/concerns/import_custom_objects_spec.rb +9 -5
- data/spec/concerns/import_leads_spec.rb +9 -5
- data/spec/errors_spec.rb +9 -11
- data/spec/faraday/params_encoder_spec.rb +4 -4
- data/spec/mkto_rest_spec.rb +1 -1
- data/spec/support/initialized_client.rb +3 -3
- metadata +47 -14
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850ac5a692b131df87d8bc0a86d0bbd0c82fb38b382a41cc201e427caaba18f6
|
4
|
+
data.tar.gz: 4eb5399bad28b69658a2a7699d87e691a6d18c273061985aa4b558001e79d37a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cc5334a1161bf7fe032e5b5919e9a7b0721124965a1a2e2b6cefed6d9305550eedd0a8370f401d85d884a6b08f5fcb1c3eadb60d4ba3bba05be457f09c4e8cc
|
7
|
+
data.tar.gz: b325752b6d9cec194cc9cab4cea09744a63d9a48ebe80c774aca9d3233b8e6c07f60d644fe41d49fb0059ebf9bd625cdf2a191353c390d970ddb1e0311412533
|
@@ -0,0 +1,19 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: "bundler"
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: "weekly"
|
7
|
+
commit-message:
|
8
|
+
prefix: "chore"
|
9
|
+
include: "scope"
|
10
|
+
rebase-strategy: "disabled"
|
11
|
+
|
12
|
+
- package-ecosystem: "github-actions"
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: "daily"
|
16
|
+
commit-message:
|
17
|
+
prefix: "chore"
|
18
|
+
include: "scope"
|
19
|
+
rebase-strategy: "disabled"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [master]
|
6
|
+
pull_request:
|
7
|
+
branches: [master]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2.4.0
|
19
|
+
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- name: Update the RubyGems system software
|
27
|
+
run: gem update --system
|
28
|
+
|
29
|
+
- name: Update Bundler
|
30
|
+
run: bundle update --bundler
|
31
|
+
|
32
|
+
- name: Install dependencies
|
33
|
+
run: bundle install
|
34
|
+
|
35
|
+
- name: Run tests and publish coverage
|
36
|
+
uses: paambaati/codeclimate-action@v3.0.0
|
37
|
+
env:
|
38
|
+
COVERAGE: on
|
39
|
+
CC_TEST_REPORTER_ID: 45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
|
40
|
+
with:
|
41
|
+
coverageCommand: bundle exec rspec
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
TargetRubyVersion: 2.5
|
3
7
|
Exclude:
|
4
8
|
- 'bin/**/*'
|
5
9
|
- 'vendor/**/*'
|
10
|
+
NewCops: enable
|
6
11
|
|
7
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
8
|
-
Enabled: true
|
9
12
|
Layout/EmptyLineAfterGuardClause:
|
10
13
|
Enabled: false
|
11
14
|
Layout/FirstHashElementIndentation:
|
@@ -16,23 +19,14 @@ Layout/LineLength:
|
|
16
19
|
Max: 128
|
17
20
|
Layout/MultilineMethodCallIndentation:
|
18
21
|
EnforcedStyle: indented
|
19
|
-
Layout/SpaceAroundMethodCallOperator:
|
20
|
-
Enabled: true
|
21
|
-
|
22
|
-
Lint/DeprecatedOpenSSLConstant:
|
23
|
-
Enabled: true
|
24
|
-
Lint/MixedRegexpCaptureTypes:
|
25
|
-
Enabled: true
|
26
|
-
Lint/RaiseException:
|
27
|
-
Enabled: true
|
28
|
-
Lint/StructNewOverride:
|
29
|
-
Enabled: true
|
30
22
|
|
31
23
|
Metrics/AbcSize:
|
32
|
-
|
24
|
+
Exclude:
|
25
|
+
- 'lib/mrkt/concerns/connection.rb'
|
33
26
|
Metrics/BlockLength:
|
34
27
|
Exclude:
|
35
28
|
- 'spec/**/*'
|
29
|
+
- '**/*.gemspec'
|
36
30
|
Metrics/MethodLength:
|
37
31
|
Max: 20
|
38
32
|
Metrics/ParameterLists:
|
@@ -41,31 +35,19 @@ Metrics/ParameterLists:
|
|
41
35
|
Naming/AccessorMethodName:
|
42
36
|
Enabled: false
|
43
37
|
|
44
|
-
|
45
|
-
Enabled:
|
46
|
-
|
47
|
-
Enabled:
|
38
|
+
RSpec/FilePath:
|
39
|
+
Enabled: false
|
40
|
+
RSpec/NestedGroups:
|
41
|
+
Enabled: false
|
42
|
+
RSpec/MultipleMemoizedHelpers:
|
43
|
+
Enabled: false
|
44
|
+
RSpec/MultipleExpectations:
|
45
|
+
Exclude:
|
46
|
+
- 'spec/concerns/authentication_spec.rb'
|
47
|
+
|
48
48
|
Style/ClassAndModuleChildren:
|
49
49
|
Enabled: false
|
50
50
|
Style/Documentation:
|
51
51
|
Enabled: false
|
52
|
-
Style/ExponentialNotation:
|
53
|
-
Enabled: true
|
54
52
|
Style/FrozenStringLiteralComment:
|
55
53
|
Enabled: false
|
56
|
-
Style/HashEachMethods:
|
57
|
-
Enabled: true
|
58
|
-
Style/HashTransformKeys:
|
59
|
-
Enabled: true
|
60
|
-
Style/HashTransformValues:
|
61
|
-
Enabled: true
|
62
|
-
Style/RedundantAssignment:
|
63
|
-
Enabled: true
|
64
|
-
Style/RedundantFetchBlock:
|
65
|
-
Enabled: true
|
66
|
-
Style/RedundantRegexpCharacterClass:
|
67
|
-
Enabled: true
|
68
|
-
Style/RedundantRegexpEscape:
|
69
|
-
Enabled: true
|
70
|
-
Style/SlicingWithRange:
|
71
|
-
Enabled: true
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mrkt (1.
|
4
|
+
mrkt (1.2.1)
|
5
5
|
faraday (~> 1.0)
|
6
6
|
faraday_middleware (~> 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
11
|
+
addressable (2.8.0)
|
12
12
|
public_suffix (>= 2.0.2, < 5.0)
|
13
|
-
ast (2.4.
|
13
|
+
ast (2.4.2)
|
14
14
|
byebug (11.1.3)
|
15
15
|
coderay (1.1.3)
|
16
|
-
crack (0.4.
|
17
|
-
|
16
|
+
crack (0.4.5)
|
17
|
+
rexml
|
18
18
|
diff-lcs (1.4.4)
|
19
|
-
docile (1.
|
20
|
-
faraday (1.0
|
19
|
+
docile (1.4.0)
|
20
|
+
faraday (1.8.0)
|
21
|
+
faraday-em_http (~> 1.0)
|
22
|
+
faraday-em_synchrony (~> 1.0)
|
23
|
+
faraday-excon (~> 1.1)
|
24
|
+
faraday-httpclient (~> 1.0.1)
|
25
|
+
faraday-net_http (~> 1.0)
|
26
|
+
faraday-net_http_persistent (~> 1.1)
|
27
|
+
faraday-patron (~> 1.0)
|
28
|
+
faraday-rack (~> 1.0)
|
21
29
|
multipart-post (>= 1.2, < 3)
|
22
|
-
|
30
|
+
ruby2_keywords (>= 0.0.4)
|
31
|
+
faraday-em_http (1.0.0)
|
32
|
+
faraday-em_synchrony (1.0.0)
|
33
|
+
faraday-excon (1.1.0)
|
34
|
+
faraday-httpclient (1.0.1)
|
35
|
+
faraday-net_http (1.0.1)
|
36
|
+
faraday-net_http_persistent (1.2.0)
|
37
|
+
faraday-patron (1.0.0)
|
38
|
+
faraday-rack (1.0.0)
|
39
|
+
faraday_middleware (1.2.0)
|
23
40
|
faraday (~> 1.0)
|
24
|
-
gem-release (2.
|
41
|
+
gem-release (2.2.2)
|
25
42
|
hashdiff (1.0.1)
|
26
|
-
json (2.3.1)
|
27
43
|
method_source (1.0.0)
|
28
44
|
multipart-post (2.1.1)
|
29
|
-
parallel (1.
|
30
|
-
parser (
|
45
|
+
parallel (1.21.0)
|
46
|
+
parser (3.0.3.2)
|
31
47
|
ast (~> 2.4.1)
|
32
48
|
pry (0.13.1)
|
33
49
|
coderay (~> 1.1)
|
@@ -35,45 +51,50 @@ GEM
|
|
35
51
|
pry-byebug (3.9.0)
|
36
52
|
byebug (~> 11.0)
|
37
53
|
pry (~> 0.13.0)
|
38
|
-
public_suffix (4.0.
|
54
|
+
public_suffix (4.0.6)
|
39
55
|
rainbow (3.0.0)
|
40
|
-
rake (
|
41
|
-
regexp_parser (
|
42
|
-
rexml (3.2.
|
43
|
-
rspec (3.
|
44
|
-
rspec-core (~> 3.
|
45
|
-
rspec-expectations (~> 3.
|
46
|
-
rspec-mocks (~> 3.
|
47
|
-
rspec-core (3.
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-expectations (3.
|
56
|
+
rake (13.0.6)
|
57
|
+
regexp_parser (2.2.0)
|
58
|
+
rexml (3.2.5)
|
59
|
+
rspec (3.10.0)
|
60
|
+
rspec-core (~> 3.10.0)
|
61
|
+
rspec-expectations (~> 3.10.0)
|
62
|
+
rspec-mocks (~> 3.10.0)
|
63
|
+
rspec-core (3.10.1)
|
64
|
+
rspec-support (~> 3.10.0)
|
65
|
+
rspec-expectations (3.10.1)
|
50
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-mocks (3.
|
67
|
+
rspec-support (~> 3.10.0)
|
68
|
+
rspec-mocks (3.10.2)
|
53
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
-
rspec-support (~> 3.
|
55
|
-
rspec-support (3.
|
56
|
-
rubocop (
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-support (3.10.3)
|
72
|
+
rubocop (1.23.0)
|
57
73
|
parallel (~> 1.10)
|
58
|
-
parser (>=
|
74
|
+
parser (>= 3.0.0.0)
|
59
75
|
rainbow (>= 2.2.2, < 4.0)
|
60
|
-
regexp_parser (>= 1.
|
76
|
+
regexp_parser (>= 1.8, < 3.0)
|
61
77
|
rexml
|
62
|
-
rubocop-ast (>=
|
78
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
63
79
|
ruby-progressbar (~> 1.7)
|
64
|
-
unicode-display_width (>= 1.4.0, <
|
65
|
-
rubocop-ast (
|
66
|
-
parser (>=
|
67
|
-
|
68
|
-
|
69
|
-
|
80
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
81
|
+
rubocop-ast (1.15.0)
|
82
|
+
parser (>= 3.0.1.1)
|
83
|
+
rubocop-rake (0.6.0)
|
84
|
+
rubocop (~> 1.0)
|
85
|
+
rubocop-rspec (2.6.0)
|
86
|
+
rubocop (~> 1.19)
|
87
|
+
ruby-progressbar (1.11.0)
|
88
|
+
ruby2_keywords (0.0.5)
|
89
|
+
simplecov (0.21.2)
|
70
90
|
docile (~> 1.1)
|
71
|
-
|
72
|
-
|
73
|
-
simplecov-html (0.
|
74
|
-
|
75
|
-
|
76
|
-
|
91
|
+
simplecov-html (~> 0.11)
|
92
|
+
simplecov_json_formatter (~> 0.1)
|
93
|
+
simplecov-html (0.12.3)
|
94
|
+
simplecov_json_formatter (0.1.3)
|
95
|
+
unicode-display_width (2.1.0)
|
96
|
+
webmock (3.14.0)
|
97
|
+
addressable (>= 2.8.0)
|
77
98
|
crack (>= 0.3.2)
|
78
99
|
hashdiff (>= 0.4.0, < 2.0.0)
|
79
100
|
|
@@ -81,15 +102,17 @@ PLATFORMS
|
|
81
102
|
ruby
|
82
103
|
|
83
104
|
DEPENDENCIES
|
84
|
-
bundler (~>
|
105
|
+
bundler (~> 2.0)
|
85
106
|
gem-release (~> 2.1)
|
86
107
|
mrkt!
|
87
108
|
pry-byebug (~> 3.7)
|
88
|
-
rake (~>
|
109
|
+
rake (~> 13.0)
|
89
110
|
rspec (~> 3.2)
|
90
|
-
rubocop (~>
|
91
|
-
|
111
|
+
rubocop (~> 1.23.0)
|
112
|
+
rubocop-rake (~> 0.6.0)
|
113
|
+
rubocop-rspec (~> 2.6)
|
114
|
+
simplecov (~> 0.21.2)
|
92
115
|
webmock (~> 3.1)
|
93
116
|
|
94
117
|
BUNDLED WITH
|
95
|
-
1.
|
118
|
+
2.1.4
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
[](https://codeclimate.com/github/raszi/mrkt)
|
5
5
|
[](https://codeclimate.com/github/raszi/mrkt)
|
6
6
|
[](https://badge.fury.io/rb/mrkt)
|
7
|
+
[](https://rubygems.org/gems/mrkt)
|
7
8
|
|
8
9
|
This gem provides some level of abstraction to Marketo REST APIs. Please note that this gem is alpha quality.
|
9
10
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Mrkt
|
2
|
+
module CrudProgramMembers
|
3
|
+
def describe_program_members
|
4
|
+
get('/rest/v1/programs/members/describe.json')
|
5
|
+
end
|
6
|
+
|
7
|
+
def createupdate_program_members(program_id, lead_ids, status)
|
8
|
+
post_json("/rest/v1/programs/#{program_id}/members/status.json") do
|
9
|
+
{
|
10
|
+
statusName: status,
|
11
|
+
input: lead_ids.map { |lead_id| { leadId: lead_id } }
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_program_members(program_id, filter_type, filter_values, fields: nil, batch_size: nil, next_page_token: nil)
|
17
|
+
params = {
|
18
|
+
filterType: filter_type,
|
19
|
+
filterValues: filter_values
|
20
|
+
}
|
21
|
+
|
22
|
+
optional = {
|
23
|
+
fields: fields,
|
24
|
+
batchSize: batch_size,
|
25
|
+
nextPageToken: next_page_token
|
26
|
+
}
|
27
|
+
|
28
|
+
get("/rest/v1/programs/#{program_id}/members.json", params, optional)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/mrkt/errors.rb
CHANGED
@@ -40,7 +40,26 @@ class Mrkt::Errors
|
|
40
40
|
1011 => 'FieldNotSupported',
|
41
41
|
1012 => 'InvalidCookieValue',
|
42
42
|
1013 => 'ObjectNotFound',
|
43
|
-
1014 => 'FailedToCreateObject'
|
43
|
+
1014 => 'FailedToCreateObject',
|
44
|
+
1015 => 'LeadNotInList',
|
45
|
+
1016 => 'TooManyImports',
|
46
|
+
1017 => 'ObjectAlreadyExists',
|
47
|
+
1018 => 'CRMEnabled',
|
48
|
+
1019 => 'ImportInProgress',
|
49
|
+
1020 => 'TooManyCloneToProgram',
|
50
|
+
1021 => 'CompanyUpdateNotAllowed',
|
51
|
+
1022 => 'ObjectInUse',
|
52
|
+
1025 => 'ProgramStatusNotFound',
|
53
|
+
1026 => 'CustomObjectNotEnabled',
|
54
|
+
1027 => 'MaxActivityTypeLimitReached',
|
55
|
+
1028 => 'MaxFieldLimitReached',
|
56
|
+
1029 => 'BulkExportQuotaExceeded',
|
57
|
+
1035 => 'UnsupportedFilterType',
|
58
|
+
1036 => 'DuplicateObjectFoundInInput',
|
59
|
+
1042 => 'InvalidRunAtDate',
|
60
|
+
1048 => 'CustomObjectDiscardDraftFailed',
|
61
|
+
1049 => 'FailedToCreateActivity',
|
62
|
+
1077 => 'MergeLeadsCallFailedDueToFieldLength'
|
44
63
|
}.freeze
|
45
64
|
|
46
65
|
RESPONSE_CODE_TO_ERROR.each_value do |class_name|
|
data/lib/mrkt/version.rb
CHANGED
data/lib/mrkt.rb
CHANGED
@@ -13,6 +13,7 @@ require 'mrkt/concerns/import_custom_objects'
|
|
13
13
|
require 'mrkt/concerns/crud_custom_objects'
|
14
14
|
require 'mrkt/concerns/crud_custom_activities'
|
15
15
|
require 'mrkt/concerns/crud_programs'
|
16
|
+
require 'mrkt/concerns/crud_program_members'
|
16
17
|
require 'mrkt/concerns/crud_asset_static_lists'
|
17
18
|
require 'mrkt/concerns/crud_asset_folders'
|
18
19
|
|
@@ -30,6 +31,7 @@ module Mrkt
|
|
30
31
|
include CrudCustomObjects
|
31
32
|
include CrudCustomActivities
|
32
33
|
include CrudPrograms
|
34
|
+
include CrudProgramMembers
|
33
35
|
include CrudAssetStaticLists
|
34
36
|
include CrudAssetFolders
|
35
37
|
|
data/mrkt.gemspec
CHANGED
@@ -17,17 +17,21 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = %w[lib]
|
19
19
|
|
20
|
-
spec.
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 2.5'
|
21
23
|
|
22
24
|
spec.add_dependency 'faraday', '~> 1.0'
|
23
25
|
spec.add_dependency 'faraday_middleware', '~> 1.0'
|
24
26
|
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
28
|
spec.add_development_dependency 'gem-release', '~> 2.1'
|
27
29
|
spec.add_development_dependency 'pry-byebug', '~> 3.7'
|
28
|
-
spec.add_development_dependency 'rake', '~>
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
29
31
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
30
|
-
spec.add_development_dependency 'rubocop', '~>
|
31
|
-
spec.add_development_dependency '
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 1.23.0'
|
33
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
34
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.6'
|
35
|
+
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
32
36
|
spec.add_development_dependency 'webmock', '~> 3.1'
|
33
37
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
describe Mrkt::Authentication do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#authenticate' do
|
5
|
-
subject { client.authenticate }
|
5
|
+
subject(:action) { client.authenticate }
|
6
6
|
|
7
|
-
context 'on a successful response' do
|
7
|
+
context 'with on a successful response' do
|
8
8
|
it { is_expected.to be_success }
|
9
9
|
end
|
10
10
|
|
@@ -16,21 +16,28 @@ describe Mrkt::Authentication do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
it '
|
20
|
-
expect {
|
19
|
+
it 'raises an Error' do
|
20
|
+
expect { action }.to raise_error(Mrkt::Errors::Error, 'Bad client credentials')
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#authenticate!' do
|
26
|
-
it '
|
27
|
-
expect(client.authenticated?).
|
26
|
+
it 'authenticates the client' do
|
27
|
+
expect(client.authenticated?).not_to be true
|
28
|
+
|
28
29
|
client.authenticate!
|
29
30
|
expect(client.authenticated?).to be true
|
30
31
|
end
|
31
32
|
|
32
33
|
context 'with optional partner_id client option' do
|
33
|
-
|
34
|
+
subject(:client) { Mrkt::Client.new(client_options) }
|
35
|
+
|
36
|
+
before do
|
37
|
+
stub_request(:get, "https://#{host}/identity/oauth/token")
|
38
|
+
.with(query: query)
|
39
|
+
.to_return(json_stub(authentication_stub))
|
40
|
+
end
|
34
41
|
|
35
42
|
let(:partner_id) { SecureRandom.uuid }
|
36
43
|
|
@@ -52,23 +59,22 @@ describe Mrkt::Authentication do
|
|
52
59
|
}
|
53
60
|
end
|
54
61
|
|
55
|
-
|
56
|
-
|
57
|
-
before do
|
58
|
-
stub_request(:get, "https://#{host}/identity/oauth/token")
|
59
|
-
.with(query: query)
|
60
|
-
.to_return(json_stub(authentication_stub))
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should authenticate and then be authenticated?' do
|
64
|
-
expect(client.authenticated?).to_not be true
|
62
|
+
it 'authenticates the client' do
|
63
|
+
expect(client.authenticated?).not_to be true
|
65
64
|
client.authenticate!
|
66
65
|
expect(client.authenticated?).to be true
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
69
|
context 'when the token has expired and @retry_authentication = true' do
|
71
|
-
|
70
|
+
subject(:client) { Mrkt::Client.new(client_options) }
|
71
|
+
|
72
|
+
before do
|
73
|
+
stub_request(:get, "https://#{host}/identity/oauth/token")
|
74
|
+
.with(query: { client_id: client_id, client_secret: client_secret, grant_type: 'client_credentials' })
|
75
|
+
.to_return(json_stub(expired_authentication_stub)).times(3).then
|
76
|
+
.to_return(json_stub(valid_authentication_stub))
|
77
|
+
end
|
72
78
|
|
73
79
|
let(:retry_count) { 3 }
|
74
80
|
|
@@ -90,17 +96,8 @@ describe Mrkt::Authentication do
|
|
90
96
|
}
|
91
97
|
end
|
92
98
|
|
93
|
-
|
94
|
-
|
95
|
-
before do
|
96
|
-
stub_request(:get, "https://#{host}/identity/oauth/token")
|
97
|
-
.with(query: { client_id: client_id, client_secret: client_secret, grant_type: 'client_credentials' })
|
98
|
-
.to_return(json_stub(expired_authentication_stub)).times(3).then
|
99
|
-
.to_return(json_stub(valid_authentication_stub))
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should retry until getting valid token and then be authenticated?' do
|
103
|
-
expect(client.authenticated?).to_not be true
|
99
|
+
it 'retries until it gets a valid token' do
|
100
|
+
expect(client.authenticated?).not_to be true
|
104
101
|
client.authenticate!
|
105
102
|
expect(client.authenticated?).to be true
|
106
103
|
end
|
@@ -108,8 +105,8 @@ describe Mrkt::Authentication do
|
|
108
105
|
context 'when retry_authentication_count is low' do
|
109
106
|
let(:retry_count) { 2 }
|
110
107
|
|
111
|
-
it '
|
112
|
-
expect(client.authenticated?).
|
108
|
+
it 'stops retrying after a while' do
|
109
|
+
expect(client.authenticated?).not_to be true
|
113
110
|
|
114
111
|
expect { client.authenticate! }.to raise_error(Mrkt::Errors::Error, 'Client not authenticated')
|
115
112
|
end
|
@@ -120,11 +117,11 @@ describe Mrkt::Authentication do
|
|
120
117
|
describe '#authenticated?' do
|
121
118
|
subject { client.authenticated? }
|
122
119
|
|
123
|
-
context '
|
120
|
+
context 'when authentication has not been done' do
|
124
121
|
it { is_expected.to be_falsey }
|
125
122
|
end
|
126
123
|
|
127
|
-
context '
|
124
|
+
context 'when authentication has been done' do
|
128
125
|
before { client.authenticate }
|
129
126
|
|
130
127
|
it { is_expected.to be_truthy }
|