RoboHydra Class
Dispatches the incoming requests. Normally there is only one of this per server, but there can be several if summoners are used.
Constructor
RoboHydra
-
extraVars
Parameters:
-
extraVars
ObjectAn optional object with the extra configuration variables. These take precedence over any other configuration variables elsewhere, and are the values passed as command-line parameters in the "robohydra" executable.
Methods
attachHead
-
pluginName
-
headName
Attach the given head.
Parameters:
-
pluginName
StringThe name of the plugin containing the head to (re-)attach.
-
headName
StringThe name of the head to (re-)attach.
detachHead
-
pluginName
-
headName
Detach the given head.
Parameters:
-
pluginName
StringThe name of the plugin containing the head to detach.
-
headName
StringThe name of the head to detach.
getModulesObject
-
conf
Returns an object with the modules for a given plugin.
Parameters:
-
conf
ObjectThe full, resolved configuration for the plugin the module object is for.
Returns:
Object with the names of the available modules as keys, and objects with functions as values.
getPlugin
-
pluginName
Returns a plugin given its name.
Parameters:
-
pluginName
StringThe name of the plugin
Returns:
The plugin with the given name
getPluginNames
()
Array
Returns the names of the current plugins, including pseudo-plugins.
Returns:
An array with the names of the plugins in the hydra.
getPlugins
()
Array
Returns a list of all current plugins, including pseudo-plugins.
Returns:
An array containing all plugins in the hydra.
headForPath
-
req
-
afterHead
Returns the first head that matches a given URL.
Parameters:
-
req
RequestRequest object the head must match
-
afterHead
RoboHydraHeadIf given, only heads after the given one will be considered for matching.
Returns:
First head matching the given URL.
registerDynamicHead
-
head
-
opts
Adds a new (dynamic) head into a hydra. The new head is added at the beginning of the appropriate pseudo-plugin ("admin-dynamic", "priority-dynamic", or "dynamic", if the priority given is "admin", "high", or "normal"). The order of the plugins is: "admin-dynamic", special admin plugin (which is normally not visible in the admin interface!), "priority-dynamic", "dynamic", "current-scenario", and regular plugins.
Parameters:
-
head
RoboHydraHeadThe head to add
-
opts
ObjectOptions
-
priority
StringThe priority of the head. Can be "normal", "high", or "admin".
-
registerPluginObject
-
pluginObject
Register the given plugin object at the end of the hydra.
Parameters:
-
pluginObject
Object-
name
StringThe name of the plugin. Must be exclusively comprised of ASCII letters, numbers, underscores and dashes. Mandatory.
-
path
StringThe path to the plugin directory. Mandatory.
-
config
ObjectAn object with the plugin-specific configuration. Optional.
-
module
ObjectThe plugin module itself (ie. an object with the "getBodyParts" function).
-
startScenario
-
pluginName
-
scenarioName
Start the given scenario.
Parameters:
-
pluginName
StringThe name of the plugin containing the scenario to start.
-
scenarioName
StringThe name of the scenario to start.
stopScenario
-
pluginName
-
scenarioName
Stop the given scenario.
Parameters:
-
pluginName
StringThe name of the plugin containing the scenario to stop.
-
scenarioName
StringThe name of the scenario to stop.
Properties
currentScenario
Object
The currently active scenario, if any. It's an object with the keys "plugin" and "scenario". If there’s no active scenario, it’s "*default*" / "*default*".
scenarioResults
Object
deprecated
Deprecated alias for testResults, please use testResults instead.
testResults
Object
Current test (assertion) results. Its keys are plugin names and its values are objects with scenario names as keys. The values of the latter objects are test results: objects with the keys "result" (value is undefined if the test doesn’t have any result yet, or the strings "pass" or "fail" if at least one assertion has run for that test), "passes" (an array with the description of the passing assertions) and "failures" (ditto for failing assertions). Assertion results obtained outside of a scenario are stored under the plugin name "*default*" and the scenario name "*default*".