rails_twirp 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +0 -1
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/lib/rails_twirp/base.rb +12 -6
  6. data/lib/rails_twirp/engine.rb +5 -1
  7. data/lib/rails_twirp/metal.rb +26 -0
  8. data/lib/rails_twirp/version.rb +1 -1
  9. data/rails_twirp.gemspec +2 -3
  10. metadata +10 -146
  11. data/.github/workflows/test.yml +0 -21
  12. data/bin/test +0 -5
  13. data/lib/rails_twirp/testing/integration_test.rb +0 -106
  14. data/test/dummy/Rakefile +0 -6
  15. data/test/dummy/app/assets/config/manifest.js +0 -2
  16. data/test/dummy/app/assets/images/.keep +0 -0
  17. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  18. data/test/dummy/app/channels/application_cable/channel.rb +0 -4
  19. data/test/dummy/app/channels/application_cable/connection.rb +0 -4
  20. data/test/dummy/app/controllers/application_controller.rb +0 -2
  21. data/test/dummy/app/controllers/application_twirp_controller.rb +0 -7
  22. data/test/dummy/app/controllers/concerns/.keep +0 -0
  23. data/test/dummy/app/controllers/dummy_controller.rb +0 -5
  24. data/test/dummy/app/controllers/pings_controller.rb +0 -40
  25. data/test/dummy/app/controllers/testmod/nested/other_controller.rb +0 -10
  26. data/test/dummy/app/helpers/application_helper.rb +0 -2
  27. data/test/dummy/app/helpers/random_helper.rb +0 -5
  28. data/test/dummy/app/javascript/packs/application.js +0 -15
  29. data/test/dummy/app/jobs/application_job.rb +0 -7
  30. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  31. data/test/dummy/app/models/application_record.rb +0 -3
  32. data/test/dummy/app/models/concerns/.keep +0 -0
  33. data/test/dummy/app/views/dummy/rpc_name_check.pb.pbbuilder +0 -1
  34. data/test/dummy/app/views/layouts/application.html.erb +0 -15
  35. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  36. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  37. data/test/dummy/app/views/pings/ping_template.pb.pbbuilder +0 -1
  38. data/test/dummy/bin/generate +0 -3
  39. data/test/dummy/bin/rails +0 -4
  40. data/test/dummy/bin/rake +0 -4
  41. data/test/dummy/bin/setup +0 -33
  42. data/test/dummy/config/application.rb +0 -23
  43. data/test/dummy/config/boot.rb +0 -5
  44. data/test/dummy/config/cable.yml +0 -10
  45. data/test/dummy/config/database.yml +0 -25
  46. data/test/dummy/config/environment.rb +0 -5
  47. data/test/dummy/config/environments/development.rb +0 -76
  48. data/test/dummy/config/environments/production.rb +0 -120
  49. data/test/dummy/config/environments/test.rb +0 -59
  50. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
  51. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
  52. data/test/dummy/config/initializers/content_security_policy.rb +0 -28
  53. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  54. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  55. data/test/dummy/config/initializers/inflections.rb +0 -16
  56. data/test/dummy/config/initializers/mime_types.rb +0 -4
  57. data/test/dummy/config/initializers/permissions_policy.rb +0 -11
  58. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  59. data/test/dummy/config/locales/en.yml +0 -33
  60. data/test/dummy/config/puma.rb +0 -43
  61. data/test/dummy/config/routes.rb +0 -3
  62. data/test/dummy/config/storage.yml +0 -34
  63. data/test/dummy/config/twirp/routes.rb +0 -22
  64. data/test/dummy/config.ru +0 -6
  65. data/test/dummy/lib/assets/.keep +0 -0
  66. data/test/dummy/log/.keep +0 -0
  67. data/test/dummy/proto/api.proto +0 -30
  68. data/test/dummy/proto/api_pb.rb +0 -29
  69. data/test/dummy/proto/api_twirp.rb +0 -25
  70. data/test/dummy/public/404.html +0 -67
  71. data/test/dummy/public/422.html +0 -67
  72. data/test/dummy/public/500.html +0 -66
  73. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  74. data/test/dummy/public/apple-touch-icon.png +0 -0
  75. data/test/dummy/public/favicon.ico +0 -0
  76. data/test/dummy_test.rb +0 -10
  77. data/test/other_controller_test.rb +0 -9
  78. data/test/ping_controller_test.rb +0 -114
  79. data/test/rails_twirp_test.rb +0 -7
  80. data/test/test_helper.rb +0 -16
