http_stub 0.25.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http_stub.rb +32 -9
- data/lib/http_stub/configurer.rb +2 -10
- data/lib/http_stub/configurer/dsl/scenario_builder.rb +13 -11
- data/lib/http_stub/configurer/dsl/server.rb +32 -43
- data/lib/http_stub/configurer/dsl/server_endpoint_template.rb +23 -0
- data/lib/http_stub/configurer/dsl/session.rb +55 -0
- data/lib/http_stub/configurer/dsl/session_endpoint_template.rb +22 -0
- data/lib/http_stub/configurer/dsl/session_factory.rb +34 -0
- data/lib/http_stub/configurer/dsl/stub_builder.rb +18 -8
- data/lib/http_stub/configurer/dsl/stub_builder_template.rb +26 -0
- data/lib/http_stub/configurer/request/http/basic.rb +9 -3
- data/lib/http_stub/configurer/request/http/factory.rb +7 -16
- data/lib/http_stub/configurer/request/http/multipart.rb +5 -7
- data/lib/http_stub/configurer/request/stub.rb +3 -3
- data/lib/http_stub/configurer/request/triggers.rb +25 -0
- data/lib/http_stub/configurer/server/command_processor.rb +8 -10
- data/lib/http_stub/configurer/server/configuration.rb +33 -0
- data/lib/http_stub/configurer/server/facade.rb +21 -43
- data/lib/http_stub/configurer/server/request_processor.rb +2 -2
- data/lib/http_stub/configurer/server/session_facade.rb +64 -0
- data/lib/http_stub/extensions/core/uri.rb +28 -0
- data/lib/http_stub/extensions/rack/handler.rb +1 -0
- data/lib/http_stub/extensions/sinatra/namespace.rb +9 -0
- data/lib/http_stub/rake/server_tasks.rb +1 -4
- data/lib/http_stub/server/application/application.rb +17 -98
- data/lib/http_stub/server/application/configuration.rb +38 -0
- data/lib/http_stub/server/application/cross_origin_support.rb +7 -5
- data/lib/http_stub/server/application/request_support.rb +38 -0
- data/lib/http_stub/server/application/response_support.rb +19 -0
- data/lib/http_stub/server/application/routes/memory.rb +37 -0
- data/lib/http_stub/server/application/routes/resource.rb +23 -0
- data/lib/http_stub/server/application/routes/scenario.rb +52 -0
- data/lib/http_stub/server/application/routes/session.rb +65 -0
- data/lib/http_stub/server/application/routes/stub.rb +75 -0
- data/lib/http_stub/server/application/session_uri_support.rb +15 -0
- data/lib/http_stub/server/memory/controller.rb +25 -0
- data/lib/http_stub/server/memory/memory.rb +32 -0
- data/lib/http_stub/server/registry.rb +25 -8
- data/lib/http_stub/server/request/factory.rb +23 -0
- data/lib/http_stub/server/request/parameters.rb +2 -2
- data/lib/http_stub/server/request/request.rb +6 -11
- data/lib/http_stub/server/request/sinatra_request.rb +26 -0
- data/lib/http_stub/server/scenario/controller.rb +16 -11
- data/lib/http_stub/server/scenario/not_found_error.rb +15 -0
- data/lib/http_stub/server/session.rb +14 -0
- data/lib/http_stub/server/session/configuration.rb +32 -0
- data/lib/http_stub/server/session/controller.rb +40 -0
- data/lib/http_stub/server/session/empty.rb +15 -0
- data/lib/http_stub/server/session/identifier_strategy.rb +24 -0
- data/lib/http_stub/server/session/registry.rb +38 -0
- data/lib/http_stub/server/session/session.rb +80 -0
- data/lib/http_stub/server/stub/controller.rb +18 -12
- data/lib/http_stub/server/stub/empty.rb +1 -1
- data/lib/http_stub/server/stub/match/controller.rb +9 -5
- data/lib/http_stub/server/stub/payload/response_body_modifier.rb +3 -1
- data/lib/http_stub/server/stub/registry.rb +6 -13
- data/lib/http_stub/server/stub/triggers.rb +11 -9
- data/lib/http_stub/server/views/_home.haml +2 -0
- data/lib/http_stub/server/views/_post_link_function.haml +26 -0
- data/lib/http_stub/server/views/_session.haml +16 -0
- data/lib/http_stub/server/views/_stub.haml +8 -2
- data/lib/http_stub/server/views/_stubs.haml +4 -0
- data/lib/http_stub/server/views/application.sass +4 -1
- data/lib/http_stub/server/views/layout.haml +1 -0
- data/lib/http_stub/server/views/scenario.haml +4 -3
- data/lib/http_stub/server/views/scenarios.haml +7 -6
- data/lib/http_stub/server/views/session.haml +3 -0
- data/lib/http_stub/server/views/sessions.haml +6 -0
- data/lib/http_stub/server/views/stubs.haml +1 -4
- data/lib/http_stub/server/views/transactional_session.haml +2 -0
- data/lib/http_stub/version.rb +1 -1
- data/spec/acceptance/configurer_initialization_spec.rb +40 -51
- data/spec/acceptance/configurer_part_spec.rb +5 -7
- data/spec/acceptance/cross_origin_support_spec.rb +7 -13
- data/spec/acceptance/endpoint_template_spec.rb +2 -4
- data/spec/acceptance/request_reference_spec.rb +1 -3
- data/spec/acceptance/scenario_spec.rb +7 -9
- data/spec/acceptance/server_defaults_spec.rb +2 -4
- data/spec/acceptance/server_memory_spec.rb +20 -0
- data/spec/acceptance/session_spec.rb +125 -0
- data/spec/acceptance/stub_body_request_matching_spec.rb +2 -4
- data/spec/acceptance/stub_control_values_spec.rb +19 -18
- data/spec/acceptance/stub_match_last_spec.rb +0 -4
- data/spec/acceptance/stub_match_list_spec.rb +0 -4
- data/spec/acceptance/stub_miss_list_spec.rb +0 -4
- data/spec/acceptance/stub_spec.rb +11 -11
- data/spec/acceptance/stub_trigger_spec.rb +60 -13
- data/spec/lib/http_stub/configurer/dsl/scenario_builder_spec.rb +83 -30
- data/spec/lib/http_stub/configurer/dsl/server_endpoint_template_spec.rb +167 -0
- data/spec/lib/http_stub/configurer/dsl/server_spec.rb +306 -176
- data/spec/lib/http_stub/configurer/dsl/session_endpoint_template_spec.rb +150 -0
- data/spec/lib/http_stub/configurer/dsl/session_factory_spec.rb +97 -0
- data/spec/lib/http_stub/configurer/dsl/session_spec.rb +222 -0
- data/spec/lib/http_stub/configurer/dsl/stub_builder_spec.rb +209 -48
- data/spec/lib/http_stub/configurer/dsl/stub_builder_template_spec.rb +203 -0
- data/spec/lib/http_stub/configurer/request/http/basic_spec.rb +80 -4
- data/spec/lib/http_stub/configurer/request/http/factory_spec.rb +115 -56
- data/spec/lib/http_stub/configurer/request/http/multipart_spec.rb +39 -6
- data/spec/lib/http_stub/configurer/request/stub_spec.rb +50 -108
- data/spec/lib/http_stub/configurer/request/triggers_spec.rb +101 -0
- data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +11 -10
- data/spec/lib/http_stub/configurer/server/configuration_spec.rb +139 -0
- data/spec/lib/http_stub/configurer/server/facade_spec.rb +65 -142
- data/spec/lib/http_stub/configurer/server/request_processor_spec.rb +7 -6
- data/spec/lib/http_stub/configurer/server/session_facade_spec.rb +336 -0
- data/spec/lib/http_stub/configurer_spec.rb +105 -0
- data/spec/lib/http_stub/extensions/core/uri_spec.rb +75 -0
- data/spec/lib/http_stub/extensions/rack/handler_spec.rb +1 -1
- data/spec/lib/http_stub/extensions/sinatra/namespace_spec.rb +36 -0
- data/spec/lib/http_stub/rake/server_tasks_smoke_spec.rb +4 -3
- data/spec/lib/http_stub/rake/server_tasks_spec.rb +47 -10
- data/spec/lib/http_stub/server/application/application_spec.rb +44 -301
- data/spec/lib/http_stub/server/application/configuration_spec.rb +59 -0
- data/spec/lib/http_stub/server/application/cross_origin_support_spec.rb +23 -20
- data/spec/lib/http_stub/server/application/request_support_integration_spec.rb +93 -0
- data/spec/lib/http_stub/server/application/request_support_spec.rb +61 -0
- data/spec/lib/http_stub/server/application/response_support_spec.rb +30 -0
- data/spec/lib/http_stub/server/application/routes/memory_spec.rb +41 -0
- data/spec/lib/http_stub/server/application/routes/resource_spec.rb +16 -0
- data/spec/lib/http_stub/server/application/routes/scenario_spec.rb +117 -0
- data/spec/lib/http_stub/server/application/routes/session_integration_spec.rb +46 -0
- data/spec/lib/http_stub/server/application/routes/session_spec.rb +186 -0
- data/spec/lib/http_stub/server/application/{application_integration_spec.rb → routes/stub_integration_spec.rb} +16 -38
- data/spec/lib/http_stub/server/application/routes/stub_spec.rb +202 -0
- data/spec/lib/http_stub/server/application/session_uri_support_spec.rb +48 -0
- data/spec/lib/http_stub/server/application/text_formatting_support_spec.rb +3 -3
- data/spec/lib/http_stub/server/memory/controller_spec.rb +47 -0
- data/spec/lib/http_stub/server/memory/memory_spec.rb +122 -0
- data/spec/lib/http_stub/server/registry_spec.rb +153 -34
- data/spec/lib/http_stub/server/request/factory_spec.rb +74 -0
- data/spec/lib/http_stub/server/request/parameters_spec.rb +5 -8
- data/spec/lib/http_stub/server/request/request_spec.rb +52 -52
- data/spec/lib/http_stub/server/request/sinatra_request_spec.rb +132 -0
- data/spec/lib/http_stub/server/scenario/controller_spec.rb +121 -35
- data/spec/lib/http_stub/server/scenario/not_found_error_spec.rb +25 -0
- data/spec/lib/http_stub/server/session/configuration_spec.rb +94 -0
- data/spec/lib/http_stub/server/session/controller_spec.rb +106 -0
- data/spec/lib/http_stub/server/session/empty_spec.rb +13 -0
- data/spec/lib/http_stub/server/session/identifier_strategy_spec.rb +126 -0
- data/spec/lib/http_stub/server/session/registry_spec.rb +214 -0
- data/spec/lib/http_stub/server/session/session_spec.rb +444 -0
- data/spec/lib/http_stub/server/stub/controller_spec.rb +89 -37
- data/spec/lib/http_stub/server/stub/empty_spec.rb +2 -2
- data/spec/lib/http_stub/server/stub/match/controller_spec.rb +59 -16
- data/spec/lib/http_stub/server/stub/payload/response_body_modifier_spec.rb +7 -8
- data/spec/lib/http_stub/server/stub/registry_integration_spec.rb +42 -15
- data/spec/lib/http_stub/server/stub/registry_spec.rb +38 -59
- data/spec/lib/http_stub/server/stub/triggers_spec.rb +93 -34
- data/spec/spec_helper.rb +13 -1
- data/spec/support/contain_file.rb +23 -0
- data/spec/support/cross_origin_server/application.rb +1 -1
- data/spec/support/cross_origin_server/index_page.rb +2 -2
- data/spec/support/cross_origin_server/integration.rb +3 -2
- data/spec/support/cross_origin_server/public/index.html +2 -1
- data/spec/support/http_stub/configurer_integration.rb +12 -14
- data/spec/support/http_stub/server/application/http_stub_rack_application_test.rb +47 -0
- data/spec/support/http_stub/server/driver.rb +56 -0
- data/spec/support/http_stub/server/memory_fixture.rb +17 -0
- data/spec/support/http_stub/server/request_fixture.rb +7 -6
- data/spec/support/http_stub/server/scenario_fixture.rb +13 -0
- data/spec/support/http_stub/server/session_fixture.rb +27 -0
- data/spec/support/http_stub/server_integration.rb +12 -17
- data/spec/support/http_stub/stub_fixture.rb +19 -6
- data/spec/support/include_in_json.rb +4 -4
- data/spec/support/rack/rack_application_test.rb +9 -0
- data/spec/support/rack/request_fixture.rb +13 -0
- data/spec/support/surpressed_output.rb +10 -0
- metadata +149 -36
- data/lib/http_stub/configurer/dsl/deprecated.rb +0 -60
- data/lib/http_stub/configurer/dsl/endpoint_template.rb +0 -38
- data/lib/http_stub/configurer/dsl/scenario_activator.rb +0 -15
- data/lib/http_stub/configurer/dsl/stub_activator_builder.rb +0 -24
- data/lib/http_stub/configurer/dsl/stub_builder_producer.rb +0 -21
- data/lib/http_stub/server/request.rb +0 -12
- data/lib/http_stub/server/scenario/activator.rb +0 -25
- data/lib/http_stub/server/views/_activate_scenario.haml +0 -23
- data/lib/http_stub/server/views/index.haml +0 -8
- data/spec/acceptance/activator_spec.rb +0 -81
- data/spec/lib/http_stub/configurer/dsl/deprecated_spec.rb +0 -240
- data/spec/lib/http_stub/configurer/dsl/endpoint_template_spec.rb +0 -255
- data/spec/lib/http_stub/configurer/dsl/scenario_activator_spec.rb +0 -62
- data/spec/lib/http_stub/configurer/dsl/stub_activator_builder_spec.rb +0 -120
- data/spec/lib/http_stub/configurer/dsl/stub_builder_producer_spec.rb +0 -85
- data/spec/lib/http_stub/server/request_spec.rb +0 -24
- data/spec/lib/http_stub/server/scenario/activator_spec.rb +0 -111
- data/spec/support/http_stub/server/scenario/scenario_fixture.rb +0 -15
@@ -26,10 +26,7 @@ module HttpStub
|
|
26
26
|
|
27
27
|
def run_application(args)
|
28
28
|
HttpStub::Server::Application::Application.instance_eval do
|
29
|
-
|
30
|
-
set :port, args[:configurer] ? args[:configurer].stub_server.port : args[:port]
|
31
|
-
enable :cross_origin_support if args[:configurer] &&
|
32
|
-
args[:configurer].stub_server.enabled?(:cross_origin_support)
|
29
|
+
configure(args)
|
33
30
|
run!
|
34
31
|
end
|
35
32
|
end
|
@@ -4,120 +4,39 @@ module HttpStub
|
|
4
4
|
|
5
5
|
class Application < Sinatra::Base
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
private_constant :SUPPORTED_REQUEST_TYPES
|
7
|
+
register Sinatra::Namespace
|
8
|
+
register Sinatra::Partial
|
10
9
|
|
11
10
|
set :root, File.expand_path("../..", __FILE__)
|
12
|
-
|
13
|
-
|
11
|
+
set :environment, :test
|
12
|
+
set :session_identifier, nil
|
14
13
|
|
15
14
|
enable :dump_errors, :logging, :partial_underscores
|
16
15
|
disable :protection, :cross_origin_support
|
17
16
|
|
18
|
-
def self.
|
19
|
-
|
17
|
+
def self.configure(args)
|
18
|
+
configuration = HttpStub::Server::Application::Configuration.new(args)
|
19
|
+
configuration.settings.each { |name, value| set(name, value) }
|
20
20
|
end
|
21
21
|
|
22
|
-
private_class_method :any_request_type
|
23
|
-
|
24
22
|
def initialize
|
23
|
+
@session_configuration = HttpStub::Server::Session::Configuration.new(settings.session_identifier)
|
24
|
+
@server_memory = HttpStub::Server::Memory::Memory.new(@session_configuration)
|
25
25
|
super()
|
26
|
-
@scenario_registry = HttpStub::Server::Registry.new("scenario")
|
27
|
-
@stub_registry = HttpStub::Server::Stub::Registry.new
|
28
|
-
@stub_match_registry = HttpStub::Server::Registry.new("stub match")
|
29
|
-
@stub_miss_registry = HttpStub::Server::Registry.new("stub miss")
|
30
|
-
@scenario_controller = HttpStub::Server::Scenario::Controller.new(@scenario_registry, @stub_registry)
|
31
|
-
@stub_controller =
|
32
|
-
HttpStub::Server::Stub::Controller.new(@stub_registry, @stub_match_registry, @stub_miss_registry)
|
33
|
-
@stub_match_controller = HttpStub::Server::Stub::Match::Controller.new(@stub_match_registry)
|
34
26
|
end
|
35
27
|
|
36
|
-
|
37
|
-
|
38
|
-
@http_stub_request = HttpStub::Server::Request.create(request)
|
39
|
-
end
|
28
|
+
include HttpStub::Server::Application::RequestSupport
|
29
|
+
include HttpStub::Server::Application::ResponseSupport
|
40
30
|
|
41
31
|
register HttpStub::Server::Application::CrossOriginSupport
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
response = @stub_controller.register(@http_stub_request, logger)
|
49
|
-
@response_pipeline.process(response)
|
50
|
-
end
|
51
|
-
|
52
|
-
get "/http_stub/stubs" do
|
53
|
-
haml :stubs, {}, stubs: @stub_registry.all
|
54
|
-
end
|
55
|
-
|
56
|
-
delete "/http_stub/stubs" do
|
57
|
-
@stub_controller.clear(logger)
|
58
|
-
halt 200, "OK"
|
59
|
-
end
|
60
|
-
|
61
|
-
post "/http_stub/stubs/memory" do
|
62
|
-
@stub_registry.remember
|
63
|
-
halt 200, "OK"
|
64
|
-
end
|
65
|
-
|
66
|
-
get "/http_stub/stubs/memory" do
|
67
|
-
@stub_registry.recall
|
68
|
-
halt 200, "OK"
|
69
|
-
end
|
70
|
-
|
71
|
-
get "/http_stub/stubs/matches" do
|
72
|
-
haml :stub_matches, {}, matches: @stub_match_registry.all
|
73
|
-
end
|
74
|
-
|
75
|
-
get "/http_stub/stubs/matches/last" do
|
76
|
-
response = @stub_match_controller.find_last(@http_stub_request, logger)
|
77
|
-
@response_pipeline.process(response)
|
78
|
-
end
|
79
|
-
|
80
|
-
get "/http_stub/stubs/misses" do
|
81
|
-
haml :stub_misses, {}, misses: @stub_miss_registry.all
|
82
|
-
end
|
83
|
-
|
84
|
-
get "/http_stub/stubs/:id" do
|
85
|
-
haml :stub, {}, the_stub: @stub_registry.find(params[:id], logger)
|
86
|
-
end
|
87
|
-
|
88
|
-
post "/http_stub/scenarios" do
|
89
|
-
response = @scenario_controller.register(@http_stub_request, logger)
|
90
|
-
@response_pipeline.process(response)
|
91
|
-
end
|
92
|
-
|
93
|
-
get "/http_stub/scenarios" do
|
94
|
-
pass unless params[:name]
|
95
|
-
haml :scenario, {}, scenario: @scenario_registry.find(URI.decode_www_form_component(params[:name]), logger)
|
96
|
-
end
|
97
|
-
|
98
|
-
get "/http_stub/scenarios" do
|
99
|
-
haml :scenarios, {}, scenarios: @scenario_registry.all.sort_by(&:name)
|
100
|
-
end
|
101
|
-
|
102
|
-
post "/http_stub/scenarios/activate" do
|
103
|
-
response = @scenario_controller.activate(params[:name], logger)
|
104
|
-
@response_pipeline.process(response)
|
105
|
-
end
|
106
|
-
|
107
|
-
delete "/http_stub/scenarios" do
|
108
|
-
@scenario_controller.clear(logger)
|
109
|
-
halt 200, "OK"
|
110
|
-
end
|
111
|
-
|
112
|
-
get "/application.css" do
|
113
|
-
sass :application
|
114
|
-
end
|
115
|
-
|
116
|
-
any_request_type "*" do
|
117
|
-
response = @stub_controller.match(@http_stub_request, logger)
|
118
|
-
@response_pipeline.process(response)
|
119
|
-
end
|
33
|
+
include HttpStub::Server::Application::Routes::Memory
|
34
|
+
include HttpStub::Server::Application::Routes::Resource
|
35
|
+
include HttpStub::Server::Application::Routes::Scenario
|
36
|
+
include HttpStub::Server::Application::Routes::Session
|
37
|
+
include HttpStub::Server::Application::Routes::Stub
|
120
38
|
|
39
|
+
helpers HttpStub::Server::Application::SessionUriSupport
|
121
40
|
helpers HttpStub::Server::Application::TextFormattingSupport
|
122
41
|
|
123
42
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
|
5
|
+
class Configuration
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
@configurer = args[:configurer]
|
9
|
+
@port = args[:port]
|
10
|
+
end
|
11
|
+
|
12
|
+
def settings
|
13
|
+
@configurer ? configurer_settings : direct_settings
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def configurer_settings
|
19
|
+
{
|
20
|
+
port: @configurer.stub_server.port,
|
21
|
+
session_identifier: @configurer.stub_server.session_identifier,
|
22
|
+
cross_origin_support: @configurer.stub_server.enabled?(:cross_origin_support)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def direct_settings
|
27
|
+
{
|
28
|
+
port: @port,
|
29
|
+
session_identifier: nil,
|
30
|
+
cross_origin_support: false
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -22,19 +22,21 @@ module HttpStub
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def determine_allowed_methods
|
25
|
-
|
25
|
+
http_stub_request.headers["Access_Control_Request_Method"] || http_stub_request.method.upcase
|
26
26
|
end
|
27
27
|
|
28
28
|
def determine_allowed_headers
|
29
|
-
|
29
|
+
http_stub_request.headers["Access_Control_Request_Headers"] || http_stub_request.headers.keys.join(",")
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.registered(application)
|
35
|
-
application.
|
36
|
-
|
37
|
-
|
35
|
+
application.instance_eval do
|
36
|
+
helpers HttpStub::Server::Application::CrossOriginSupport::Helpers
|
37
|
+
before { add_headers_if_necessary }
|
38
|
+
options("*") { handle_options_if_necessary }
|
39
|
+
end
|
38
40
|
end
|
39
41
|
|
40
42
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
|
5
|
+
module RequestSupport
|
6
|
+
|
7
|
+
STUBBABLE_REQUEST_METHODS = [ :get, :post, :put, :patch, :delete, :options ].freeze
|
8
|
+
|
9
|
+
private_constant :STUBBABLE_REQUEST_METHODS
|
10
|
+
|
11
|
+
attr_reader :http_stub_request
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super()
|
15
|
+
@request_factory = HttpStub::Server::Request::Factory.new(@session_configuration, @server_memory)
|
16
|
+
end
|
17
|
+
|
18
|
+
def establish_http_stub_request
|
19
|
+
@http_stub_request = @request_factory.create(request, params, logger)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(application)
|
23
|
+
application.instance_eval do
|
24
|
+
|
25
|
+
def self.any_request_method(path, opts={}, &block)
|
26
|
+
STUBBABLE_REQUEST_METHODS.each { |request_method| self.send(request_method, path, opts, &block) }
|
27
|
+
end
|
28
|
+
|
29
|
+
before { establish_http_stub_request }
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
|
5
|
+
module ResponseSupport
|
6
|
+
|
7
|
+
def self.included(application)
|
8
|
+
application.instance_eval do
|
9
|
+
|
10
|
+
before { @response_pipeline = HttpStub::Server::Application::ResponsePipeline.new(self) }
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
module Routes
|
5
|
+
|
6
|
+
module Memory
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super()
|
10
|
+
@memory_controller = HttpStub::Server::Memory::Controller.new(@session_configuration, @server_memory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(application)
|
14
|
+
application.instance_eval do
|
15
|
+
|
16
|
+
namespace "/http_stub/memory" do
|
17
|
+
|
18
|
+
get do
|
19
|
+
haml :stubs, {}, stubs: @memory_controller.find_stubs
|
20
|
+
end
|
21
|
+
|
22
|
+
delete do
|
23
|
+
@memory_controller.reset(logger)
|
24
|
+
halt 200, "OK"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
module Routes
|
5
|
+
|
6
|
+
module Resource
|
7
|
+
|
8
|
+
def self.included(application)
|
9
|
+
application.instance_eval do
|
10
|
+
|
11
|
+
get "/application.css" do
|
12
|
+
sass :application
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
module Routes
|
5
|
+
|
6
|
+
module Scenario
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super()
|
10
|
+
@scenario_controller = HttpStub::Server::Scenario::Controller.new(@server_memory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(application)
|
14
|
+
application.instance_eval do
|
15
|
+
|
16
|
+
namespace "/http_stub/scenarios" do
|
17
|
+
|
18
|
+
post do
|
19
|
+
response = @scenario_controller.register(http_stub_request, logger)
|
20
|
+
@response_pipeline.process(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
get do
|
24
|
+
pass unless http_stub_request.parameters[:name]
|
25
|
+
haml :scenario, {}, scenario: @scenario_controller.find(http_stub_request, logger)
|
26
|
+
end
|
27
|
+
|
28
|
+
get do
|
29
|
+
haml :scenarios, {}, scenarios: @scenario_controller.find_all
|
30
|
+
end
|
31
|
+
|
32
|
+
post "/activate" do
|
33
|
+
response = @scenario_controller.activate(http_stub_request, logger)
|
34
|
+
@response_pipeline.process(response)
|
35
|
+
end
|
36
|
+
|
37
|
+
delete do
|
38
|
+
@scenario_controller.clear(logger)
|
39
|
+
halt 200, "OK"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module HttpStub
|
2
|
+
module Server
|
3
|
+
module Application
|
4
|
+
module Routes
|
5
|
+
|
6
|
+
module Session
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super()
|
10
|
+
@session_controller = HttpStub::Server::Session::Controller.new(@session_configuration, @server_memory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(application)
|
14
|
+
application.instance_eval do
|
15
|
+
|
16
|
+
namespace "/http_stub" do
|
17
|
+
|
18
|
+
get do
|
19
|
+
redirect settings.session_identifier? ? "/http_stub/sessions" : "/http_stub/sessions/transactional"
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace "/sessions" do
|
23
|
+
|
24
|
+
get "/transactional" do
|
25
|
+
haml :transactional_session, {}, session: @session_controller.find_transactional(logger)
|
26
|
+
end
|
27
|
+
|
28
|
+
get do
|
29
|
+
pass unless http_stub_request.session_id
|
30
|
+
haml :session, {}, session: @session_controller.find(http_stub_request, logger)
|
31
|
+
end
|
32
|
+
|
33
|
+
get do
|
34
|
+
haml :sessions, {}, sessions: @session_controller.find_all
|
35
|
+
end
|
36
|
+
|
37
|
+
post "/default" do
|
38
|
+
@session_controller.mark_default(http_stub_request)
|
39
|
+
halt 200, "OK"
|
40
|
+
end
|
41
|
+
|
42
|
+
delete do
|
43
|
+
pass unless http_stub_request.session_id
|
44
|
+
@session_controller.delete(http_stub_request, logger)
|
45
|
+
halt 200, "OK"
|
46
|
+
end
|
47
|
+
|
48
|
+
delete do
|
49
|
+
@session_controller.clear(logger)
|
50
|
+
halt 200, "OK"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|