Esempio n. 1
0
    def test_get_within_project_id(self):
        # Create an adhoc action for the purpose of the test.
        adhoc_actions.create_actions(ADHOC_ACTION_YAML)

        # We should not be able to change 'project_id' even with a
        # direct DB call.
        db_api.update_action_definition(
            'my_action',
            {'project_id': 'foobar'}
        )

        resp = self.app.get('/v2/actions/my_action')

        self.assertEqual(200, resp.status_int)
        self.assertEqual('<default-project>', resp.json['project_id'])
Esempio n. 2
0
    def test_put_system(self):
        # Create an adhoc action for the purpose of the test.
        adhoc_actions.create_actions(ADHOC_ACTION_YAML)

        db_api.update_action_definition('my_action', {'is_system': True})

        resp = self.app.put(
            '/v2/actions',
            ADHOC_ACTION_YAML,
            headers={'Content-Type': 'text/plain'},
            expect_errors=True
        )

        self.assertEqual(400, resp.status_int)
        self.assertIn(
            'Attempt to modify a system action: my_action',
            resp.body.decode()
        )
Esempio n. 3
0
def update_action(action_spec, definition, scope, identifier=None):
    action = db_api.load_action_definition(action_spec.get_name())

    if action and action.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system action: %s" % action.name)

    values = _get_action_values(action_spec, definition, scope)

    return db_api.update_action_definition(
        identifier if identifier else values['name'], values)
Esempio n. 4
0
def update_action(action_spec, definition, scope):
    action = db_api.load_action_definition(action_spec.get_name())

    if action and action.is_system:
        raise exc.InvalidActionException(
            "Attempt to modify a system action: %s" %
            action.name
        )

    values = _get_action_values(action_spec, definition, scope)

    return db_api.update_action_definition(values['name'], values)