prevoty 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prevoty/responses/filter_statistics.rb +4 -0
- data/lib/prevoty/responses/monitor_content.rb +4 -0
- data/lib/prevoty/version.rb +1 -1
- data/prevoty.gemspec +4 -4
- metadata +5 -9
- data/test/specs/client_spec.rb +0 -581
- data/test/test_helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78619cd1622896c3f072bab5290ff9c5b5a3567
|
4
|
+
data.tar.gz: 73c00be1cf7453dfc152d414543d8d2c1c4fbebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35aa53e2d40a3609d93e03e4fb366135e7bbb397c757650150730ac8e19e8c8e1e25ce16056a3f913a7a0485fbffb1af34f000c6a71f0ce1f20d40634952fa62
|
7
|
+
data.tar.gz: 4902852dfbdcb7a4bdebb6358650cbb3cb369bd29a39a7291946c56c3bfb5766f5f8a848da5e63662c9399f6c4150e1a06ef3a7d79fc0fa744ab7dd36de7e02b
|
data/lib/prevoty/version.rb
CHANGED
data/prevoty.gemspec
CHANGED
@@ -11,11 +11,11 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = %q{Pevoty API client for Ruby}
|
12
12
|
spec.description = %q{Implementation of the Prevoty API}
|
13
13
|
spec.homepage = "https://www.prevoty.com"
|
14
|
-
spec.license = "
|
14
|
+
spec.license = "Apache-2.0"
|
15
15
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.
|
18
|
-
spec.
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "httparty", "~> 0.13"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prevoty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Rozner
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -121,11 +121,9 @@ files:
|
|
121
121
|
- lib/prevoty/responses/validate_token.rb
|
122
122
|
- lib/prevoty/version.rb
|
123
123
|
- prevoty.gemspec
|
124
|
-
- test/specs/client_spec.rb
|
125
|
-
- test/test_helper.rb
|
126
124
|
homepage: https://www.prevoty.com
|
127
125
|
licenses:
|
128
|
-
-
|
126
|
+
- Apache-2.0
|
129
127
|
metadata: {}
|
130
128
|
post_install_message:
|
131
129
|
rdoc_options: []
|
@@ -147,7 +145,5 @@ rubygems_version: 2.5.1
|
|
147
145
|
signing_key:
|
148
146
|
specification_version: 4
|
149
147
|
summary: Pevoty API client for Ruby
|
150
|
-
test_files:
|
151
|
-
- test/specs/client_spec.rb
|
152
|
-
- test/test_helper.rb
|
148
|
+
test_files: []
|
153
149
|
has_rdoc:
|
data/test/specs/client_spec.rb
DELETED
@@ -1,581 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
describe Prevoty::Client do
|
4
|
-
it 'should throw BadInputParameter for verify_api_key without an api key' do
|
5
|
-
client = Prevoty::Client.new(nil)
|
6
|
-
assert_raises Prevoty::BadInputParameter do
|
7
|
-
client.verify_api_key
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should throw BadAPIKey for verify_api_key with an invalid api key' do
|
12
|
-
client = Prevoty::Client.new('badapikey')
|
13
|
-
assert_raises Prevoty::BadAPIKey do
|
14
|
-
client.verify_api_key
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should return true for verify_api_key with a valid api key' do
|
19
|
-
client = Prevoty::Client.new(API_KEY)
|
20
|
-
response = client.verify_api_key
|
21
|
-
response.must_equal true
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should throw BadInputParameter for api_key_info without an api key' do
|
25
|
-
client = Prevoty::Client.new('')
|
26
|
-
assert_raises Prevoty::BadInputParameter do
|
27
|
-
client.api_key_info
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should throw BadAPIKey for api_key_info with an invalid api key' do
|
32
|
-
client = Prevoty::Client.new('badapikey')
|
33
|
-
assert_raises Prevoty::BadAPIKey do
|
34
|
-
client.api_key_info
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should return an APIKeyInfo for api_key_info with a valid api key' do
|
39
|
-
client = Prevoty::Client.new(API_KEY)
|
40
|
-
response = client.api_key_info
|
41
|
-
response.class.must_equal Prevoty::APIKeyInfo
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should throw BadInputParameter for verify_content_configuration without an api key' do
|
45
|
-
client = Prevoty::Client.new('')
|
46
|
-
assert_raises Prevoty::BadInputParameter do
|
47
|
-
client.verify_content_configuration('')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should throw BadAPIKey for verify_content_configuration with an invalid api key' do
|
52
|
-
client = Prevoty::Client.new('badapikey')
|
53
|
-
assert_raises Prevoty::BadAPIKey do
|
54
|
-
client.verify_content_configuration('')
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should throw BadInputParameter for verify_content_configuration with an invalid api key' do
|
59
|
-
client = Prevoty::Client.new(API_KEY)
|
60
|
-
assert_raises Prevoty::BadInputParameter do
|
61
|
-
client.verify_content_configuration('badkey')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should return true for verify_content_configuration with a valid api key' do
|
66
|
-
client = Prevoty::Client.new(API_KEY)
|
67
|
-
response = client.verify_content_configuration(CONTENT_KEY)
|
68
|
-
response.must_equal true
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should throw BadInputParameter for filter_content without an api key' do
|
72
|
-
client = Prevoty::Client.new('')
|
73
|
-
assert_raises Prevoty::BadInputParameter do
|
74
|
-
client.filter_content(CONTENT_PAYLOAD, '')
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should throw BadAPIKey for filter_content with an invalid api key' do
|
79
|
-
client = Prevoty::Client.new('badapikey')
|
80
|
-
assert_raises Prevoty::BadAPIKey do
|
81
|
-
client.filter_content(CONTENT_PAYLOAD, '')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should throw BadInputParameter for filter_content with an invalid content key' do
|
86
|
-
client = Prevoty::Client.new(API_KEY)
|
87
|
-
assert_raises Prevoty::BadInputParameter do
|
88
|
-
client.filter_content(CONTENT_PAYLOAD, 'badkey')
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should return a valid response for filter_content with a valid api key and content_key' do
|
93
|
-
client = Prevoty::Client.new(API_KEY)
|
94
|
-
response = client.filter_content(CONTENT_PAYLOAD, CONTENT_KEY)
|
95
|
-
response.class.must_equal Prevoty::FilterContent
|
96
|
-
response.statistics.class.must_equal Prevoty::FilterStatistics
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should throw BadInputParameter for bulk_filter without an api key' do
|
100
|
-
client = Prevoty::Client.new('')
|
101
|
-
assert_raises Prevoty::BadInputParameter do
|
102
|
-
client.bulk_filter(CONTENT_PAYLOAD, '')
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should throw BadAPIKey for bulk_filter with an invalid api key' do
|
107
|
-
client = Prevoty::Client.new('badapikey')
|
108
|
-
assert_raises Prevoty::BadAPIKey do
|
109
|
-
client.bulk_filter(CONTENT_PAYLOAD, '')
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should throw BadInputParameter for bulk_filter with an invalid content key' do
|
114
|
-
client = Prevoty::Client.new(API_KEY)
|
115
|
-
assert_raises Prevoty::BadInputParameter do
|
116
|
-
client.bulk_filter(CONTENT_PAYLOAD, 'badkey')
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'should return a valid response for bulk_filter with a valid api key and content_key' do
|
121
|
-
client = Prevoty::Client.new(API_KEY)
|
122
|
-
response = client.bulk_filter(CONTENT_PAYLOAD, CONTENT_KEY)
|
123
|
-
response.class.must_equal Prevoty::FilterContent
|
124
|
-
response.statistics.class.must_equal Prevoty::FilterStatistics
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should throw BadInputParameter for monitor_content without an api key' do
|
128
|
-
client = Prevoty::Client.new('')
|
129
|
-
assert_raises Prevoty::BadInputParameter do
|
130
|
-
client.monitor_content(CONTENT_PAYLOAD)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should throw BadAPIKey for monitor_content with an invalid api key' do
|
135
|
-
client = Prevoty::Client.new('badapikey')
|
136
|
-
assert_raises Prevoty::BadAPIKey do
|
137
|
-
client.monitor_content(CONTENT_PAYLOAD)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'should return a valid response for monitor with a valid api key' do
|
142
|
-
client = Prevoty::Client.new(API_KEY)
|
143
|
-
response = client.monitor_content(["stuff=lol", "things=<script>alert()</script>"])
|
144
|
-
response.class.must_equal Array
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'should throw BadInputParameter for generate_timed_token without an api key' do
|
148
|
-
client = Prevoty::Client.new('')
|
149
|
-
assert_raises Prevoty::BadInputParameter do
|
150
|
-
client.generate_timed_token('id', 'action', 3600)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'should throw BadAPIKey for generate_timed_token with an invalid api key' do
|
155
|
-
client = Prevoty::Client.new('badapikey')
|
156
|
-
assert_raises Prevoty::BadAPIKey do
|
157
|
-
client.generate_timed_token('id', 'action', 3600)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'should throw BadInputParameter for validate_timed_token without an api key' do
|
162
|
-
client = Prevoty::Client.new('')
|
163
|
-
assert_raises Prevoty::BadInputParameter do
|
164
|
-
client.validate_timed_token('id', 'action', 3600)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'should throw BadAPIKey for validate_timed_token with an invalid api key' do
|
169
|
-
client = Prevoty::Client.new('badapikey')
|
170
|
-
assert_raises Prevoty::BadAPIKey do
|
171
|
-
client.validate_timed_token('id', 'action', 3600)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should throw BadInputParameter for delete_timed_token without an api key' do
|
176
|
-
client = Prevoty::Client.new('')
|
177
|
-
assert_raises Prevoty::BadInputParameter do
|
178
|
-
client.delete_timed_token('id', 'action', 3600)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'should throw BadAPIKey for delete_timed_token with an invalid api key' do
|
183
|
-
client = Prevoty::Client.new('badapikey')
|
184
|
-
assert_raises Prevoty::BadAPIKey do
|
185
|
-
client.delete_timed_token('id', 'action', 3600)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'should generate and validate a timed token' do
|
190
|
-
client = Prevoty::Client.new(API_KEY)
|
191
|
-
response = client.generate_timed_token('id', 'action', 3600)
|
192
|
-
response.class.must_equal Prevoty::GenerateToken
|
193
|
-
response = client.validate_timed_token('id', 'action', response.token)
|
194
|
-
response.class.must_equal Prevoty::ValidateToken
|
195
|
-
end
|
196
|
-
|
197
|
-
it 'should generate and delete a timed token' do
|
198
|
-
client = Prevoty::Client.new(API_KEY)
|
199
|
-
response = client.generate_timed_token('id', 'action', 3600)
|
200
|
-
response.class.must_equal Prevoty::GenerateToken
|
201
|
-
response = client.delete_timed_token('id', 'action', response.token)
|
202
|
-
response.class.must_equal Prevoty::DeleteToken
|
203
|
-
end
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
it 'should throw BadInputParameter for generate_persisted_token without an api key' do
|
208
|
-
client = Prevoty::Client.new('')
|
209
|
-
assert_raises Prevoty::BadInputParameter do
|
210
|
-
client.generate_persisted_token('id', 'action')
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'should throw BadAPIKey for generate_persisted_token with an invalid api key' do
|
215
|
-
client = Prevoty::Client.new('badapikey')
|
216
|
-
assert_raises Prevoty::BadAPIKey do
|
217
|
-
client.generate_persisted_token('id', 'action')
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'should throw BadInputParameter for validate_persisted_token without an api key' do
|
222
|
-
client = Prevoty::Client.new('')
|
223
|
-
assert_raises Prevoty::BadInputParameter do
|
224
|
-
client.validate_persisted_token('id', 'action', 'token')
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'should throw BadAPIKey for validate_persisted_token with an invalid api key' do
|
229
|
-
client = Prevoty::Client.new('badapikey')
|
230
|
-
assert_raises Prevoty::BadAPIKey do
|
231
|
-
client.validate_persisted_token('id', 'action', 'token')
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'should throw BadInputParameter for delete_persisted_token without an api key' do
|
236
|
-
client = Prevoty::Client.new('')
|
237
|
-
assert_raises Prevoty::BadInputParameter do
|
238
|
-
client.delete_persisted_token('id', 'action', 'token')
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'should throw BadAPIKey for delete_persisted_token with an invalid api key' do
|
243
|
-
client = Prevoty::Client.new('badapikey')
|
244
|
-
assert_raises Prevoty::BadAPIKey do
|
245
|
-
client.delete_persisted_token('id', 'action', 'token')
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'should generate and validate a persisted token' do
|
250
|
-
client = Prevoty::Client.new(API_KEY)
|
251
|
-
response = client.generate_persisted_token('id', 'action')
|
252
|
-
response.class.must_equal Prevoty::GenerateToken
|
253
|
-
response = client.validate_persisted_token('id', 'action', response.token)
|
254
|
-
response.class.must_equal Prevoty::ValidateToken
|
255
|
-
end
|
256
|
-
|
257
|
-
it 'should generate and delete a persisted token' do
|
258
|
-
client = Prevoty::Client.new(API_KEY)
|
259
|
-
response = client.generate_persisted_token('id', 'action')
|
260
|
-
response.class.must_equal Prevoty::GenerateToken
|
261
|
-
response = client.delete_persisted_token('id', 'action', response.token)
|
262
|
-
response.class.must_equal Prevoty::DeleteToken
|
263
|
-
end
|
264
|
-
|
265
|
-
it 'should throw BadInputParameter for analyze_query without an api key' do
|
266
|
-
client = Prevoty::Client.new('')
|
267
|
-
assert_raises Prevoty::BadInputParameter do
|
268
|
-
client.analyze_query(QUERY_PAYLOAD, '')
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'should throw BadAPIKey for analyze_query with an invalid api key' do
|
273
|
-
client = Prevoty::Client.new('badapikey')
|
274
|
-
assert_raises Prevoty::BadAPIKey do
|
275
|
-
client.analyze_query(QUERY_PAYLOAD, '')
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
it 'should throw BadInputParameter for analyze_query with an invalid query key' do
|
280
|
-
client = Prevoty::Client.new(API_KEY)
|
281
|
-
assert_raises Prevoty::BadInputParameter do
|
282
|
-
client.analyze_query(QUERY_PAYLOAD, 'badkey')
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
it 'should return a valid response for analyze_query with a valid api key and query_key' do
|
287
|
-
client = Prevoty::Client.new(API_KEY)
|
288
|
-
response = client.analyze_query(QUERY_PAYLOAD, QUERY_KEY)
|
289
|
-
response.class.must_equal Prevoty::QueryAnalysis
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'should throw BadInputParameter for monitor_query without an api key' do
|
293
|
-
client = Prevoty::Client.new('')
|
294
|
-
assert_raises Prevoty::BadInputParameter do
|
295
|
-
client.monitor_query(MONITOR_QUERY_PAYLOAD)
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'should throw BadAPIKey for monitor_query with an invalid api key' do
|
300
|
-
client = Prevoty::Client.new('badapikey')
|
301
|
-
assert_raises Prevoty::BadAPIKey do
|
302
|
-
client.monitor_query(MONITOR_QUERY_PAYLOAD)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
it 'should return a valid response for monitor with a valid api key' do
|
307
|
-
client = Prevoty::Client.new(API_KEY)
|
308
|
-
response = client.monitor_query(MONITOR_QUERY_PAYLOAD)
|
309
|
-
response.class.must_equal Array
|
310
|
-
end
|
311
|
-
|
312
|
-
it 'should throw BadInputParameter for validate_pattern without an api key' do
|
313
|
-
client = Prevoty::Client.new('')
|
314
|
-
assert_raises Prevoty::BadInputParameter do
|
315
|
-
client.validate_pattern(Prevoty::Pattern::NUMERIC, '')
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
it 'should throw BadAPIKey for validate_pattern with an invalid api key' do
|
320
|
-
client = Prevoty::Client.new('badapikey')
|
321
|
-
assert_raises Prevoty::BadAPIKey do
|
322
|
-
client.validate_pattern(Prevoty::Pattern::NUMERIC, '')
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
it 'should throw BadInputParameter for validate_pattern with an invalid pattern' do
|
327
|
-
client = Prevoty::Client.new(API_KEY)
|
328
|
-
response = client.validate_pattern('badpattern', '12345')
|
329
|
-
response.matched.must_equal false
|
330
|
-
end
|
331
|
-
|
332
|
-
it 'should return a valid response for validate_pattern' do
|
333
|
-
client = Prevoty::Client.new(API_KEY)
|
334
|
-
response = client.validate_pattern(Prevoty::Pattern::NUMERIC, '12345')
|
335
|
-
response.class.must_equal Prevoty::InputValidation
|
336
|
-
response.matched.must_equal true
|
337
|
-
end
|
338
|
-
|
339
|
-
|
340
|
-
it 'should throw BadInputParameter for hash without an api key' do
|
341
|
-
client = Prevoty::Client.new('')
|
342
|
-
assert_raises Prevoty::BadInputParameter do
|
343
|
-
client.hash('test', Prevoty::Hash::MD5)
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
it 'should throw BadAPIKey for hash with an invalid api key' do
|
348
|
-
client = Prevoty::Client.new('badapikey')
|
349
|
-
assert_raises Prevoty::BadAPIKey do
|
350
|
-
client.hash('test', Prevoty::Hash::MD5)
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
it 'should return a valid response for hash with a valid api key and hash' do
|
355
|
-
client = Prevoty::Client.new(API_KEY)
|
356
|
-
response = client.hash('test', Prevoty::Hash::MD5)
|
357
|
-
response.class.must_equal Prevoty::HashResult
|
358
|
-
response.hash.must_equal Digest::MD5.hexdigest('test')
|
359
|
-
end
|
360
|
-
|
361
|
-
it 'should throw BadInputParameter for encrypt without an api key' do
|
362
|
-
client = Prevoty::Client.new('')
|
363
|
-
assert_raises Prevoty::BadInputParameter do
|
364
|
-
client.encrypt('test', Prevoty::Crypto::Algorithms::AES, Prevoty::Crypto::Modes::CBC)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
it 'should throw BadAPIKey for encrypt with an invalid api key' do
|
369
|
-
client = Prevoty::Client.new('badapikey')
|
370
|
-
assert_raises Prevoty::BadAPIKey do
|
371
|
-
client.encrypt('test', Prevoty::Crypto::Algorithms::AES, Prevoty::Crypto::Modes::CBC)
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
it 'should return a valid response for encrypt with a valid api key' do
|
376
|
-
client = Prevoty::Client.new(API_KEY)
|
377
|
-
response = client.encrypt('testtesttesttesttesttesttesttest', Prevoty::Crypto::Algorithms::AES, Prevoty::Crypto::Modes::CBC)
|
378
|
-
response.class.must_equal Prevoty::EncryptResult
|
379
|
-
end
|
380
|
-
|
381
|
-
it 'should throw BadInputParameter for decrypt without an api key' do
|
382
|
-
client = Prevoty::Client.new('')
|
383
|
-
assert_raises Prevoty::BadInputParameter do
|
384
|
-
client.decrypt(Prevoty::EncryptResult.new({}))
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
it 'should throw BadAPIKey for decrypt with an invalid api key' do
|
389
|
-
client = Prevoty::Client.new('badapikey')
|
390
|
-
assert_raises Prevoty::BadAPIKey do
|
391
|
-
client.decrypt(Prevoty::EncryptResult.new({}))
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
it 'should return a valid response for decrypt with a valid api key' do
|
396
|
-
client = Prevoty::Client.new(API_KEY)
|
397
|
-
response = client.encrypt('testtesttesttesttesttesttesttest', Prevoty::Crypto::Algorithms::AES, Prevoty::Crypto::Modes::CBC)
|
398
|
-
response.class.must_equal Prevoty::EncryptResult
|
399
|
-
response = client.decrypt(response)
|
400
|
-
response.class.must_equal Prevoty::DecryptResult
|
401
|
-
response.plain_text.must_equal 'testtesttesttesttesttesttesttest'
|
402
|
-
end
|
403
|
-
|
404
|
-
it 'should throw BadInputParameter for generate_rsa_keypair without an api key' do
|
405
|
-
client = Prevoty::Client.new('')
|
406
|
-
assert_raises Prevoty::BadInputParameter do
|
407
|
-
client.generate_rsa_keypair(1024)
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
it 'should throw BadAPIKey for generate_rsa_keypair with an invalid api key' do
|
412
|
-
client = Prevoty::Client.new('badapikey')
|
413
|
-
assert_raises Prevoty::BadAPIKey do
|
414
|
-
client.generate_rsa_keypair(1024)
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
it 'should return a valid response for generate_rsa_keypair with a valid api key' do
|
419
|
-
client = Prevoty::Client.new(API_KEY)
|
420
|
-
response = client.generate_rsa_keypair(1024)
|
421
|
-
response.class.must_equal Prevoty::RSAPrivateKey
|
422
|
-
end
|
423
|
-
|
424
|
-
it 'should throw BadInputParameter for generate_ecdsa_keypair without an api key' do
|
425
|
-
client = Prevoty::Client.new('')
|
426
|
-
assert_raises Prevoty::BadInputParameter do
|
427
|
-
client.generate_ecdsa_keypair(Prevoty::Crypto::Curves::P224)
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
it 'should throw BadAPIKey for generate_ecdsa_keypair with an invalid api key' do
|
432
|
-
client = Prevoty::Client.new('badapikey')
|
433
|
-
assert_raises Prevoty::BadAPIKey do
|
434
|
-
client.generate_ecdsa_keypair(Prevoty::Crypto::Curves::P224)
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
it 'should return a valid response for generate_ecdsa_keypair with a valid api key' do
|
439
|
-
client = Prevoty::Client.new(API_KEY)
|
440
|
-
response = client.generate_ecdsa_keypair(Prevoty::Crypto::Curves::P224)
|
441
|
-
response.class.must_equal Prevoty::ECDSAPrivateKey
|
442
|
-
end
|
443
|
-
|
444
|
-
it 'should throw BadInputParameter for rsa_pss_signature without an api key' do
|
445
|
-
client = Prevoty::Client.new('')
|
446
|
-
assert_raises Prevoty::BadInputParameter do
|
447
|
-
client.rsa_pss_signature('test', Prevoty::Hash::SHA1, Prevoty::RSAPrivateKey.new({}), nil)
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
it 'should throw BadAPIKey for rsa_pss_signature with an invalid api key' do
|
452
|
-
client = Prevoty::Client.new('badapikey')
|
453
|
-
assert_raises Prevoty::BadAPIKey do
|
454
|
-
client.rsa_pss_signature('test', Prevoty::Hash::SHA1, Prevoty::RSAPrivateKey.new({}), nil)
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
it 'should return a valid response for rsa_pss_signature with a valid api key' do
|
459
|
-
client = Prevoty::Client.new(API_KEY)
|
460
|
-
response = client.generate_rsa_keypair(1024)
|
461
|
-
response.class.must_equal Prevoty::RSAPrivateKey
|
462
|
-
response = client.rsa_pss_signature('test', Prevoty::Hash::SHA1, response, Prevoty::Crypto::PSSSaltOptions::PSSSaltLengthAuto)
|
463
|
-
response.class.must_equal Prevoty::RSASignature
|
464
|
-
end
|
465
|
-
|
466
|
-
it 'should throw BadInputParameter for rsa_pkcs_signature without an api key' do
|
467
|
-
client = Prevoty::Client.new('')
|
468
|
-
assert_raises Prevoty::BadInputParameter do
|
469
|
-
client.rsa_pkcs_signature('test', Prevoty::Hash::SHA1, Prevoty::RSAPrivateKey.new({}))
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
it 'should throw BadAPIKey for rsa_pkcs_signature with an invalid api key' do
|
474
|
-
client = Prevoty::Client.new('badapikey')
|
475
|
-
assert_raises Prevoty::BadAPIKey do
|
476
|
-
client.rsa_pkcs_signature('test', Prevoty::Hash::SHA1, Prevoty::RSAPrivateKey.new({}))
|
477
|
-
end
|
478
|
-
end
|
479
|
-
|
480
|
-
it 'should return a valid response for rsa_pkcs_signature with a valid api key' do
|
481
|
-
client = Prevoty::Client.new(API_KEY)
|
482
|
-
response = client.generate_rsa_keypair(1024)
|
483
|
-
response.class.must_equal Prevoty::RSAPrivateKey
|
484
|
-
response = client.rsa_pkcs_signature('test', Prevoty::Hash::SHA1, response)
|
485
|
-
response.class.must_equal Prevoty::RSASignature
|
486
|
-
end
|
487
|
-
|
488
|
-
it 'should throw BadInputParameter for ecdsa_signature without an api key' do
|
489
|
-
client = Prevoty::Client.new('')
|
490
|
-
assert_raises Prevoty::BadInputParameter do
|
491
|
-
client.ecdsa_signature('test', Prevoty::Hash::SHA1, Prevoty::ECDSAPrivateKey.new({}))
|
492
|
-
end
|
493
|
-
end
|
494
|
-
|
495
|
-
it 'should throw BadAPIKey for ecdsa_signature with an invalid api key' do
|
496
|
-
client = Prevoty::Client.new('badapikey')
|
497
|
-
assert_raises Prevoty::BadAPIKey do
|
498
|
-
client.ecdsa_signature('test', Prevoty::Hash::SHA1, Prevoty::ECDSAPrivateKey.new({}))
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
it 'should return a valid response for ecdsa_signature with a valid api key' do
|
503
|
-
client = Prevoty::Client.new(API_KEY)
|
504
|
-
response = client.generate_ecdsa_keypair(Prevoty::Crypto::Curves::P224)
|
505
|
-
response.class.must_equal Prevoty::ECDSAPrivateKey
|
506
|
-
response = client.ecdsa_signature('test', Prevoty::Hash::SHA1, response)
|
507
|
-
response.class.must_equal Prevoty::ECDSASignature
|
508
|
-
end
|
509
|
-
|
510
|
-
it 'should throw BadInputParameter for verify_rsa_pss_signature without an api key' do
|
511
|
-
client = Prevoty::Client.new('')
|
512
|
-
assert_raises Prevoty::BadInputParameter do
|
513
|
-
client.rsa_pss_signature('test', Prevoty::Hash::SHA1, Prevoty::SignatureVerify.new({}), Prevoty::Crypto::PSSSaltOptions::PSSSaltLengthAuto)
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
it 'should throw BadAPIKey for verify_rsa_pss_signature with an invalid api key' do
|
518
|
-
client = Prevoty::Client.new('badapikey')
|
519
|
-
assert_raises Prevoty::BadAPIKey do
|
520
|
-
client.rsa_pss_signature('test', Prevoty::Hash::SHA1, Prevoty::SignatureVerify.new({}), Prevoty::Crypto::PSSSaltOptions::PSSSaltLengthAuto)
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
it 'should return a valid response for verify_rsa_pss_signature with a valid api key' do
|
525
|
-
client = Prevoty::Client.new(API_KEY)
|
526
|
-
key = client.generate_rsa_keypair(1024)
|
527
|
-
key.class.must_equal Prevoty::RSAPrivateKey
|
528
|
-
response = client.rsa_pss_signature('test', Prevoty::Hash::SHA1, key, Prevoty::Crypto::PSSSaltOptions::PSSSaltLengthAuto)
|
529
|
-
response.class.must_equal Prevoty::RSASignature
|
530
|
-
response = client.verify_rsa_pss_signature('test', Prevoty::Hash::SHA1, key, response, Prevoty::Crypto::PSSSaltOptions::PSSSaltLengthAuto)
|
531
|
-
response.class.must_equal Prevoty::SignatureVerify
|
532
|
-
end
|
533
|
-
|
534
|
-
it 'should throw BadInputParameter for verify_rsa_pkcs_signature without an api key' do
|
535
|
-
client = Prevoty::Client.new('')
|
536
|
-
assert_raises Prevoty::BadInputParameter do
|
537
|
-
client.rsa_pkcs_signature('test', Prevoty::Hash::SHA1, Prevoty::SignatureVerify.new({}))
|
538
|
-
end
|
539
|
-
end
|
540
|
-
|
541
|
-
it 'should throw BadAPIKey for verify_rsa_pkcs_signature with an invalid api key' do
|
542
|
-
client = Prevoty::Client.new('badapikey')
|
543
|
-
assert_raises Prevoty::BadAPIKey do
|
544
|
-
client.rsa_pkcs_signature('test', Prevoty::Hash::SHA1, Prevoty::SignatureVerify.new({}))
|
545
|
-
end
|
546
|
-
end
|
547
|
-
|
548
|
-
it 'should return a valid response for verify_rsa_pss_signature with a valid api key' do
|
549
|
-
client = Prevoty::Client.new(API_KEY)
|
550
|
-
key = client.generate_rsa_keypair(1024)
|
551
|
-
key.class.must_equal Prevoty::RSAPrivateKey
|
552
|
-
response = client.rsa_pkcs_signature('test', Prevoty::Hash::SHA1, key)
|
553
|
-
response.class.must_equal Prevoty::RSASignature
|
554
|
-
response = client.verify_rsa_pkcs_signature('test', Prevoty::Hash::SHA1, key, response)
|
555
|
-
response.class.must_equal Prevoty::SignatureVerify
|
556
|
-
end
|
557
|
-
|
558
|
-
it 'should throw BadInputParameter for verify_ecdsa_signature without an api key' do
|
559
|
-
client = Prevoty::Client.new('')
|
560
|
-
assert_raises Prevoty::BadInputParameter do
|
561
|
-
client.ecdsa_signature('test', Prevoty::Hash::SHA1, Prevoty::SignatureVerify.new({}))
|
562
|
-
end
|
563
|
-
end
|
564
|
-
|
565
|
-
it 'should throw BadAPIKey for verify_ecdsa_signature with an invalid api key' do
|
566
|
-
client = Prevoty::Client.new('badapikey')
|
567
|
-
assert_raises Prevoty::BadAPIKey do
|
568
|
-
client.ecdsa_signature('test', Prevoty::Hash::SHA1, Prevoty::SignatureVerify.new({}))
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
it 'should return a valid response for verify_ecdsa_signature with a valid api key' do
|
573
|
-
client = Prevoty::Client.new(API_KEY)
|
574
|
-
key = client.generate_ecdsa_keypair(Prevoty::Crypto::Curves::P224)
|
575
|
-
key.class.must_equal Prevoty::ECDSAPrivateKey
|
576
|
-
response = client.ecdsa_signature('test', Prevoty::Hash::SHA1, key)
|
577
|
-
response.class.must_equal Prevoty::ECDSASignature
|
578
|
-
response = client.verify_ecdsa_signature('test', Prevoty::Hash::SHA1, key, response)
|
579
|
-
response.class.must_equal Prevoty::SignatureVerify
|
580
|
-
end
|
581
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'minitest/spec'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
require File.expand_path('../../lib/prevoty', __FILE__)
|
5
|
-
|
6
|
-
API_KEY = ''
|
7
|
-
CONTENT_KEY = ''
|
8
|
-
CONTENT_PAYLOAD = "the <script>alert('quick brown fox');</script> jumps over the lazy dog & mouse"
|
9
|
-
QUERY_KEY = ''
|
10
|
-
QUERY_PAYLOAD = 'select * from users'
|
11
|
-
MONITOR_QUERY_PAYLOAD = [{vendor: 'mysql', query: QUERY_PAYLOAD, database: 'ruby_test'}]
|