webhukhs 0.5.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 (105) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +14 -0
  3. data/.rubocop.yml +9 -0
  4. data/.standard.yml +3 -0
  5. data/Appraisals +13 -0
  6. data/CHANGELOG.md +54 -0
  7. data/LICENSE +21 -0
  8. data/README.md +71 -0
  9. data/Rakefile +26 -0
  10. data/config/routes.rb +3 -0
  11. data/example/.gitattributes +7 -0
  12. data/example/.gitignore +29 -0
  13. data/example/.ruby-version +1 -0
  14. data/example/Gemfile +32 -0
  15. data/example/Gemfile.lock +228 -0
  16. data/example/README.md +24 -0
  17. data/example/Rakefile +8 -0
  18. data/example/app/assets/images/.keep +0 -0
  19. data/example/app/assets/stylesheets/application.css +1 -0
  20. data/example/app/controllers/application_controller.rb +4 -0
  21. data/example/app/controllers/concerns/.keep +0 -0
  22. data/example/app/helpers/application_helper.rb +4 -0
  23. data/example/app/models/application_record.rb +5 -0
  24. data/example/app/models/concerns/.keep +0 -0
  25. data/example/app/views/layouts/application.html.erb +15 -0
  26. data/example/app/webhooks/webhook_test_handler.rb +13 -0
  27. data/example/bin/bundle +109 -0
  28. data/example/bin/rails +4 -0
  29. data/example/bin/rake +4 -0
  30. data/example/bin/setup +33 -0
  31. data/example/config/application.rb +39 -0
  32. data/example/config/boot.rb +5 -0
  33. data/example/config/credentials.yml.enc +1 -0
  34. data/example/config/database.yml +25 -0
  35. data/example/config/environment.rb +7 -0
  36. data/example/config/environments/development.rb +61 -0
  37. data/example/config/environments/production.rb +71 -0
  38. data/example/config/environments/test.rb +52 -0
  39. data/example/config/initializers/assets.rb +14 -0
  40. data/example/config/initializers/content_security_policy.rb +27 -0
  41. data/example/config/initializers/filter_parameter_logging.rb +10 -0
  42. data/example/config/initializers/generators.rb +7 -0
  43. data/example/config/initializers/inflections.rb +18 -0
  44. data/example/config/initializers/permissions_policy.rb +13 -0
  45. data/example/config/initializers/webhukhs.rb +9 -0
  46. data/example/config/locales/en.yml +33 -0
  47. data/example/config/puma.rb +45 -0
  48. data/example/config/routes.rb +5 -0
  49. data/example/config.ru +8 -0
  50. data/example/db/migrate/20240523125859_create_webhukhs_tables.rb +22 -0
  51. data/example/db/schema.rb +24 -0
  52. data/example/db/seeds.rb +9 -0
  53. data/example/lib/assets/.keep +0 -0
  54. data/example/lib/tasks/.keep +0 -0
  55. data/example/log/.keep +0 -0
  56. data/example/public/404.html +67 -0
  57. data/example/public/422.html +67 -0
  58. data/example/public/500.html +66 -0
  59. data/example/public/apple-touch-icon-precomposed.png +0 -0
  60. data/example/public/apple-touch-icon.png +0 -0
  61. data/example/public/favicon.ico +0 -0
  62. data/example/public/robots.txt +1 -0
  63. data/example/test/controllers/.keep +0 -0
  64. data/example/test/fixtures/files/.keep +0 -0
  65. data/example/test/helpers/.keep +0 -0
  66. data/example/test/integration/.keep +0 -0
  67. data/example/test/models/.keep +0 -0
  68. data/example/test/test_helper.rb +15 -0
  69. data/example/tmp/.keep +0 -0
  70. data/example/tmp/pids/.keep +0 -0
  71. data/example/vendor/.keep +0 -0
  72. data/gemfiles/rails_7.1.gemfile +10 -0
  73. data/gemfiles/rails_7.1.gemfile.lock +412 -0
  74. data/gemfiles/rails_8.0.gemfile +10 -0
  75. data/gemfiles/rails_8.0.gemfile.lock +405 -0
  76. data/gemfiles/rails_8.1.gemfile +10 -0
  77. data/gemfiles/rails_8.1.gemfile.lock +405 -0
  78. data/handler-examples/customer_io_handler.rb +36 -0
  79. data/handler-examples/revolut_business_v1_handler.rb +29 -0
  80. data/handler-examples/revolut_business_v2_handler.rb +42 -0
  81. data/handler-examples/starling_payments_handler.rb +25 -0
  82. data/lib/tasks/webhukhs_tasks.rake +4 -0
  83. data/lib/webhukhs/base_handler.rb +100 -0
  84. data/lib/webhukhs/controllers/receive_webhooks_controller.rb +55 -0
  85. data/lib/webhukhs/engine.rb +24 -0
  86. data/lib/webhukhs/install_generator.rb +31 -0
  87. data/lib/webhukhs/jobs/processing_job.rb +33 -0
  88. data/lib/webhukhs/models/received_webhook.rb +99 -0
  89. data/lib/webhukhs/templates/add_headers_to_webhukhs_webhooks.rb.erb +5 -0
  90. data/lib/webhukhs/templates/create_webhukhs_tables.rb.erb +23 -0
  91. data/lib/webhukhs/templates/webhukhs.rb +40 -0
  92. data/lib/webhukhs/version.rb +5 -0
  93. data/lib/webhukhs.rb +23 -0
  94. data/test/test-webhook-handlers/.DS_Store +0 -0
  95. data/test/test-webhook-handlers/extract_id_handler.rb +5 -0
  96. data/test/test-webhook-handlers/failing_with_concealed_errors.rb +7 -0
  97. data/test/test-webhook-handlers/failing_with_exposed_errors.rb +7 -0
  98. data/test/test-webhook-handlers/inactive_handler.rb +5 -0
  99. data/test/test-webhook-handlers/invalid_handler.rb +5 -0
  100. data/test/test-webhook-handlers/private_handler.rb +3 -0
  101. data/test/test-webhook-handlers/webhook_test_handler.rb +13 -0
  102. data/test/test_app.rb +66 -0
  103. data/test/test_helper.rb +50 -0
  104. data/test/webhukhs_test.rb +203 -0
  105. metadata +247 -0
