Exemplo n.º 1
0
    def test_leading_trailing_slashes(self):
        # Ideally the test should setup fixtures in DB. However, the triggerwatcher
        # that is supposed to load the models from DB does not real start given
        # eventlets etc.
        # Therefore this test is somewhat special and does not post directly.
        # This only check performed here is that even if a trigger was infact created with
        # the url containing all kinds of slashes the normalized version still work.
        # The part which does not get tested is integration with pecan since # that will
        # require hacking into the test app and force dependency on pecan internals.
        # TLDR; sorry for the ghetto test. Not sure how else to test this as a unit test.
        def get_webhook_trigger(name, url):
            trigger = TriggerDB(name=name, pack='test')
            trigger.type = list(WEBHOOK_TRIGGER_TYPES.keys())[0]
            trigger.parameters = {'url': url}
            return trigger

        test_triggers = [
            get_webhook_trigger('no_slash', 'no_slash'),
            get_webhook_trigger('with_leading_slash', '/with_leading_slash'),
            get_webhook_trigger('with_trailing_slash', '/with_trailing_slash/'),
            get_webhook_trigger('with_leading_trailing_slash', '/with_leading_trailing_slash/'),
            get_webhook_trigger('with_mixed_slash', '/with/mixed/slash/')
        ]

        controller = WebhooksController()
        for trigger in test_triggers:
            controller.add_trigger(trigger)

        self.assertTrue(controller._is_valid_hook('no_slash'))
        self.assertFalse(controller._is_valid_hook('/no_slash'))
        self.assertTrue(controller._is_valid_hook('with_leading_slash'))
        self.assertTrue(controller._is_valid_hook('with_trailing_slash'))
        self.assertTrue(controller._is_valid_hook('with_leading_trailing_slash'))
        self.assertTrue(controller._is_valid_hook('with/mixed/slash'))
Exemplo n.º 2
0
    def test_leading_trailing_slashes(self):
        # Ideally the test should setup fixtures in DB. However, the triggerwatcher
        # that is supposed to load the models from DB does not real start given
        # eventlets etc.
        # Therefore this test is somewhat special and does not post directly.
        # This only check performed here is that even if a trigger was infact created with
        # the url containing all kinds of slashes the normalized version still work.
        # The part which does not get tested is integration with pecan since # that will
        # require hacking into the test app and force dependency on pecan internals.
        # TLDR; sorry for the ghetto test. Not sure how else to test this as a unit test.
        def get_webhook_trigger(name, url):
            trigger = TriggerDB(name=name, pack='test')
            trigger.type = WEBHOOK_TRIGGER_TYPES.keys()[0]
            trigger.parameters = {'url': url}
            return trigger

        test_triggers = [
            get_webhook_trigger('no_slash', 'no_slash'),
            get_webhook_trigger('with_leading_slash', '/with_leading_slash'),
            get_webhook_trigger('with_trailing_slash', '/with_trailing_slash/'),
            get_webhook_trigger('with_leading_trailing_slash', '/with_leading_trailing_slash/'),
            get_webhook_trigger('with_mixed_slash', '/with/mixed/slash/')
        ]

        controller = WebhooksController()
        for trigger in test_triggers:
            controller.add_trigger(trigger)

        self.assertTrue(controller._is_valid_hook('no_slash'))
        self.assertFalse(controller._is_valid_hook('/no_slash'))
        self.assertTrue(controller._is_valid_hook('with_leading_slash'))
        self.assertTrue(controller._is_valid_hook('with_trailing_slash'))
        self.assertTrue(controller._is_valid_hook('with_leading_trailing_slash'))
        self.assertTrue(controller._is_valid_hook('with/mixed/slash'))
Exemplo n.º 3
0
class RootController(object):
    # Pack related controllers
    packs = PacksController()
    config_schemas = PackConfigSchemasController()
    configs = PackConfigsController()

    actions = ActionsController()
    actionexecutions = ActionExecutionsController()
    executions = actionexecutions  # We should deprecate actionexecutions.
    policies = PolicyController()
    policytypes = PolicyTypeController()
    runnertypes = RunnerTypesController()
    sensortypes = SensorTypeController()
    triggertypes = TriggerTypeController()
    triggers = TriggerController()
    triggerinstances = TriggerInstanceController()
    ruletypes = RuleTypesController()
    rules = RuleController()
    ruleenforcements = RuleEnforcementController()
    keys = KeyValuePairController()
    webhooks = WebhooksController()
    actionalias = ActionAliasController()
    aliasexecution = ActionAliasExecutionController()
    traces = TracesController()
    rbac = RBACController()
    apikeys = ApiKeyController()
    timers = TimersController()
Exemplo n.º 4
0
class RootController(object):
    actions = ActionsController()
    actionexecutions = ActionExecutionsController()
    executions = actionexecutions  # We should deprecate actionexecutions.
    runnertypes = RunnerTypesController()
    sensortypes = SensorTypeController()
    triggertypes = TriggerTypeController()
    triggers = TriggerController()
    triggerinstances = TriggerInstanceController()
    rules = RuleController()
    keys = KeyValuePairController()
    webhooks = WebhooksController()
    stream = StreamController()
Exemplo n.º 5
0
Arquivo: root.py Projeto: miqui/st2
class RootController(object):
    actions = ActionsController()
    actionexecutions = ActionExecutionsController()
    runnertypes = RunnerTypesController()
    sensortypes = SensorTypeController()
    triggertypes = TriggerTypeController()
    triggers = TriggerController()
    triggerinstances = TriggerInstanceController()
    rules = RuleController()
    keys = KeyValuePairController()
    history = HistoryController()
    webhooks = WebhooksController()
    stream = StreamController()

    @expose(generic=True, template='index.html')
    def index(self):
        return dict()
Exemplo n.º 6
0
Arquivo: root.py Projeto: joshgre/st2
class RootController(object):
    packs = PacksController()
    actions = ActionsController()
    actionexecutions = ActionExecutionsController()
    executions = actionexecutions  # We should deprecate actionexecutions.
    policies = PolicyController()
    policytypes = PolicyTypeController()
    runnertypes = RunnerTypesController()
    sensortypes = SensorTypeController()
    triggertypes = TriggerTypeController()
    triggers = TriggerController()
    triggerinstances = TriggerInstanceController()
    rules = RuleController()
    keys = KeyValuePairController()
    webhooks = WebhooksController()
    stream = StreamController()
    actionalias = ActionAliasController()
    aliasexecution = ActionAliasExecutionController()