campact_user_service 4.2.0 → 4.3.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/CHANGELOG.md +7 -0
- data/Gemfile +2 -2
- data/Rakefile +4 -45
- data/VERSION +1 -1
- metadata +47 -79
- data/.github/workflows/ci.yml +0 -24
- data/campact_user_service.gemspec +0 -67
- data/spec/account_spec.rb +0 -221
- data/spec/campact_user_service_spec.rb +0 -36
- data/spec/client_spec.rb +0 -219
- data/spec/prefill_forms_spec.rb +0 -76
- data/spec/session_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7db0b278ef7f32ba9d87395a935a3959ca21ac3be353e7abf9023920538494fe
|
|
4
|
+
data.tar.gz: 66a4d524b87d00baf939aea54fc3f84057c7adc0bdfa89724ec3ffb69b4e0bd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f58e5c726bfaca8ae536b29ff782f4f03175ce2acaeda9bb9dfe090c56f457d63c669aff1814528525096284abd6dd2e029994cf26c0f9f34d5452d2df878711
|
|
7
|
+
data.tar.gz: 2b3f93386c2c7f2cf78de43d7caea3c119be7cb3e0cec28b71eed5de7cc3b8a50aa6c7ac5d6935a1f1f4704177a55b16dbd1b5a45f8be3042e2cc054bd743835
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.1
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
gem 'rotp', '~> 6'
|
|
4
|
-
gem 'faraday', '~>
|
|
4
|
+
gem 'faraday', '~> 2.14'
|
|
5
5
|
gem 'json', '~> 2.1'
|
|
6
6
|
|
|
7
7
|
group :development do
|
|
8
|
+
gem 'rake'
|
|
8
9
|
gem 'byebug', '>= 0'
|
|
9
10
|
gem 'rspec', '>= 0'
|
|
10
11
|
gem 'shoulda', '>= 0'
|
|
11
12
|
gem 'webmock', '>= 0'
|
|
12
13
|
gem 'rdoc', '~> 6.0', '>= 6.0.4'
|
|
13
|
-
gem 'juwelier', git: 'https://github.com/flajann2/juwelier.git'
|
|
14
14
|
gem 'simplecov', '= 0.16.1'
|
|
15
15
|
gem 'pry-byebug', '~> 3.6'
|
|
16
16
|
gem 'faraday-detailed_logger', '~> 2.1', '>= 2.1.2'
|
data/Rakefile
CHANGED
|
@@ -1,49 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
4
|
-
require 'bundler'
|
|
5
|
-
begin
|
|
6
|
-
Bundler.setup(:default, :development)
|
|
7
|
-
rescue Bundler::BundlerError => e
|
|
8
|
-
$stderr.puts e.message
|
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
-
exit e.status_code
|
|
11
|
-
end
|
|
12
|
-
require 'rake'
|
|
13
|
-
|
|
14
|
-
require 'juwelier'
|
|
15
|
-
Juwelier::Tasks.new do |gem|
|
|
16
|
-
gem.name = "campact_user_service"
|
|
17
|
-
gem.homepage = "http://github.com/controlshift/campact_user_service"
|
|
18
|
-
gem.license = "MIT"
|
|
19
|
-
gem.summary = %Q{Ruby wrapper for Campact User Service}
|
|
20
|
-
gem.description = %Q{Ruby wrapper for Campact User Service}
|
|
21
|
-
gem.email = "hello@controlshiftlabs.com"
|
|
22
|
-
gem.authors = ["ControlShift"]
|
|
23
|
-
|
|
24
|
-
# dependencies defined in Gemfile
|
|
25
|
-
end
|
|
26
|
-
Juwelier::RubygemsDotOrgTasks.new
|
|
27
|
-
|
|
28
|
-
require 'rspec/core'
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
29
4
|
require 'rspec/core/rake_task'
|
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
31
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
35
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
36
|
-
spec.rcov = true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
task :default => :spec
|
|
40
5
|
|
|
41
|
-
|
|
42
|
-
Rake::RDocTask.new do |rdoc|
|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
44
7
|
|
|
45
|
-
|
|
46
|
-
rdoc.title = "krautbuster_api #{version}"
|
|
47
|
-
rdoc.rdoc_files.include('README*')
|
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
49
|
-
end
|
|
8
|
+
task default: :spec
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.
|
|
1
|
+
4.3.0
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: campact_user_service
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ControlShift
|
|
@@ -9,34 +9,20 @@ bindir: bin
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: rotp
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - "~>"
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '6'
|
|
19
|
-
type: :runtime
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - "~>"
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '6'
|
|
26
12
|
- !ruby/object:Gem::Dependency
|
|
27
13
|
name: faraday
|
|
28
14
|
requirement: !ruby/object:Gem::Requirement
|
|
29
15
|
requirements:
|
|
30
16
|
- - "~>"
|
|
31
17
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
18
|
+
version: '2.14'
|
|
33
19
|
type: :runtime
|
|
34
20
|
prerelease: false
|
|
35
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
22
|
requirements:
|
|
37
23
|
- - "~>"
|
|
38
24
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
25
|
+
version: '2.14'
|
|
40
26
|
- !ruby/object:Gem::Dependency
|
|
41
27
|
name: json
|
|
42
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,21 +38,21 @@ dependencies:
|
|
|
52
38
|
- !ruby/object:Gem::Version
|
|
53
39
|
version: '2.1'
|
|
54
40
|
- !ruby/object:Gem::Dependency
|
|
55
|
-
name:
|
|
41
|
+
name: rotp
|
|
56
42
|
requirement: !ruby/object:Gem::Requirement
|
|
57
43
|
requirements:
|
|
58
|
-
- - "
|
|
44
|
+
- - "~>"
|
|
59
45
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
61
|
-
type: :
|
|
46
|
+
version: '6'
|
|
47
|
+
type: :runtime
|
|
62
48
|
prerelease: false
|
|
63
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
50
|
requirements:
|
|
65
|
-
- - "
|
|
51
|
+
- - "~>"
|
|
66
52
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
53
|
+
version: '6'
|
|
68
54
|
- !ruby/object:Gem::Dependency
|
|
69
|
-
name:
|
|
55
|
+
name: byebug
|
|
70
56
|
requirement: !ruby/object:Gem::Requirement
|
|
71
57
|
requirements:
|
|
72
58
|
- - ">="
|
|
@@ -80,33 +66,33 @@ dependencies:
|
|
|
80
66
|
- !ruby/object:Gem::Version
|
|
81
67
|
version: '0'
|
|
82
68
|
- !ruby/object:Gem::Dependency
|
|
83
|
-
name:
|
|
69
|
+
name: faraday-detailed_logger
|
|
84
70
|
requirement: !ruby/object:Gem::Requirement
|
|
85
71
|
requirements:
|
|
86
|
-
- - "
|
|
72
|
+
- - "~>"
|
|
87
73
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
74
|
+
version: '2.1'
|
|
89
75
|
type: :development
|
|
90
76
|
prerelease: false
|
|
91
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
78
|
requirements:
|
|
93
|
-
- - "
|
|
79
|
+
- - "~>"
|
|
94
80
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
81
|
+
version: '2.1'
|
|
96
82
|
- !ruby/object:Gem::Dependency
|
|
97
|
-
name:
|
|
83
|
+
name: pry-byebug
|
|
98
84
|
requirement: !ruby/object:Gem::Requirement
|
|
99
85
|
requirements:
|
|
100
|
-
- - "
|
|
86
|
+
- - "~>"
|
|
101
87
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
88
|
+
version: '3.6'
|
|
103
89
|
type: :development
|
|
104
90
|
prerelease: false
|
|
105
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
92
|
requirements:
|
|
107
|
-
- - "
|
|
93
|
+
- - "~>"
|
|
108
94
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
95
|
+
version: '3.6'
|
|
110
96
|
- !ruby/object:Gem::Dependency
|
|
111
97
|
name: rdoc
|
|
112
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,9 +100,6 @@ dependencies:
|
|
|
114
100
|
- - "~>"
|
|
115
101
|
- !ruby/object:Gem::Version
|
|
116
102
|
version: '6.0'
|
|
117
|
-
- - ">="
|
|
118
|
-
- !ruby/object:Gem::Version
|
|
119
|
-
version: 6.0.4
|
|
120
103
|
type: :development
|
|
121
104
|
prerelease: false
|
|
122
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -124,11 +107,8 @@ dependencies:
|
|
|
124
107
|
- - "~>"
|
|
125
108
|
- !ruby/object:Gem::Version
|
|
126
109
|
version: '6.0'
|
|
127
|
-
- - ">="
|
|
128
|
-
- !ruby/object:Gem::Version
|
|
129
|
-
version: 6.0.4
|
|
130
110
|
- !ruby/object:Gem::Dependency
|
|
131
|
-
name:
|
|
111
|
+
name: rspec
|
|
132
112
|
requirement: !ruby/object:Gem::Requirement
|
|
133
113
|
requirements:
|
|
134
114
|
- - ">="
|
|
@@ -142,55 +122,49 @@ dependencies:
|
|
|
142
122
|
- !ruby/object:Gem::Version
|
|
143
123
|
version: '0'
|
|
144
124
|
- !ruby/object:Gem::Dependency
|
|
145
|
-
name:
|
|
125
|
+
name: rubocop
|
|
146
126
|
requirement: !ruby/object:Gem::Requirement
|
|
147
127
|
requirements:
|
|
148
|
-
- -
|
|
128
|
+
- - ">="
|
|
149
129
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: 0
|
|
130
|
+
version: '0'
|
|
151
131
|
type: :development
|
|
152
132
|
prerelease: false
|
|
153
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
154
134
|
requirements:
|
|
155
|
-
- -
|
|
135
|
+
- - ">="
|
|
156
136
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: 0
|
|
137
|
+
version: '0'
|
|
158
138
|
- !ruby/object:Gem::Dependency
|
|
159
|
-
name:
|
|
139
|
+
name: shoulda
|
|
160
140
|
requirement: !ruby/object:Gem::Requirement
|
|
161
141
|
requirements:
|
|
162
|
-
- - "
|
|
142
|
+
- - ">="
|
|
163
143
|
- !ruby/object:Gem::Version
|
|
164
|
-
version: '
|
|
144
|
+
version: '0'
|
|
165
145
|
type: :development
|
|
166
146
|
prerelease: false
|
|
167
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
168
148
|
requirements:
|
|
169
|
-
- - "
|
|
149
|
+
- - ">="
|
|
170
150
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '
|
|
151
|
+
version: '0'
|
|
172
152
|
- !ruby/object:Gem::Dependency
|
|
173
|
-
name:
|
|
153
|
+
name: simplecov
|
|
174
154
|
requirement: !ruby/object:Gem::Requirement
|
|
175
155
|
requirements:
|
|
176
|
-
- -
|
|
177
|
-
- !ruby/object:Gem::Version
|
|
178
|
-
version: '2.1'
|
|
179
|
-
- - ">="
|
|
156
|
+
- - '='
|
|
180
157
|
- !ruby/object:Gem::Version
|
|
181
|
-
version:
|
|
158
|
+
version: 0.16.1
|
|
182
159
|
type: :development
|
|
183
160
|
prerelease: false
|
|
184
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
185
162
|
requirements:
|
|
186
|
-
- -
|
|
187
|
-
- !ruby/object:Gem::Version
|
|
188
|
-
version: '2.1'
|
|
189
|
-
- - ">="
|
|
163
|
+
- - '='
|
|
190
164
|
- !ruby/object:Gem::Version
|
|
191
|
-
version:
|
|
165
|
+
version: 0.16.1
|
|
192
166
|
- !ruby/object:Gem::Dependency
|
|
193
|
-
name:
|
|
167
|
+
name: webmock
|
|
194
168
|
requirement: !ruby/object:Gem::Requirement
|
|
195
169
|
requirements:
|
|
196
170
|
- - ">="
|
|
@@ -204,23 +178,21 @@ dependencies:
|
|
|
204
178
|
- !ruby/object:Gem::Version
|
|
205
179
|
version: '0'
|
|
206
180
|
description: Ruby wrapper for Campact User Service
|
|
207
|
-
email:
|
|
181
|
+
email:
|
|
182
|
+
- talk@controlshiftlabs.com
|
|
208
183
|
executables: []
|
|
209
184
|
extensions: []
|
|
210
|
-
extra_rdoc_files:
|
|
211
|
-
- LICENSE
|
|
212
|
-
- README.md
|
|
185
|
+
extra_rdoc_files: []
|
|
213
186
|
files:
|
|
214
|
-
- ".github/workflows/ci.yml"
|
|
215
187
|
- ".rubocop.yml"
|
|
216
188
|
- ".ruby-gemset"
|
|
217
189
|
- ".ruby-version"
|
|
190
|
+
- CHANGELOG.md
|
|
218
191
|
- Gemfile
|
|
219
192
|
- LICENSE
|
|
220
193
|
- README.md
|
|
221
194
|
- Rakefile
|
|
222
195
|
- VERSION
|
|
223
|
-
- campact_user_service.gemspec
|
|
224
196
|
- example.rb
|
|
225
197
|
- lib/campact_user_service.rb
|
|
226
198
|
- lib/campact_user_service/account.rb
|
|
@@ -228,16 +200,12 @@ files:
|
|
|
228
200
|
- lib/campact_user_service/prefill_forms.rb
|
|
229
201
|
- lib/campact_user_service/response_error.rb
|
|
230
202
|
- lib/campact_user_service/session.rb
|
|
231
|
-
|
|
232
|
-
- spec/campact_user_service_spec.rb
|
|
233
|
-
- spec/client_spec.rb
|
|
234
|
-
- spec/prefill_forms_spec.rb
|
|
235
|
-
- spec/session_spec.rb
|
|
236
|
-
- spec/spec_helper.rb
|
|
237
|
-
homepage: http://github.com/controlshift/campact_user_service
|
|
203
|
+
homepage: https://github.com/controlshift/campact_user_service
|
|
238
204
|
licenses:
|
|
239
205
|
- MIT
|
|
240
|
-
metadata:
|
|
206
|
+
metadata:
|
|
207
|
+
homepage_uri: https://github.com/controlshift/campact_user_service
|
|
208
|
+
source_code_uri: https://github.com/controlshift/campact_user_service
|
|
241
209
|
rdoc_options: []
|
|
242
210
|
require_paths:
|
|
243
211
|
- lib
|
|
@@ -245,14 +213,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
245
213
|
requirements:
|
|
246
214
|
- - ">="
|
|
247
215
|
- !ruby/object:Gem::Version
|
|
248
|
-
version:
|
|
216
|
+
version: 3.0.0
|
|
249
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
218
|
requirements:
|
|
251
219
|
- - ">="
|
|
252
220
|
- !ruby/object:Gem::Version
|
|
253
221
|
version: '0'
|
|
254
222
|
requirements: []
|
|
255
|
-
rubygems_version:
|
|
223
|
+
rubygems_version: 4.0.3
|
|
256
224
|
specification_version: 4
|
|
257
225
|
summary: Ruby wrapper for Campact User Service
|
|
258
226
|
test_files: []
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on: [push]
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
test:
|
|
6
|
-
runs-on: ubuntu-latest
|
|
7
|
-
steps:
|
|
8
|
-
- uses: actions/checkout@v2
|
|
9
|
-
- uses: ruby/setup-ruby@v1
|
|
10
|
-
with:
|
|
11
|
-
ruby-version: 3.4
|
|
12
|
-
bundler-cache: true
|
|
13
|
-
- run: bundle install
|
|
14
|
-
- run: bundle exec rspec
|
|
15
|
-
rubocop:
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v2
|
|
19
|
-
- uses: ruby/setup-ruby@v1
|
|
20
|
-
with:
|
|
21
|
-
ruby-version: 3.4
|
|
22
|
-
bundler-cache: true
|
|
23
|
-
- run: bundle install
|
|
24
|
-
- run: bundle exec rubocop
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Generated by juwelier
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: campact_user_service 4.2.0 ruby lib
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |s|
|
|
8
|
-
s.name = "campact_user_service".freeze
|
|
9
|
-
s.version = "4.2.0".freeze
|
|
10
|
-
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
|
-
s.require_paths = ["lib".freeze]
|
|
13
|
-
s.authors = ["ControlShift".freeze]
|
|
14
|
-
s.date = "1980-01-02"
|
|
15
|
-
s.description = "Ruby wrapper for Campact User Service".freeze
|
|
16
|
-
s.email = "hello@controlshiftlabs.com".freeze
|
|
17
|
-
s.extra_rdoc_files = [
|
|
18
|
-
"LICENSE",
|
|
19
|
-
"README.md"
|
|
20
|
-
]
|
|
21
|
-
s.files = [
|
|
22
|
-
".github/workflows/ci.yml",
|
|
23
|
-
".rubocop.yml",
|
|
24
|
-
".ruby-gemset",
|
|
25
|
-
".ruby-version",
|
|
26
|
-
"Gemfile",
|
|
27
|
-
"LICENSE",
|
|
28
|
-
"README.md",
|
|
29
|
-
"Rakefile",
|
|
30
|
-
"VERSION",
|
|
31
|
-
"campact_user_service.gemspec",
|
|
32
|
-
"example.rb",
|
|
33
|
-
"lib/campact_user_service.rb",
|
|
34
|
-
"lib/campact_user_service/account.rb",
|
|
35
|
-
"lib/campact_user_service/client.rb",
|
|
36
|
-
"lib/campact_user_service/prefill_forms.rb",
|
|
37
|
-
"lib/campact_user_service/response_error.rb",
|
|
38
|
-
"lib/campact_user_service/session.rb",
|
|
39
|
-
"spec/account_spec.rb",
|
|
40
|
-
"spec/campact_user_service_spec.rb",
|
|
41
|
-
"spec/client_spec.rb",
|
|
42
|
-
"spec/prefill_forms_spec.rb",
|
|
43
|
-
"spec/session_spec.rb",
|
|
44
|
-
"spec/spec_helper.rb"
|
|
45
|
-
]
|
|
46
|
-
s.homepage = "http://github.com/controlshift/campact_user_service".freeze
|
|
47
|
-
s.licenses = ["MIT".freeze]
|
|
48
|
-
s.rubygems_version = "3.6.9".freeze
|
|
49
|
-
s.summary = "Ruby wrapper for Campact User Service".freeze
|
|
50
|
-
|
|
51
|
-
s.specification_version = 4
|
|
52
|
-
|
|
53
|
-
s.add_runtime_dependency(%q<rotp>.freeze, ["~> 6".freeze])
|
|
54
|
-
s.add_runtime_dependency(%q<faraday>.freeze, ["~> 1.0".freeze])
|
|
55
|
-
s.add_runtime_dependency(%q<json>.freeze, ["~> 2.1".freeze])
|
|
56
|
-
s.add_development_dependency(%q<byebug>.freeze, [">= 0".freeze])
|
|
57
|
-
s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
|
|
58
|
-
s.add_development_dependency(%q<shoulda>.freeze, [">= 0".freeze])
|
|
59
|
-
s.add_development_dependency(%q<webmock>.freeze, [">= 0".freeze])
|
|
60
|
-
s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.0".freeze, ">= 6.0.4".freeze])
|
|
61
|
-
s.add_development_dependency(%q<juwelier>.freeze, [">= 0".freeze])
|
|
62
|
-
s.add_development_dependency(%q<simplecov>.freeze, ["= 0.16.1".freeze])
|
|
63
|
-
s.add_development_dependency(%q<pry-byebug>.freeze, ["~> 3.6".freeze])
|
|
64
|
-
s.add_development_dependency(%q<faraday-detailed_logger>.freeze, ["~> 2.1".freeze, ">= 2.1.2".freeze])
|
|
65
|
-
s.add_development_dependency(%q<rubocop>.freeze, [">= 0".freeze])
|
|
66
|
-
end
|
|
67
|
-
|
data/spec/account_spec.rb
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CampactUserService::Account do
|
|
4
|
-
let(:client) { CampactUserService::Client.new(host: 'test.com') }
|
|
5
|
-
let(:session_id) { '123456abcdef' }
|
|
6
|
-
let(:session_cookie_name) { 'cus-session' }
|
|
7
|
-
let(:user_id) { 'test@example.org' }
|
|
8
|
-
|
|
9
|
-
subject {
|
|
10
|
-
CampactUserService::Account.new(client, user_id)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
before(:each) do
|
|
14
|
-
WebMock.disable_net_connect!
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe '#exists?' do
|
|
18
|
-
it 'should return true where a valid user object is returned' do
|
|
19
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
20
|
-
.to_return(body: {
|
|
21
|
-
"external_id": "id-123"
|
|
22
|
-
}.to_json)
|
|
23
|
-
|
|
24
|
-
expect(subject.exists?).to be_truthy
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'should not return true where an invalid user object is returned' do
|
|
28
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
29
|
-
.to_return(body: {
|
|
30
|
-
"error": true
|
|
31
|
-
}.to_json)
|
|
32
|
-
|
|
33
|
-
expect(subject.exists?).to be_falsey
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe 'URI escaping' do
|
|
38
|
-
it 'should escape the user ID in any requests' do
|
|
39
|
-
malicious_user_id = "\11\15"
|
|
40
|
-
malicious_subject = CampactUserService::Account.new(
|
|
41
|
-
client,
|
|
42
|
-
malicious_user_id
|
|
43
|
-
)
|
|
44
|
-
stub_request(:get, "https://test.com/v1/accounts/%09%0D")
|
|
45
|
-
.to_return(body: '', status: 404)
|
|
46
|
-
|
|
47
|
-
expect(malicious_subject.exists?).to be_falsey
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'should escape "/" characters' do
|
|
51
|
-
malicious_user_id = "foo@example.com/secrets"
|
|
52
|
-
malicious_subject = CampactUserService::Account.new(
|
|
53
|
-
client,
|
|
54
|
-
malicious_user_id
|
|
55
|
-
)
|
|
56
|
-
stub_request(:get, "https://test.com/v1/accounts/foo@example.com%2Fsecrets")
|
|
57
|
-
.to_return(body: '', status: 404)
|
|
58
|
-
|
|
59
|
-
expect(malicious_subject.exists?).to be_falsey
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe '#name' do
|
|
64
|
-
it 'should retrieve all of the names and gender of the user' do
|
|
65
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
66
|
-
.to_return(body: {
|
|
67
|
-
"name": {
|
|
68
|
-
"firstname": "Alice",
|
|
69
|
-
"lastname": "Wu",
|
|
70
|
-
"gender": "female",
|
|
71
|
-
"title": "PhD",
|
|
72
|
-
"fullname": "PhD Alice Wu"
|
|
73
|
-
},
|
|
74
|
-
}.to_json)
|
|
75
|
-
|
|
76
|
-
name = subject.name
|
|
77
|
-
expect(name['firstname']).to eq 'Alice'
|
|
78
|
-
expect(name['lastname']).to eq 'Wu'
|
|
79
|
-
expect(name['gender']).to eq 'female'
|
|
80
|
-
expect(name['title']).to eq 'PhD'
|
|
81
|
-
expect(name['fullname']).to eq 'PhD Alice Wu'
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe '#email' do
|
|
86
|
-
it 'should retrieve the email address of the user' do
|
|
87
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
88
|
-
.to_return(body: {
|
|
89
|
-
"emailaddress": {
|
|
90
|
-
"emailaddress": "foobar@example.com"
|
|
91
|
-
}
|
|
92
|
-
}.to_json)
|
|
93
|
-
|
|
94
|
-
email = subject.email
|
|
95
|
-
expect(email).to eq 'foobar@example.com'
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it 'should return nil where no email address is set' do
|
|
99
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
100
|
-
.to_return(body: {
|
|
101
|
-
"emailaddress": {}
|
|
102
|
-
}.to_json)
|
|
103
|
-
|
|
104
|
-
email = subject.email
|
|
105
|
-
expect(email).to be_nil
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
describe '#address' do
|
|
110
|
-
it 'should retrieve the address of the user' do
|
|
111
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
112
|
-
.to_return(body: {
|
|
113
|
-
"postaladdress": {
|
|
114
|
-
"street": "123 Fake Street",
|
|
115
|
-
"postalcode": "E1234",
|
|
116
|
-
"locality": "London",
|
|
117
|
-
"countrycode": "GB"
|
|
118
|
-
}
|
|
119
|
-
}.to_json)
|
|
120
|
-
|
|
121
|
-
address = subject.address
|
|
122
|
-
expect(address['street']).to eq '123 Fake Street'
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
describe '#subscribed_to_newsletter?' do
|
|
127
|
-
it 'should be true where the user is subscribed' do
|
|
128
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
129
|
-
.to_return(body: {
|
|
130
|
-
"emailaddress": {
|
|
131
|
-
"emailaddress": "foobar@example.com",
|
|
132
|
-
"subscriptions": [{"type": "newsletter"}]
|
|
133
|
-
}
|
|
134
|
-
}.to_json)
|
|
135
|
-
|
|
136
|
-
expect(subject.subscribed_to_newsletter?).to be_truthy
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it 'should be false where the user is not subscribed' do
|
|
140
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
141
|
-
.to_return(body: {
|
|
142
|
-
"emailaddress": {
|
|
143
|
-
"emailaddress": "foobar@example.com",
|
|
144
|
-
"subscriptions": []
|
|
145
|
-
}
|
|
146
|
-
}.to_json)
|
|
147
|
-
|
|
148
|
-
expect(subject.subscribed_to_newsletter?).to be_falsey
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it 'should be false where user subscription is different than newsletter' do
|
|
152
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
153
|
-
.to_return(body: {
|
|
154
|
-
"emailaddress": {
|
|
155
|
-
"emailaddress": "foobar@example.com",
|
|
156
|
-
"subscriptions": [{"type": "foo"}]
|
|
157
|
-
}
|
|
158
|
-
}.to_json)
|
|
159
|
-
|
|
160
|
-
expect(subject.subscribed_to_newsletter?).to be_falsey
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
describe '#allow_prefill?' do
|
|
165
|
-
it 'should allow prefilling where the user has opted-in' do
|
|
166
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
167
|
-
.to_return(body: {
|
|
168
|
-
"prefill_forms_state": "allowed"
|
|
169
|
-
}.to_json)
|
|
170
|
-
|
|
171
|
-
expect(subject.allow_prefill?).to be_truthy
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it 'should not allow prefilling where the user has not decided' do
|
|
175
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
176
|
-
.to_return(body: {
|
|
177
|
-
"prefill_forms_state": "undecided"
|
|
178
|
-
}.to_json)
|
|
179
|
-
|
|
180
|
-
expect(subject.allow_prefill?).to be_falsey
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
it 'should not allow prefilling where the user has opted out' do
|
|
184
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
185
|
-
.to_return(body: {
|
|
186
|
-
"prefill_forms_state": "forbidden"
|
|
187
|
-
}.to_json)
|
|
188
|
-
|
|
189
|
-
expect(subject.allow_prefill?).to be_falsey
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
describe "#prefill_undecided?" do
|
|
194
|
-
it 'should be true if the user has not decided' do
|
|
195
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
196
|
-
.to_return(body: {
|
|
197
|
-
"prefill_forms_state": "undecided"
|
|
198
|
-
}.to_json)
|
|
199
|
-
|
|
200
|
-
expect(subject.prefill_undecided?).to be_truthy
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
it 'should be false if the user has opted-in' do
|
|
204
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
205
|
-
.to_return(body: {
|
|
206
|
-
"prefill_forms_state": "allowed"
|
|
207
|
-
}.to_json)
|
|
208
|
-
|
|
209
|
-
expect(subject.prefill_undecided?).to be_falsey
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
it 'should be false if the user has opted out' do
|
|
213
|
-
stub_request(:get, "https://test.com/v1/accounts/#{user_id}")
|
|
214
|
-
.to_return(body: {
|
|
215
|
-
"prefill_forms_state": "forbidden"
|
|
216
|
-
}.to_json)
|
|
217
|
-
|
|
218
|
-
expect(subject.prefill_undecided?).to be_falsey
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CampactUserService do
|
|
4
|
-
subject { CampactUserService }
|
|
5
|
-
|
|
6
|
-
describe '.session' do
|
|
7
|
-
it 'should create Session instance with correct arguments' do
|
|
8
|
-
options = { foo: 'bar', foo2: 'bar2' }
|
|
9
|
-
client = double
|
|
10
|
-
expect(CampactUserService::Client).to receive(:new).with(options).and_return(client)
|
|
11
|
-
session_id = '123abcd'
|
|
12
|
-
session_cookie_name = 'campact-session'
|
|
13
|
-
session_api = double
|
|
14
|
-
expect(CampactUserService::Session).to receive(:new).with(client, session_id, session_cookie_name).and_return(session_api)
|
|
15
|
-
|
|
16
|
-
session = subject.session(session_id, session_cookie_name, options)
|
|
17
|
-
|
|
18
|
-
expect(session).to be(session_api)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe '.account' do
|
|
23
|
-
it 'should create Account instance with correct arguments' do
|
|
24
|
-
options = { foo: 'bar', foo2: 'bar2' }
|
|
25
|
-
client = double
|
|
26
|
-
expect(CampactUserService::Client).to receive(:new).with(options).and_return(client)
|
|
27
|
-
account_id = '189b6864-d58a-4f49-8370-4ae0b854a40e'
|
|
28
|
-
account_api = double
|
|
29
|
-
expect(CampactUserService::Account).to receive(:new).with(client, account_id).and_return(account_api)
|
|
30
|
-
|
|
31
|
-
account = subject.account(account_id, options)
|
|
32
|
-
|
|
33
|
-
expect(account).to be(account_api)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
data/spec/client_spec.rb
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CampactUserService::Client do
|
|
4
|
-
describe 'initialization' do
|
|
5
|
-
let(:options) {
|
|
6
|
-
{
|
|
7
|
-
host: 'demo.campact.de',
|
|
8
|
-
port: '10003',
|
|
9
|
-
faraday: { a_custom_option: 'foo', adapter: :an_adapter }
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
let(:faraday_builder) { double(adapter: true) }
|
|
13
|
-
|
|
14
|
-
before :each do
|
|
15
|
-
allow(faraday_builder).to receive(:request).with(:json)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'should initialize connection from options' do
|
|
19
|
-
expect(faraday_builder).to receive(:adapter).with(:an_adapter)
|
|
20
|
-
|
|
21
|
-
expect(Faraday).to receive(:new) do |endpoint, initialization_options|
|
|
22
|
-
expect(endpoint).to eq 'https://demo.campact.de:10003'
|
|
23
|
-
expect(initialization_options[:a_custom_option]).to eq 'foo'
|
|
24
|
-
end.and_yield(faraday_builder)
|
|
25
|
-
|
|
26
|
-
CampactUserService::Client.new(options)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'should use default faraday options for connection' do
|
|
30
|
-
expect(Faraday).to receive(:new) do |_endpoint, initialization_options|
|
|
31
|
-
expect(initialization_options[:ssl][:verify]).to be_truthy
|
|
32
|
-
expect(initialization_options[:headers]['Accept']).to eq "application/json;q=0.1"
|
|
33
|
-
expect(initialization_options[:headers]['Accept-Charset']).to eq "utf-8"
|
|
34
|
-
expect(initialization_options[:headers]['User-Agent']).to eq 'campact_user_service'
|
|
35
|
-
end.and_yield(faraday_builder)
|
|
36
|
-
|
|
37
|
-
CampactUserService::Client.new(options)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'should allow overriding default options' do
|
|
41
|
-
options[:faraday][:ssl] = {verify: false}
|
|
42
|
-
options[:faraday][:headers] = {'Accept'=>'custom-accept-header', 'Accept-Charset'=>'custom-accept-charset-header', 'User-Agent'=>'custom-user-agent-header'}
|
|
43
|
-
|
|
44
|
-
expect(Faraday).to receive(:new) do |_endpoint, initialization_options|
|
|
45
|
-
expect(initialization_options[:ssl][:verify]).to be_falsey
|
|
46
|
-
expect(initialization_options[:headers]['Accept']).to eq 'custom-accept-header'
|
|
47
|
-
expect(initialization_options[:headers]['Accept-Charset']).to eq 'custom-accept-charset-header'
|
|
48
|
-
expect(initialization_options[:headers]['User-Agent']).to eq 'custom-user-agent-header'
|
|
49
|
-
end.and_yield(faraday_builder)
|
|
50
|
-
|
|
51
|
-
CampactUserService::Client.new(options)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
shared_examples 'error handling' do
|
|
56
|
-
[310, 410, 510].each do |unexpected_status_code|
|
|
57
|
-
it 'should raise error if status code is 3xx, 4xx or 5xx' do
|
|
58
|
-
expect(request_builder).to receive(:url).with('/foo/bar')
|
|
59
|
-
expect(request_builder_options).to receive(:timeout=).with(CampactUserService::Client::TIMEOUT)
|
|
60
|
-
expect(request_builder_options).to receive(:open_timeout=).with(CampactUserService::Client::OPEN_TIMEOUT)
|
|
61
|
-
allow(response).to receive(:status).and_return(unexpected_status_code)
|
|
62
|
-
allow(response).to receive(:body).and_return('An error occurred')
|
|
63
|
-
|
|
64
|
-
expect { subject.send(method_under_test, '/foo/bar') }.to raise_error do |error|
|
|
65
|
-
expect(error).to be_an_instance_of CampactUserService::ResponseError
|
|
66
|
-
expect(error.status_code).to eq(unexpected_status_code)
|
|
67
|
-
expect(error.body).to eq('An error occurred')
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'should return nil if status code is 404' do
|
|
73
|
-
expect(request_builder).to receive(:url).with('/foo/bar')
|
|
74
|
-
expect(request_builder_options).to receive(:timeout=).with(CampactUserService::Client::TIMEOUT)
|
|
75
|
-
expect(request_builder_options).to receive(:open_timeout=).with(CampactUserService::Client::OPEN_TIMEOUT)
|
|
76
|
-
allow(response).to receive(:status).and_return(404)
|
|
77
|
-
|
|
78
|
-
response = subject.send(method_under_test, '/foo/bar')
|
|
79
|
-
|
|
80
|
-
expect(response).to be_nil
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe '#get_request' do
|
|
85
|
-
let(:connection) { double }
|
|
86
|
-
let(:request_builder) { double }
|
|
87
|
-
let(:request_builder_options) { double }
|
|
88
|
-
let(:response) { double(body: '') }
|
|
89
|
-
let(:method_under_test) { :get_request }
|
|
90
|
-
|
|
91
|
-
subject { CampactUserService::Client.new(host: 'demo.campact.de') }
|
|
92
|
-
|
|
93
|
-
before :each do
|
|
94
|
-
expect(Faraday).to receive(:new).and_yield(double(adapter: true, request: true)).and_return(connection)
|
|
95
|
-
expect(request_builder).to receive(:options).at_least(:once).and_return(request_builder_options)
|
|
96
|
-
expect(connection).to receive(:get).and_yield(request_builder).and_return(response)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
include_examples 'error handling'
|
|
100
|
-
|
|
101
|
-
it 'should perform get request on provided path and return true if response is 204' do
|
|
102
|
-
expect(request_builder).to receive(:url).with('/foo/bar')
|
|
103
|
-
expect(request_builder_options).to receive(:timeout=).with(CampactUserService::Client::TIMEOUT)
|
|
104
|
-
expect(request_builder_options).to receive(:open_timeout=).with(CampactUserService::Client::OPEN_TIMEOUT)
|
|
105
|
-
allow(response).to receive(:status).and_return(204)
|
|
106
|
-
|
|
107
|
-
expect(subject.get_request('/foo/bar')).to be_truthy
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context 'stubbed request builder' do
|
|
111
|
-
let(:headers_builder) { double }
|
|
112
|
-
|
|
113
|
-
before :each do
|
|
114
|
-
allow(request_builder).to receive(:url).with('/foo/bar')
|
|
115
|
-
allow(request_builder_options).to receive(:timeout=).with(CampactUserService::Client::TIMEOUT)
|
|
116
|
-
allow(request_builder_options).to receive(:open_timeout=).with(CampactUserService::Client::OPEN_TIMEOUT)
|
|
117
|
-
allow(request_builder).to receive(:headers).and_return(headers_builder)
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it 'should set cookies sent as string' do
|
|
121
|
-
expect(headers_builder).to receive(:[]=).with('Cookie', 'foo=bar;xyz=abc')
|
|
122
|
-
allow(response).to receive(:status).and_return(200)
|
|
123
|
-
|
|
124
|
-
subject.get_request('/foo/bar', cookies: 'foo=bar;xyz=abc')
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it 'should set cookies sent as hash' do
|
|
128
|
-
expect(headers_builder).to receive(:[]=).with('Cookie', 'foo=bar;xyz=abc;')
|
|
129
|
-
allow(response).to receive(:status).and_return(200)
|
|
130
|
-
|
|
131
|
-
subject.get_request('/foo/bar', cookies: {'foo' => 'bar', 'xyz' => 'abc'})
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it 'should set TOTP authorization header' do
|
|
135
|
-
allow(response).to receive(:status).and_return(200)
|
|
136
|
-
allow(response).to receive(:body).and_return(nil)
|
|
137
|
-
|
|
138
|
-
totp_secret = ROTP::Base32.encode('shh! a secret!')
|
|
139
|
-
|
|
140
|
-
totp = double
|
|
141
|
-
expect(totp).to receive(:now).and_return('totp_token')
|
|
142
|
-
expect(ROTP::TOTP).to receive(:new).with(totp_secret, hash_including(digest: 'sha256', digits: 8, interval: 30)).and_return(totp)
|
|
143
|
-
|
|
144
|
-
expect(headers_builder).to receive(:[]=).with('authorization', 'Token api_user:totp_token')
|
|
145
|
-
|
|
146
|
-
subject = CampactUserService::Client.new(host: 'demo.campact.de', topt_authorization: {user: 'api_user', secret: 'shh! a secret!'})
|
|
147
|
-
|
|
148
|
-
subject.get_request('/foo/bar')
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it 'should parse JSON response on successful response' do
|
|
152
|
-
allow(response).to receive(:status).and_return(200)
|
|
153
|
-
allow(response).to receive(:body).and_return({a_field: 'foo', another_field: 'bar'}.to_json)
|
|
154
|
-
|
|
155
|
-
response = subject.get_request('/foo/bar')
|
|
156
|
-
|
|
157
|
-
expect(response).not_to be_nil
|
|
158
|
-
expect(response['a_field']).to eq 'foo'
|
|
159
|
-
expect(response['another_field']).to eq 'bar'
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
describe '#delete_request' do
|
|
165
|
-
let(:connection) { double }
|
|
166
|
-
let(:request_builder) { double }
|
|
167
|
-
let(:request_builder_options) { double }
|
|
168
|
-
let(:response) { double(body: '') }
|
|
169
|
-
let(:method_under_test) { :delete_request }
|
|
170
|
-
|
|
171
|
-
subject { CampactUserService::Client.new(host: 'demo.campact.de') }
|
|
172
|
-
|
|
173
|
-
before :each do
|
|
174
|
-
expect(Faraday).to receive(:new).and_yield(double(adapter: true, request: true)).and_return(connection)
|
|
175
|
-
expect(request_builder).to receive(:options).at_least(:once).and_return(request_builder_options)
|
|
176
|
-
expect(connection).to receive(:delete).and_yield(request_builder).and_return(response)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
include_examples 'error handling'
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
describe '#patch_request' do
|
|
183
|
-
let(:connection) { double }
|
|
184
|
-
let(:request_builder) { double }
|
|
185
|
-
let(:request_builder_options) { double }
|
|
186
|
-
let(:response) { double(body: '') }
|
|
187
|
-
let(:method_under_test) { :patch_request }
|
|
188
|
-
|
|
189
|
-
subject { CampactUserService::Client.new(host: 'demo.campact.de') }
|
|
190
|
-
|
|
191
|
-
context 'with faraday stubbed' do
|
|
192
|
-
before :each do
|
|
193
|
-
expect(Faraday).to receive(:new).and_yield(double(adapter: true, request: true)).and_return(connection)
|
|
194
|
-
expect(request_builder).to receive(:options).at_least(:once).and_return(request_builder_options)
|
|
195
|
-
expect(connection).to receive(:patch).and_yield(request_builder).and_return(response)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
include_examples 'error handling'
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
context 'with HTTP connection stubbed' do
|
|
202
|
-
before(:each) do
|
|
203
|
-
WebMock.disable_net_connect!
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it 'should send the body included in options' do
|
|
207
|
-
stub_patch =
|
|
208
|
-
stub_request(:patch, 'https://demo.campact.de/foo/bar')
|
|
209
|
-
.with(body: { a_field: 'foo', another_field: 'bar' }.to_json,
|
|
210
|
-
headers: { 'Content-Type'=>'application/json' })
|
|
211
|
-
.to_return(status: 204)
|
|
212
|
-
|
|
213
|
-
subject.patch_request('/foo/bar', body: { a_field: 'foo', another_field: 'bar' })
|
|
214
|
-
|
|
215
|
-
assert_requested(stub_patch)
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
data/spec/prefill_forms_spec.rb
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CampactUserService::PrefillForms do
|
|
4
|
-
let(:client) { CampactUserService::Client.new(host: 'test.com') }
|
|
5
|
-
let(:account_id) { 'abcdef123456fedcba' }
|
|
6
|
-
|
|
7
|
-
subject do
|
|
8
|
-
CampactUserService::PrefillForms.new(client, account_id)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
before(:each) do
|
|
12
|
-
WebMock.disable_net_connect!
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe '#update_prefill_forms' do
|
|
16
|
-
it 'should update the prefill forms state with just the state and petition slug' do
|
|
17
|
-
stub_patch_prefill_forms = stub_request(:patch, "https://test.com/v1/prefill_forms?account_id=#{account_id}")
|
|
18
|
-
.with(body: {
|
|
19
|
-
prefill_forms: {
|
|
20
|
-
state: 'allowed',
|
|
21
|
-
slug: 'save-the-forest'
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
.to_return(status: 204)
|
|
25
|
-
|
|
26
|
-
result = subject.update_prefill_forms(prefill_forms_state: 'allowed', campaign_slug: 'save-the-forest')
|
|
27
|
-
|
|
28
|
-
assert_requested(stub_patch_prefill_forms)
|
|
29
|
-
expect(result).to be_truthy
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'should update the prefill forms state including UTM parameters' do
|
|
33
|
-
utm_params = {
|
|
34
|
-
utm_campaign: 'a campaign',
|
|
35
|
-
utm_content: 'a content',
|
|
36
|
-
utm_medium: 'a medium',
|
|
37
|
-
utm_source: 'a source',
|
|
38
|
-
utm_term: 'a term',
|
|
39
|
-
utm_placement: 'a placement',
|
|
40
|
-
utm_target: 'a target'
|
|
41
|
-
}
|
|
42
|
-
stub_patch_prefill_forms = stub_request(:patch, "https://test.com/v1/prefill_forms?account_id=#{account_id}")
|
|
43
|
-
.with(body: {
|
|
44
|
-
prefill_forms: {
|
|
45
|
-
state: 'allowed',
|
|
46
|
-
slug: 'save-the-forest'
|
|
47
|
-
}.merge(utm_params)
|
|
48
|
-
})
|
|
49
|
-
.to_return(status: 204)
|
|
50
|
-
|
|
51
|
-
subject.update_prefill_forms(prefill_forms_state: 'allowed', campaign_slug: 'save-the-forest', **utm_params)
|
|
52
|
-
|
|
53
|
-
assert_requested(stub_patch_prefill_forms)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'should escape special characters in account_id' do
|
|
57
|
-
unescaped_account_id = 'user@example.com'
|
|
58
|
-
escaped_account_id = 'user%40example.com'
|
|
59
|
-
|
|
60
|
-
prefill_forms = CampactUserService::PrefillForms.new(client, unescaped_account_id)
|
|
61
|
-
|
|
62
|
-
stub_patch_prefill_forms = stub_request(:patch, "https://test.com/v1/prefill_forms?account_id=#{escaped_account_id}")
|
|
63
|
-
.with(body: {
|
|
64
|
-
prefill_forms: {
|
|
65
|
-
state: 'allowed',
|
|
66
|
-
slug: 'save-the-forest'
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
.to_return(status: 204)
|
|
70
|
-
|
|
71
|
-
prefill_forms.update_prefill_forms(prefill_forms_state: 'allowed', campaign_slug: 'save-the-forest')
|
|
72
|
-
|
|
73
|
-
assert_requested(stub_patch_prefill_forms)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
data/spec/session_spec.rb
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe CampactUserService::Session do
|
|
4
|
-
let(:client) { CampactUserService::Client.new(host: 'test.com') }
|
|
5
|
-
let(:session_id) { '123456abcdef' }
|
|
6
|
-
let(:session_cookie_name) { 'cus-session' }
|
|
7
|
-
|
|
8
|
-
subject { CampactUserService::Session.new(client, session_id, session_cookie_name) }
|
|
9
|
-
|
|
10
|
-
describe '#account_id' do
|
|
11
|
-
it 'should be present' do
|
|
12
|
-
stub_request(:get, 'https://test.com/v1/sessions')
|
|
13
|
-
.with(headers: {'Cookie' => "cus-session=#{session_id};"})
|
|
14
|
-
.to_return(body: {account_id: '189b6864-d58a-4f49-8370-4ae0b854a40e'}.to_json)
|
|
15
|
-
|
|
16
|
-
expect(subject.account_id).to eq('189b6864-d58a-4f49-8370-4ae0b854a40e')
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe '#has_soft_login_session?' do
|
|
21
|
-
it 'should be true where permission level is limited' do
|
|
22
|
-
stub_request(:get, 'https://test.com/v1/sessions')
|
|
23
|
-
.with(headers: {'Cookie' => "cus-session=#{session_id};"})
|
|
24
|
-
.to_return(body: {permission_level: 'limited'}.to_json)
|
|
25
|
-
|
|
26
|
-
expect(subject.has_soft_login_session?).to be_truthy
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'should be false where permission level is full' do
|
|
30
|
-
stub_request(:get, 'https://test.com/v1/sessions')
|
|
31
|
-
.with(headers: {'Cookie' => "cus-session=#{session_id};"})
|
|
32
|
-
.to_return(body: {permission_level: 'full'}.to_json)
|
|
33
|
-
|
|
34
|
-
expect(subject.has_soft_login_session?).to be_falsey
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '#has_hard_login_session?' do
|
|
39
|
-
it 'should be true where permission level is full' do
|
|
40
|
-
stub_request(:get, 'https://test.com/v1/sessions')
|
|
41
|
-
.with(headers: {'Cookie' => "cus-session=#{session_id};"})
|
|
42
|
-
.to_return(body: {permission_level: 'full'}.to_json)
|
|
43
|
-
|
|
44
|
-
expect(subject.has_hard_login_session?).to be_truthy
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'should be false where permission level is limited' do
|
|
48
|
-
stub_request(:get, 'https://test.com/v1/sessions')
|
|
49
|
-
.with(headers: {'Cookie' => "cus-session=#{session_id};"})
|
|
50
|
-
.to_return(body: {permission_level: 'limited'}.to_json)
|
|
51
|
-
|
|
52
|
-
expect(subject.has_hard_login_session?).to be_falsey
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
describe '#destroy' do
|
|
57
|
-
it 'should perform DELETE request' do
|
|
58
|
-
stub_request(:delete, 'https://test.com/v1/sessions')
|
|
59
|
-
.with(headers: {'Cookie' => "cus-session=#{session_id};"})
|
|
60
|
-
.to_return(body: '', status: 204)
|
|
61
|
-
|
|
62
|
-
expect(subject.destroy).to be_truthy
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
|
-
require 'rspec'
|
|
4
|
-
require 'webmock/rspec'
|
|
5
|
-
require 'campact_user_service'
|
|
6
|
-
|
|
7
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
|
|
8
|
-
|
|
9
|
-
RSpec.configure do |config|
|
|
10
|
-
config.include WebMock::API
|
|
11
|
-
|
|
12
|
-
config.before(:each) do
|
|
13
|
-
WebMock.reset!
|
|
14
|
-
end
|
|
15
|
-
config.after(:each) do
|
|
16
|
-
WebMock.reset!
|
|
17
|
-
end
|
|
18
|
-
end
|