mollom_rest_api 0.1.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.
Files changed (72) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +18 -0
  5. data/Guardfile +4 -0
  6. data/LICENSE +21 -0
  7. data/README.md +86 -0
  8. data/Rakefile +6 -0
  9. data/lib/mollom_rest_api/exceptions.rb +12 -0
  10. data/lib/mollom_rest_api/interface.rb +81 -0
  11. data/lib/mollom_rest_api/v1/blacklist.rb +29 -0
  12. data/lib/mollom_rest_api/v1/captcha.rb +11 -0
  13. data/lib/mollom_rest_api/v1/content.rb +12 -0
  14. data/lib/mollom_rest_api/v1/feedback.rb +14 -0
  15. data/lib/mollom_rest_api/v1/site.rb +23 -0
  16. data/lib/mollom_rest_api/v1/whitelist.rb +29 -0
  17. data/lib/mollom_rest_api/v1.rb +3 -0
  18. data/lib/mollom_rest_api/version.rb +3 -0
  19. data/lib/mollom_rest_api/versioned_api.rb +51 -0
  20. data/lib/mollom_rest_api.rb +31 -0
  21. data/log/.gitkeep +0 -0
  22. data/mollom_rest_api.gemspec +21 -0
  23. data/spec/fixtures/cassette_library/blacklist/create.yml +43 -0
  24. data/spec/fixtures/cassette_library/blacklist/delete.yml +43 -0
  25. data/spec/fixtures/cassette_library/blacklist/list.yml +39 -0
  26. data/spec/fixtures/cassette_library/blacklist/read.yml +41 -0
  27. data/spec/fixtures/cassette_library/blacklist/update.yml +43 -0
  28. data/spec/fixtures/cassette_library/captcha/create/default_request.yml +45 -0
  29. data/spec/fixtures/cassette_library/captcha/create/invalid_type.yml +45 -0
  30. data/spec/fixtures/cassette_library/captcha/create/valid_request.yml +45 -0
  31. data/spec/fixtures/cassette_library/captcha/verify/invalid_captcha_id.yml +45 -0
  32. data/spec/fixtures/cassette_library/captcha/verify/invalid_solution.yml +46 -0
  33. data/spec/fixtures/cassette_library/captcha/verify/valid_solution.yml +46 -0
  34. data/spec/fixtures/cassette_library/content/create.yml +46 -0
  35. data/spec/fixtures/cassette_library/content/update/invalid_content_id.yml +45 -0
  36. data/spec/fixtures/cassette_library/content/update/valid_request.yml +45 -0
  37. data/spec/fixtures/cassette_library/feedback/add/captcha_request.yml +45 -0
  38. data/spec/fixtures/cassette_library/feedback/add/content_request.yml +45 -0
  39. data/spec/fixtures/cassette_library/interface/some_api/a_post_action.yml +32 -0
  40. data/spec/fixtures/cassette_library/interface/some_api/an_overriden_get_action.yml +26 -0
  41. data/spec/fixtures/cassette_library/interface/some_api/an_overriden_post_action.yml +32 -0
  42. data/spec/fixtures/cassette_library/interface/some_api/delete.yml +26 -0
  43. data/spec/fixtures/cassette_library/interface/some_api/list.yml +26 -0
  44. data/spec/fixtures/cassette_library/invalid_request.yml +59 -0
  45. data/spec/fixtures/cassette_library/site/create.yml +45 -0
  46. data/spec/fixtures/cassette_library/site/delete.yml +45 -0
  47. data/spec/fixtures/cassette_library/site/list.yml +75 -0
  48. data/spec/fixtures/cassette_library/site/read.yml +41 -0
  49. data/spec/fixtures/cassette_library/site/update.yml +43 -0
  50. data/spec/fixtures/cassette_library/whitelist/create.yml +43 -0
  51. data/spec/fixtures/cassette_library/whitelist/delete.yml +43 -0
  52. data/spec/fixtures/cassette_library/whitelist/list.yml +41 -0
  53. data/spec/fixtures/cassette_library/whitelist/read.yml +39 -0
  54. data/spec/fixtures/cassette_library/whitelist/update.yml +43 -0
  55. data/spec/fixtures/v_test_01.rb +27 -0
  56. data/spec/mollom_rest_api/exceptions_spec.rb +25 -0
  57. data/spec/mollom_rest_api/interface_spec.rb +43 -0
  58. data/spec/mollom_rest_api/v1/blacklist_spec.rb +64 -0
  59. data/spec/mollom_rest_api/v1/captcha_spec.rb +63 -0
  60. data/spec/mollom_rest_api/v1/content_spec.rb +41 -0
  61. data/spec/mollom_rest_api/v1/feedback_spec.rb +37 -0
  62. data/spec/mollom_rest_api/v1/site_spec.rb +63 -0
  63. data/spec/mollom_rest_api/v1/whitelist_spec.rb +64 -0
  64. data/spec/mollom_rest_api/v1_spec.rb +9 -0
  65. data/spec/mollom_rest_api/version_spec.rb +5 -0
  66. data/spec/mollom_rest_api/versioned_api_spec.rb +26 -0
  67. data/spec/mollom_rest_api_spec.rb +30 -0
  68. data/spec/spec_helper.rb +15 -0
  69. data/spec/support/macros/alternate_syntax_macro.rb +38 -0
  70. data/spec/support/shared_examples/api_error_handling.rb +33 -0
  71. data/spec/support/vcr.rb +37 -0
  72. metadata +192 -0