@@ -1,22 +0,0 @@
1
- require_relative "../../proto/api_twirp"
2
-
3
- Rails.application.twirp.routes.draw do
4
- service RPC::DummyAPI::DummyService do
5
- rpc "Ping", to: "pings#ping"
6
- rpc "PingRender", to: "pings#ping_render"
7
- rpc "PingTemplate", to: "pings#ping_template"
8
- rpc "ErrorResponse", to: "pings#error_response"
9
- rpc "RaiseError", to: "pings#raise_error"
10
- rpc "UncaughtError", to: "pings#uncaught_raise"
11
- rpc "BeforeError", to: "pings#before_error"
12
- rpc "RpcNameCheck", to: "dummy#rpc_name_check"
13
- end
14
-
15
- scope module: :testmod do
16
- service RPC::DummyAPI::DummyService do
17
- scope module: "nested" do
18
- rpc "Nested", to: "other#ping"
19
- end
20
- end
21
- end
22
- end
data/test/dummy/config.ru DELETED
@@ -1,6 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require_relative "config/environment"
4
-
5
- run Rails.application
6
- Rails.application.load_server
File without changes
data/test/dummy/log/.keep DELETED
File without changes
@@ -1,30 +0,0 @@
1
- syntax = "proto3";
2
-
3
- option ruby_package = "RPC::DummyAPI";
4
-
5
- package dummy.api;
6
-
7
- service Dummy {
8
- rpc Ping(PingRequest) returns (PingResponse);
9
- rpc PingRender(PingRequest) returns (PingResponse);
10
- rpc PingTemplate(PingRequest) returns (PingResponse);
11
- rpc ErrorResponse(PingRequest) returns (PingResponse);
12
- rpc RaiseError(PingRequest) returns (PingResponse);
13
- rpc UncaughtError(PingRequest) returns (PingResponse);
14
- rpc BeforeError(PingRequest) returns (PingResponse);
15
- rpc Nested(PingRequest) returns (PingResponse);
16
- rpc RpcNameCheck(RpcNameCheckRequest) returns (RpcNameCheckResponse);
17
- }
18
-
19
- message PingRequest {
20
- string name = 1;
21
- }
22
-
23
- message PingResponse {
24
- string double_name = 2;
25
- }
26
-
27
- message RpcNameCheckRequest{}
28
- message RpcNameCheckResponse{
29
- string rpc_name = 1;
30
- }
@@ -1,29 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: api.proto
3
-
4
- require 'google/protobuf'
5
-
6
- Google::Protobuf::DescriptorPool.generated_pool.build do
7
- add_file("api.proto", :syntax => :proto3) do
8
- add_message "dummy.api.PingRequest" do
9
- optional :name, :string, 1
10
- end
11
- add_message "dummy.api.PingResponse" do
12
- optional :double_name, :string, 2
13
- end
14
- add_message "dummy.api.RpcNameCheckRequest" do
15
- end
16
- add_message "dummy.api.RpcNameCheckResponse" do
17
- optional :rpc_name, :string, 1
18
- end
19
- end
20
- end
21
-
22
- module RPC
23
- module DummyAPI
24
- PingRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.PingRequest").msgclass
25
- PingResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.PingResponse").msgclass
26
- RpcNameCheckRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.RpcNameCheckRequest").msgclass
27
- RpcNameCheckResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dummy.api.RpcNameCheckResponse").msgclass
28
- end
29
- end
@@ -1,25 +0,0 @@
1
- # Code generated by protoc-gen-twirp_ruby 1.8.0, DO NOT EDIT.
2
- require 'twirp'
3
- require_relative 'api_pb.rb'
4
-
5
- module RPC
6
- module DummyAPI
7
- class DummyService < Twirp::Service
8
- package 'dummy.api'
9
- service 'Dummy'
10
- rpc :Ping, PingRequest, PingResponse, :ruby_method => :ping
11
- rpc :PingRender, PingRequest, PingResponse, :ruby_method => :ping_render
12
- rpc :PingTemplate, PingRequest, PingResponse, :ruby_method => :ping_template
13
- rpc :ErrorResponse, PingRequest, PingResponse, :ruby_method => :error_response
14
- rpc :RaiseError, PingRequest, PingResponse, :ruby_method => :raise_error
15
- rpc :UncaughtError, PingRequest, PingResponse, :ruby_method => :uncaught_error
16
- rpc :BeforeError, PingRequest, PingResponse, :ruby_method => :before_error
17
- rpc :Nested, PingRequest, PingResponse, :ruby_method => :nested
18
- rpc :RpcNameCheck, RpcNameCheckRequest, RpcNameCheckResponse, :ruby_method => :rpc_name_check
19
- end
20
-
21
- class DummyClient < Twirp::Client
22
- client_for DummyService
23
- end
24
- end
25
- end
@@ -1,67 +0,0 @@
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>
@@ -1,67 +0,0 @@
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>
@@ -1,66 +0,0 @@
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
data/test/dummy_test.rb DELETED
@@ -1,10 +0,0 @@
1
- require "test_helper"
2
-
3
- class DummyControllerTest < RailsTwirp::IntegrationTest
4
- test "controller gets rpc name" do
5
- req = RPC::DummyAPI::RpcNameCheckRequest.new
6
- rpc RPC::DummyAPI::DummyService, "RpcNameCheck", req
7
- assert_instance_of RPC::DummyAPI::RpcNameCheckResponse, response
8
- assert_equal "RpcNameCheck", response.rpc_name
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- require "test_helper"
2
-
3
- class OtherControllerTest < RailsTwirp::IntegrationTest
4
- test "modules work" do
5
- req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
6
- rpc RPC::DummyAPI::DummyService, "Nested", req
7
- assert_equal "BoukeBouke", response.double_name
8
- end
9
- end
@@ -1,114 +0,0 @@
1
- require "test_helper"
2
-
3
- class PingControllerTest < RailsTwirp::IntegrationTest
4
- test "you can ping it" do
5
- req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
6
- rpc RPC::DummyAPI::DummyService, "Ping", req
7
- assert_equal "BoukeBouke", response.double_name
8
- end
9
-
10
- test "you can ping render" do
11
- req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
12
- rpc RPC::DummyAPI::DummyService, "PingRender", req
13
- refute_instance_of Twirp::Error, response
14
- assert_equal "http://www.example.com/twirp BoukeBouke", response.double_name
15
- end
16
-
17
- test "you can ping render with host and https" do
18
- host! "localhost"
19
- https!
20
- req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
21
- rpc RPC::DummyAPI::DummyService, "PingRender", req
22
- refute_instance_of Twirp::Error, response
23
- assert_equal "https://localhost/twirp BoukeBouke", response.double_name
24
- end
25
-
26
- test "you can ping template" do
27
- req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
28
- rpc RPC::DummyAPI::DummyService, "PingTemplate", req
29
- refute_instance_of Twirp::Error, response
30
- assert_equal "BoukeBouke", response.double_name
31
- end
32
-
33
- test "error response" do
34
- req = RPC::DummyAPI::PingRequest.new
35
- rpc RPC::DummyAPI::DummyService, "ErrorResponse", req
36
- assert_instance_of Twirp::Error, response
37
- assert_equal "You are not authenticated!!", response.msg
38
- assert_equal :unauthenticated, response.code
39
- end
40
-
41
- test "raise error" do
42
- req = RPC::DummyAPI::PingRequest.new
43
- rpc RPC::DummyAPI::DummyService, "RaiseError", req
44
- assert_instance_of Twirp::Error, response
45
- assert_equal "Not found", response.msg
46
- assert_equal :not_found, response.code
47
- end
48
-
49
- test "uncaught errors should bubble up to the test" do
50
- req = RPC::DummyAPI::PingRequest.new
51
- assert_raises StandardError, "Uncaught" do
52
- rpc RPC::DummyAPI::DummyService, "UncaughtError", req
53
- end
54
- end
55
-
56
- test "uncaught errors should return an internal error with details if show_exceptions is true" do
57
- Rails.application.env_config["action_dispatch.show_exceptions"] = true
58
-
59
- req = RPC::DummyAPI::PingRequest.new
60
- rpc RPC::DummyAPI::DummyService, "UncaughtError", req
61
- assert_instance_of Twirp::Error, response
62
- assert_equal :internal, response.code
63
- assert_equal "Uncaught", response.msg
64
- assert_equal "StandardError", response.meta["cause"]
65
- ensure
66
- Rails.application.env_config["action_dispatch.show_exceptions"] = false
67
- end
68
-
69
- test "uncaught errors should be fanned out to the exception handler proc if one is defined" do
70
- Rails.application.env_config["action_dispatch.show_exceptions"] = true
71
-
72
- captured_exception = nil
73
- RailsTwirp.unhandled_exception_handler = ->(e) { captured_exception = e }
74
-
75
- req = RPC::DummyAPI::PingRequest.new
76
- rpc RPC::DummyAPI::DummyService, "UncaughtError", req
77
- assert_instance_of Twirp::Error, response
78
- assert_equal :internal, response.code
79
- assert_equal "Uncaught", response.msg
80
- assert_equal "StandardError", response.meta["cause"]
81
- assert_kind_of StandardError, captured_exception
82
- ensure
83
- RailsTwirp.unhandled_exception_handler = nil
84
- Rails.application.env_config["action_dispatch.show_exceptions"] = false
85
- end
86
-
87
- test "uncaught errors should return an internal error without if show_exceptions is true and show_detailed_exceptions is false" do
88
- Rails.application.env_config["action_dispatch.show_exceptions"] = true
89
- Rails.application.env_config["action_dispatch.show_detailed_exceptions"] = false
90
-
91
- req = RPC::DummyAPI::PingRequest.new
92
- rpc RPC::DummyAPI::DummyService, "UncaughtError", req
93
- assert_instance_of Twirp::Error, response
94
- assert_equal :internal, response.code
95
- assert_equal "Internal error", response.msg
96
- ensure
97
- Rails.application.env_config["action_dispatch.show_detailed_exceptions"] = true
98
- Rails.application.env_config["action_dispatch.show_exceptions"] = false
99
- end
100
-
101
- test "before error" do
102
- req = RPC::DummyAPI::PingRequest.new
103
- rpc RPC::DummyAPI::DummyService, "BeforeError", req
104
- assert_instance_of Twirp::Error, response
105
- assert_equal "yOuR ReQuEsT Is mAlFoRmEd", response.msg
106
- assert_equal :malformed, response.code
107
- end
108
-
109
- test "controller is set to the controller that handled the request" do
110
- req = RPC::DummyAPI::PingRequest.new(name: "Bouke")
111
- rpc RPC::DummyAPI::DummyService, "Ping", req
112
- assert_instance_of PingsController, controller
113
- end
114
- end
@@ -1,7 +0,0 @@
1
- require "test_helper"
2
-
3
- class RailsTwirpTest < ActiveSupport::TestCase
4
- test "it has a version number" do
5
- assert RailsTwirp::VERSION
6
- end
7
- end
data/test/test_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require_relative "../test/dummy/config/environment"
5
- ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
6
- require "rails/test_help"
7
- require "rails/test_unit/reporter"
8
- Rails::TestUnitReporter.executable = "bin/test"
9
-
10
- # Load fixtures from the engine
11
- if ActiveSupport::TestCase.respond_to?(:fixture_path=)
12
- ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
13
- ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
14
- ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
15
- ActiveSupport::TestCase.fixtures :all
16
- end