@@ -0,0 +1,24 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema[7.0].define(version: 2024_05_23_125859) do
14
+ create_table "received_webhooks", force: :cascade do |t|
15
+ t.string "handler_event_id", null: false
16
+ t.string "handler_module_name", null: false
17
+ t.string "status", default: "received", null: false
18
+ t.binary "body", null: false
19
+ t.datetime "created_at", null: false
20
+ t.datetime "updated_at", null: false
21
+ t.index ["handler_module_name", "handler_event_id"], name: "webhook_dedup_idx", unique: true
22
+ t.index ["status"], name: "index_received_webhooks_on_status"
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file should contain all the record creation needed to seed the database with its default values.
4
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
5
+ #
6
+ # Examples:
7
+ #
8
+ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
9
+ # Character.create(name: "Luke", movie: movies.first)
File without changes
File without changes
data/example/log/.keep ADDED
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["RAILS_ENV"] ||= "test"
4
+ require_relative "../config/environment"
5
+ require "rails/test_help"
6
+
7
+ class ActiveSupport::TestCase
8
+ # Run tests in parallel with specified workers
9
+ parallelize(workers: :number_of_processors)
10
+
11
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
12
+ fixtures :all
13
+
14
+ # Add more helper methods to be used by all tests here...
15
+ end
data/example/tmp/.keep ADDED
File without changes
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "sqlite3"
6
+ gem "sprockets-rails"
7
+ gem "appraisal"
8
+ gem "rails", "~> 7.1.0"
9
+
10
+ gemspec path: "../"