Class: ConfigurationService::Test::OrchestrationProvider
- Inherits:
-
Object
- Object
- ConfigurationService::Test::OrchestrationProvider
- Defined in:
- lib/configuration_service/test/orchestration_provider.rb
Overview
Abstract Orchestrator provider
Extend this class if you want your test orchestration provider to constrain your implementation’s interface to work as a configuration service provider. If you have no intention of plugging your implementation into ConfigurationService::Base, build your own test orchestration provider from scratch, using Orchestrator as a guide.
Extensions should implement:
-
#service_provider_id
-
#service_provider_configuration
-
#service_provider
-
#broken_service_provider
-
#token_for
-
#delete_configuration
Direct Known Subclasses
Constant Summary collapse
- ACTIVITY_ROLE_MAP =
-
:requesting_configurations -
:publishing_configurations -
:nothing(if possible, provide credentials that don’t allow operations on the configurationidentifier)
-
{ :requesting_configurations => :consumer, :publishing_configurations => :publisher, :nothing => :none }
- ROLES =
-
:consumer -
:publisher -
:none
-
ACTIVITY_ROLE_MAP.values
Instance Method Summary collapse
-
#authorize(role) ⇒ Object
See Orchestrator#authorize.
-
#deauthorize ⇒ Object
See Orchestrator#deauthorize.
-
#existing_configuration ⇒ Object
See Orchestrator#existing_configuration.
-
#existing_revision ⇒ Object
See Orchestrator#existing_revision.
-
#fail_next_request ⇒ Object
Arrange for the next publication or consuming operation to fail.
-
#given_existing_configuration ⇒ Object
See Orchestrator#given_existing_configuration.
-
#given_invalid_configuration ⇒ Object
See Orchestrator#given_invalid_configuration.
-
#given_metadata ⇒ Object
See Orchestrator#given_metadata.
-
#given_missing_configuration ⇒ Object
See Orchestrator#given_missing_configuration.
-
#initialize ⇒ OrchestrationProvider
constructor
Returns a new Orchestrator provider.
-
#publish_configuration ⇒ Object
Perform a publishing operation against the service under test.
-
#request_configuration ⇒ Object
Perform a consuming operation against the service under test.
-
#service_provider_configuration ⇒ Object
Return configuration for the service provider.
-
#service_provider_id ⇒ Object
Returns the string identifier of the service provider.
Constructor Details
#initialize ⇒ OrchestrationProvider
Returns a new Orchestrator provider
The provider is always initialized with the same configuration identifier
50 51 52 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 50 def initialize @identifier = "acme" end |
Instance Method Details
#authorize(role) ⇒ Object
See Orchestrator#authorize
77 78 79 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 77 def (role) @token = token_for(role) end |
#deauthorize ⇒ Object
See Orchestrator#deauthorize
84 85 86 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 84 def @token = nil end |
#existing_configuration ⇒ Object
See Orchestrator#existing_configuration
124 125 126 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 124 def existing_configuration @existing_configuration.data end |
#existing_revision ⇒ Object
See Orchestrator#existing_revision
131 132 133 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 131 def existing_revision @existing_configuration.revision end |
#fail_next_request ⇒ Object
Arrange for the next publication or consuming operation to fail
This is done by using a #broken_service_provider to service the next operation.
167 168 169 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 167 def fail_next_request @fail_next = true end |
#given_existing_configuration ⇒ Object
See Orchestrator#given_existing_configuration
98 99 100 101 102 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 98 def given_existing_configuration (:publisher) do @existing_configuration = publish_configuration end end |
#given_invalid_configuration ⇒ Object
See Orchestrator#given_invalid_configuration
107 108 109 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 107 def given_invalid_configuration @configuration = "This should be an object!" end |
#given_metadata ⇒ Object
See Orchestrator#given_metadata
91 92 93 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 91 def = {"version" => "1.0"} end |
#given_missing_configuration ⇒ Object
See Orchestrator#given_missing_configuration
114 115 116 117 118 119 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 114 def given_missing_configuration (:publisher) do delete_configuration @existing_configuration = nil end end |
#publish_configuration ⇒ Object
Perform a publishing operation against the service under test
The response from the service is wrapped in a test Response.
151 152 153 154 155 156 157 158 159 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 151 def publish_configuration wrap_response do if service.publish_configuration(configuration, ) else service.publish_configuration(configuration) end end end |
#request_configuration ⇒ Object
Perform a consuming operation against the service under test
The response from the service is wrapped in a test Response.
140 141 142 143 144 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 140 def request_configuration wrap_response do service.request_configuration end end |
#service_provider_configuration ⇒ Object
Return configuration for the service provider
The configuration should be a dictionary of keyword arguments that can be passed to the constructor of the service provider class.
70 71 72 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 70 def service_provider_configuration # :doc: raise NotImplementedError, "#{self.class} must implement service_provider_configuration" end |
#service_provider_id ⇒ Object
Returns the string identifier of the service provider
This should be the identifier with which the service provider registers into the ProviderRegistry.
60 61 62 |
# File 'lib/configuration_service/test/orchestration_provider.rb', line 60 def service_provider_id raise NotImplementedError, "#{self.class} must implement service_provider_id" end |