@@ -0,0 +1,26 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/vtest01/ticket/a_path_parameter/delete
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Authorization:
15
+ - OAuth oauth_consumer_key="1mkno2c8bsepo12ewu7v0mmpxro77o3u", oauth_nonce="SEXVLHY0YeAwgEblr04n7EVraDtDALwNWIXP77ms",
16
+ oauth_signature="C1TiejQ0csF2nu3A9Ldm23rMnmY%3D", oauth_signature_method="HMAC-SHA1",
17
+ oauth_timestamp="1407346386", oauth_version="1.0"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ body:
23
+ encoding: UTF-8
24
+ string: '{"code":"200","ticket":"Valid response."}'
25
+ recorded_at: Wed, 25 Jun 2014 15:45:19 GMT
26
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,26 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://dev.mollom.com/vtest01/ticket
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Authorization:
15
+ - OAuth oauth_consumer_key="1mkno2c8bsepo12ewu7v0mmpxro77o3u", oauth_nonce="SEXVLHY0YeAwgEblr04n7EVraDtDALwNWIXP77ms",
16
+ oauth_signature="C1TiejQ0csF2nu3A9Ldm23rMnmY%3D", oauth_signature_method="HMAC-SHA1",
17
+ oauth_timestamp="1407346386", oauth_version="1.0"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ body:
23
+ encoding: UTF-8
24
+ string: '{"code":"200","list":"Valid response."}'
25
+ recorded_at: Wed, 25 Jun 2014 15:45:19 GMT
26
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com
6
+ response:
7
+ status:
8
+ code: 401
9
+ message: Unauthorized
10
+ headers:
11
+ X-Powered-By:
12
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
13
+ Corporation/1.7)
14
+ Server:
15
+ - GlassFish Server Open Source Edition 3.1.2.2
16
+ Www-Authenticate:
17
+ - OAuth realm="default"
18
+ Content-Type:
19
+ - text/html
20
+ Content-Length:
21
+ - '1109'
22
+ Date:
23
+ - Mon, 23 Jun 2014 14:18:16 GMT
24
+ Connection:
25
+ - keep-alive
26
+ body:
27
+ encoding: UTF-8
28
+ string: '{"code":"401","message":"Error."}'
29
+ http_version:
30
+ recorded_at: Mon, 23 Jun 2014 14:16:59 GMT
31
+ - request:
32
+ method: get
33
+ uri: http://dev.mollom.com
34
+ response:
35
+ status:
36
+ code: 401
37
+ message: Unauthorized
38
+ headers:
39
+ X-Powered-By:
40
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
41
+ Corporation/1.7)
42
+ Server:
43
+ - GlassFish Server Open Source Edition 3.1.2.2
44
+ Www-Authenticate:
45
+ - OAuth realm="default"
46
+ Content-Type:
47
+ - text/html
48
+ Content-Length:
49
+ - '1109'
50
+ Date:
51
+ - Mon, 23 Jun 2014 14:18:16 GMT
52
+ Connection:
53
+ - keep-alive
54
+ body:
55
+ encoding: UTF-8
56
+ string: '{"code":"401","message":"Error."}'
57
+ http_version:
58
+ recorded_at: Mon, 23 Jun 2014 14:16:59 GMT
59
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/site
6
+ body:
7
+ encoding: US-ASCII
8
+ string: email=an-email%40gmail.com&platformName=Drupal&platformVersion=6.20&url=http%3A%2F%2Furl
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ User-Agent:
15
+ - OAuth gem v0.4.7
16
+ Content-Length:
17
+ - '0'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ Authorization:
21
+ - OAuth oauth_consumer_key="1mkno2c8bsepo12ewu7v0mmpxro77o3u", oauth_nonce="QRonktJIdG1s6jvM7LB67Qzvte3VezIub4CI8dsfs",
22
+ oauth_signature="RE3hx0n6I8x8KUmnsdxDL%2Fk2Mig%3D", oauth_signature_method="HMAC-SHA1",
23
+ oauth_timestamp="1407260182", oauth_version="1.0"
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Powered-By:
30
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
31
+ Corporation/1.7)
32
+ Server:
33
+ - GlassFish Server Open Source Edition 3.1.2.2
34
+ Content-Type:
35
+ - application/json
36
+ Date:
37
+ - Tue, 05 Aug 2014 17:36:33 GMT
38
+ Connection:
39
+ - close
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"code":"200","site":{"publicKey":"44wvtjchwxaj1h90cqi1hxscwcpceylx","privateKey":"ton7cjeu271j15l94ip777uvv1pcgua3","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null}}'
43
+ http_version:
44
+ recorded_at: Tue, 05 Aug 2014 17:36:22 GMT
45
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/site/1cu4vdx7a6m9c1jc2425k1o9r8me2mrz/delete
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ User-Agent:
15
+ - OAuth gem v0.4.7
16
+ Content-Length:
17
+ - '0'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ Authorization:
21
+ - OAuth oauth_consumer_key="1cu4vdx7a6m9c1jc2425k1o9r8me2mrz", oauth_nonce="o5GxH4qzRJgR8ScVJq8cpIXTv5fG0MDhAmbtemIA4",
22
+ oauth_signature="ljbefcpvo1a5%2FBO8cRT1E0nD5jk%3D", oauth_signature_method="HMAC-SHA1",
23
+ oauth_timestamp="1407863678", oauth_version="1.0"
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Powered-By:
30
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
31
+ Corporation/1.7)
32
+ Server:
33
+ - GlassFish Server Open Source Edition 3.1.2.2
34
+ Content-Type:
35
+ - application/json
36
+ Date:
37
+ - Tue, 12 Aug 2014 17:14:58 GMT
38
+ Connection:
39
+ - close
40
+ body:
41
+ encoding: UTF-8
42
+ string: '{"code":"200"}'
43
+ http_version:
44
+ recorded_at: Tue, 12 Aug 2014 17:14:38 GMT
45
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://dev.mollom.com/v1/site
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Authorization:
15
+ - OAuth oauth_consumer_key="1mkno2c8bsepo12ewu7v0mmpxro77o3u", oauth_nonce="z3zpJBCdAHK5SnerQMXSmvENyPNXHadizieIWSER0",
16
+ oauth_signature="6FvyyDr3QgQXDNmx1rBBLJE8lt4%3D", oauth_signature_method="HMAC-SHA1",
17
+ oauth_timestamp="1407346705", oauth_version="1.0"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Powered-By:
24
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
25
+ Corporation/1.7)
26
+ Server:
27
+ - GlassFish Server Open Source Edition 3.1.2.2
28
+ Content-Type:
29
+ - application/json
30
+ Date:
31
+ - Wed, 06 Aug 2014 17:38:48 GMT
32
+ Connection:
33
+ - close
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '{"code":"200","list":{"site":[{"publicKey":"1cu4vdx7a6m9c1jc2425k1o9r8me2mrz","privateKey":"1khj0vgpcqtjfwbbl5fr3wiykmr2ajro","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null},{"publicKey":"geu7chlny71m18ve7inn41kuap9ztyja","privateKey":"16o5626oykcsophjt31p1lim986rm5cq","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null},{"publicKey":"44wvtjchwxaj1h90cqi1hxscwcpceylx","privateKey":"ton7cjeu271j15l94ip777uvv1pcgua3","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null}]}}'
37
+ http_version:
38
+ recorded_at: Wed, 06 Aug 2014 17:38:26 GMT
39
+ - request:
40
+ method: get
41
+ uri: http://dev.mollom.com/v1/site?count=5
42
+ body:
43
+ encoding: US-ASCII
44
+ string: ''
45
+ headers:
46
+ Accept:
47
+ - application/json
48
+ User-Agent:
49
+ - OAuth gem v0.4.7
50
+ Authorization:
51
+ - OAuth oauth_consumer_key="1mkno2c8bsepo12ewu7v0mmpxro77o3u", oauth_nonce="XjaKn8ECob3Zt9XG7O6TZQwcDvhAb5CP8mAUvxqM",
52
+ oauth_signature="aN1KXhPx80F2Tht7VCnHaOnCkyY%3D", oauth_signature_method="HMAC-SHA1",
53
+ oauth_timestamp="1407431443", oauth_version="1.0"
54
+ response:
55
+ status:
56
+ code: 200
57
+ message: OK
58
+ headers:
59
+ X-Powered-By:
60
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
61
+ Corporation/1.7)
62
+ Server:
63
+ - GlassFish Server Open Source Edition 3.1.2.2
64
+ Content-Type:
65
+ - application/json
66
+ Date:
67
+ - Thu, 07 Aug 2014 17:11:07 GMT
68
+ Connection:
69
+ - close
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ! '{"code":"200","list":{"site":[{"publicKey":"1cu4vdx7a6m9c1jc2425k1o9r8me2mrz","privateKey":"1khj0vgpcqtjfwbbl5fr3wiykmr2ajro","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null},{"publicKey":"geu7chlny71m18ve7inn41kuap9ztyja","privateKey":"16o5626oykcsophjt31p1lim986rm5cq","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null},{"publicKey":"44wvtjchwxaj1h90cqi1hxscwcpceylx","privateKey":"ton7cjeu271j15l94ip777uvv1pcgua3","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null}]}}'
73
+ http_version:
74
+ recorded_at: Thu, 07 Aug 2014 17:10:43 GMT
75
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://dev.mollom.com/v1/site/1cu4vdx7a6m9c1jc2425k1o9r8me2mrz
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ User-Agent:
15
+ - OAuth gem v0.4.7
16
+ Authorization:
17
+ - OAuth oauth_consumer_key="1cu4vdx7a6m9c1jc2425k1o9r8me2mrz", oauth_nonce="SFQk35sI3nhSHZ82tjI8z0GiUTASR6wFNHvKLzPvEE",
18
+ oauth_signature="24fNpp4wf5ADykqUat2HQNjkwvU%3D", oauth_signature_method="HMAC-SHA1",
19
+ oauth_timestamp="1407863313", oauth_version="1.0"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Powered-By:
26
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
27
+ Corporation/1.7)
28
+ Server:
29
+ - GlassFish Server Open Source Edition 3.1.2.2
30
+ Content-Type:
31
+ - application/json
32
+ Date:
33
+ - Tue, 12 Aug 2014 17:08:53 GMT
34
+ Connection:
35
+ - close
36
+ body:
37
+ encoding: UTF-8
38
+ string: '{"code":"200","site":{"publicKey":"1cu4vdx7a6m9c1jc2425k1o9r8me2mrz","privateKey":"1khj0vgpcqtjfwbbl5fr3wiykmr2ajro","url":"http://url","email":"an-email@gmail.com","platformName":"Drupal","platformVersion":"6.20","expectedLanguages":null}}'
39
+ http_version:
40
+ recorded_at: Tue, 12 Aug 2014 17:08:33 GMT
41
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/site/1mkno2c8bsepo12ewu7v0mmpxro77o3u
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Content-Length:
15
+ - '0'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="1mkno2c8bsepo12ewu7v0mmpxro77o3u", oauth_nonce="kxcQodrePXxBjnj1jamjWpUAo4VgsAtS063K0NnT7bo",
20
+ oauth_signature="rSsJfmdMqVygZb1iWR8pZEQ0LBY%3D", oauth_signature_method="HMAC-SHA1",
21
+ oauth_timestamp="1407344156", oauth_version="1.0"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Powered-By:
28
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
29
+ Corporation/1.7)
30
+ Server:
31
+ - GlassFish Server Open Source Edition 3.1.2.2
32
+ Content-Type:
33
+ - application/json
34
+ Date:
35
+ - Wed, 06 Aug 2014 16:56:18 GMT
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ! '{"code":"200","site":{"publicKey":"1mkno2c8bsepo12ewu7v0mmpxro77o3u","privateKey":"z2urchz11o21b9m76l0x51iz1ize75g0","expectedLanguages":null}}'
41
+ http_version:
42
+ recorded_at: Wed, 06 Aug 2014 16:55:56 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/whitelist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n
6
+ body:
7
+ encoding: US-ASCII
8
+ string: context=authorIp&note=patate&value=123.123.80.22
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Content-Length:
15
+ - '0'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="vvBCc1km6nE0eqDGnb3v8KsQIwugF0H6z9VYBAoi5D0",
20
+ oauth_signature="CkLPAklBHdtTXNwp20E39Nxq7f4%3D", oauth_signature_method="HMAC-SHA1",
21
+ oauth_timestamp="1412787838", oauth_version="1.0"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Powered-By:
28
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
29
+ Corporation/1.7)
30
+ Server:
31
+ - GlassFish Server Open Source Edition 3.1.2.2
32
+ Content-Type:
33
+ - application/json
34
+ Date:
35
+ - Wed, 08 Oct 2014 17:05:09 GMT
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ! '{"code":"200","entry":{"context":"authorIp","created":"1412787909465","id":"76747","lastMatch":"0","matchCount":"0","status":"1","value":"123.123.80.22"}}'
41
+ http_version:
42
+ recorded_at: Wed, 08 Oct 2014 17:03:58 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/whitelist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n/79552/delete
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Content-Length:
15
+ - '0'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="6do9fVaqN7q7L8wJ32rgswuuu8qKuNWEeRi0m8tHfo",
20
+ oauth_signature="kFd1n4W0u3m%2BF8r0SkkuWUnarPc%3D", oauth_signature_method="HMAC-SHA1",
21
+ oauth_timestamp="1413825168", oauth_version="1.0"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Powered-By:
28
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
29
+ Corporation/1.7)
30
+ Server:
31
+ - GlassFish Server Open Source Edition 3.1.2.2
32
+ Content-Type:
33
+ - application/json
34
+ Date:
35
+ - Mon, 20 Oct 2014 17:14:06 GMT
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ! '{"code":"200","message":"The whitelist entry has been deleted"}'
41
+ http_version:
42
+ recorded_at: Mon, 20 Oct 2014 17:12:48 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://dev.mollom.com/v1/whitelist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n?count=5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ User-Agent:
15
+ - OAuth gem v0.4.7
16
+ Authorization:
17
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="wmI8haqfTZjbqkS8KTD4IeP4VavhOszwrhAu3lFleOU",
18
+ oauth_signature="n28axcSsgHndp41NCTqdZx09WiA%3D", oauth_signature_method="HMAC-SHA1",
19
+ oauth_timestamp="1412950791", oauth_version="1.0"
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Powered-By:
26
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
27
+ Corporation/1.7)
28
+ Server:
29
+ - GlassFish Server Open Source Edition 3.1.2.2
30
+ Content-Type:
31
+ - application/json
32
+ Date:
33
+ - Fri, 10 Oct 2014 14:21:24 GMT
34
+ Connection:
35
+ - close
36
+ body:
37
+ encoding: UTF-8
38
+ string: '{"code":"200","list":{"entry":{"context":"authorName","created":"1412787909465","id":"76747","lastMatch":"0","matchCount":"0","status":"0","value":"patate"}},"listCount":"1","listOffset":"0","listTotal":"1"}'
39
+ http_version:
40
+ recorded_at: Fri, 10 Oct 2014 14:19:51 GMT
41
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://dev.mollom.com/v1/whitelist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n/79557
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Authorization:
15
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="C7UKDXos04eCPCSWclZhllg88b30Q4x1Awiaus",
16
+ oauth_signature="22%2B8POMgeopz%2FrpykK0pAno%2BOA8%3D", oauth_signature_method="HMAC-SHA1",
17
+ oauth_timestamp="1413826653", oauth_version="1.0"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Powered-By:
24
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
25
+ Corporation/1.7)
26
+ Server:
27
+ - GlassFish Server Open Source Edition 3.1.2.2
28
+ Content-Type:
29
+ - application/json
30
+ Date:
31
+ - Mon, 20 Oct 2014 17:38:52 GMT
32
+ Connection:
33
+ - close
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '{"code":"200","entry":{"context":"authorName","created":"1413826721455","id":"79557","lastMatch":"0","matchCount":"0","status":"1","value":"patate"}}'
37
+ http_version:
38
+ recorded_at: Mon, 20 Oct 2014 17:37:33 GMT
39
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://dev.mollom.com/v1/whitelist/1lgj17lzuezlu1bn9ry4k3qz4k8nr42n/76747
6
+ body:
7
+ encoding: US-ASCII
8
+ string: context=authorName&value=patate
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - OAuth gem v0.4.7
14
+ Content-Length:
15
+ - '0'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="b06465615b3a8800ef79ca947b1addca", oauth_nonce="iCGPgyj77kMA1r1PNbc1luGMeD3awPTGS1k1WTNlXS0",
20
+ oauth_signature="HWfaBwqszvmjdfk1QvJUIxClQvc%3D", oauth_signature_method="HMAC-SHA1",
21
+ oauth_timestamp="1412788255", oauth_version="1.0"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ X-Powered-By:
28
+ - Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle
29
+ Corporation/1.7)
30
+ Server:
31
+ - GlassFish Server Open Source Edition 3.1.2.2
32
+ Content-Type:
33
+ - application/json
34
+ Date:
35
+ - Wed, 08 Oct 2014 17:12:05 GMT
36
+ Connection:
37
+ - close
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ! '{"code":"200","entry":{"context":"authorName","created":"1412787909465","id":"76747","lastMatch":"0","matchCount":"0","status":"0","value":"patate"}}'
41
+ http_version:
42
+ recorded_at: Wed, 08 Oct 2014 17:10:55 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,27 @@
1
+ module MollomRestApi
2
+ class VTest01 < VersionedApi
3
+ class Ticket < MollomRestApi::Interface
4
+ def self.create; end
5
+
6
+ def self.a_post_action
7
+ post
8
+ end
9
+
10
+ def self.an_overriden_post_action
11
+ post({authorId: 9}, "delete")
12
+ end
13
+
14
+ def self.an_overriden_get_action
15
+ get({status: :active}, "list")
16
+ end
17
+
18
+ def self.list
19
+ get
20
+ end
21
+
22
+ def self.delete
23
+ post({}, ['a_path_parameter'])
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe MollomRestApi::ApiException do
4
+ subject { MollomRestApi::ApiException.new("An error message.", 404) }
5
+
6
+ specify { expect(subject).to be_a(StandardError) }
7
+
8
+ describe :message do
9
+ specify { expect(subject.message).to eq("An error message.") }
10
+ end
11
+
12
+ describe :error_code do
13
+ specify { expect(subject.error_code).to eq(404) }
14
+ end
15
+ end
16
+
17
+ describe MollomRestApi::MissingConfig do
18
+ subject { MollomRestApi::MissingConfig.new("A missing config.") }
19
+
20
+ specify { expect(subject).to be_a(StandardError) }
21
+
22
+ describe :message do
23
+ specify { expect(subject.message).to eq("A missing config.") }
24
+ end
25
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe MollomRestApi::Interface do
4
+ describe 'a simple post action', vcr: {cassette_name: 'interface/some_api/a_post_action'} do
5
+ it "should call the correct url using the method name" do
6
+ expect(MollomRestApi::VTest01::Ticket.a_post_action).to eq('Valid response.')
7
+ end
8
+
9
+ include_examples "api error handling", class_under_test: MollomRestApi::VTest01::Ticket, method_under_test: :a_post_action
10
+ end
11
+
12
+ describe 'a post action with all arguments specified', vcr: {cassette_name: 'interface/some_api/an_overriden_post_action'} do
13
+ it "should call the correct url using the overriden properties in the method" do
14
+ expect(MollomRestApi::VTest01::Ticket.an_overriden_post_action).to eq('Valid response.')
15
+ end
16
+
17
+ include_examples "api error handling", class_under_test: MollomRestApi::VTest01::Ticket, method_under_test: :an_overriden_post_action
18
+ end
19
+
20
+ describe 'a get action with all arguments specified', vcr: {cassette_name: 'interface/some_api/an_overriden_get_action'} do
21
+ it "should call the correct url using the overriden properties in the method" do
22
+ expect(MollomRestApi::VTest01::Ticket.an_overriden_get_action).to eq('Valid response.')
23
+ end
24
+
25
+ include_examples "api error handling", class_under_test: MollomRestApi::VTest01::Ticket, method_under_test: :an_overriden_get_action
26
+ end
27
+
28
+ describe 'a get action to fetch a list', vcr: {cassette_name: 'interface/some_api/list'} do
29
+ it "should call the correct url using the method name" do
30
+ expect(MollomRestApi::VTest01::Ticket.list).to eq('Valid response.')
31
+ end
32
+
33
+ include_examples "api error handling", class_under_test: MollomRestApi::VTest01::Ticket, method_under_test: :list
34
+ end
35
+
36
+ describe 'a delete action on a resource', vcr: {cassette_name: 'interface/some_api/delete'} do
37
+ it "should call the delete url on the resource" do
38
+ expect(MollomRestApi::VTest01::Ticket.delete).to eq('Valid response.')
39
+ end
40
+
41
+ include_examples "api error handling", class_under_test: MollomRestApi::VTest01::Ticket, method_under_test: :delete
42
+ end
43
+ end