TEST_F(ActionTest, RegisterDup) { ib_status_t status; status = ib_action_register(ib_engine, "test_action", NULL, NULL, NULL, NULL, NULL, NULL); ASSERT_EQ(IB_OK, status); status = ib_action_register(ib_engine, "test_action", NULL, NULL, NULL, NULL, NULL, NULL); EXPECT_EQ(IB_EINVAL, status); }
TEST_F(ActionTest, ExecuteAction) { ib_status_t status; ib_action_inst_t *act; const char *params = "parameters"; status = ib_action_register(ib_engine, "test_action", create_fn, NULL, NULL, NULL, execute_fn, NULL); ASSERT_EQ(IB_OK, status); status = ib_action_inst_create(ib_engine, "test_action", "INVALID", &act); ASSERT_EQ(IB_EINVAL, status); status = ib_action_inst_create(ib_engine, "test_action", params, &act); ASSERT_EQ(IB_OK, status); action_executed = false; status = ib_action_execute(NULL, act); ASSERT_EQ(IB_OK, status); ASSERT_TRUE(action_executed); EXPECT_STREQ(action_str, params); }
IronBeeModifier::IronBeeModifier( const string& config_path, behavior_e behavior ) : m_state(make_shared<State>()) { m_state->behavior = behavior; m_state->server_value.get().ib()->err_fn = clipp_error; m_state->server_value.get().ib()->hdr_fn = clipp_header; ib_status_t rc = IB_OK; rc = ib_action_register( m_state->engine.ib(), "clipp", IB_ACT_FLAG_NONE, clipp_action_create, NULL, NULL, NULL, clipp_action_execute, reinterpret_cast<void*>(&m_state->current_action) ); if (rc != IB_OK) { throw runtime_error("Could not register clipp action."); } rc = ib_action_register( m_state->engine.ib(), "clipp_announce", IB_ACT_FLAG_NONE, clipp_announce_action_create, NULL, NULL, NULL, clipp_announce_action_execute, NULL ); if (rc != IB_OK) { throw runtime_error("Could not register clipp_announce action."); } load_configuration(m_state->engine, config_path); }
TEST_F(ActionTest, RegisterTest) { ib_status_t status; status = ib_action_register(ib_engine, "test_action", NULL, NULL, NULL, NULL, NULL, NULL); EXPECT_EQ(IB_OK, status); }
TEST_F(ActionTest, CallAction) { ib_status_t status; ib_action_inst_t *act; status = ib_action_register(ib_engine, "test_action", NULL, NULL, NULL, NULL, NULL, NULL); ASSERT_EQ(IB_OK, status); status = ib_action_inst_create(ib_engine, "test_action", "parameters", &act); ASSERT_EQ(IB_OK, status); status = ib_action_execute(NULL, act); ASSERT_EQ(IB_OK, status); }
ib_status_t ib_action_create_and_register( ib_action_t **action, ib_engine_t *ib, const char *name, ib_action_create_fn_t create_fn, void *create_cbdata, ib_action_destroy_fn_t destroy_fn, void *destroy_cbdata, ib_action_execute_fn_t execute_fn, void *execute_cbdata ) { assert(ib != NULL); assert(name != NULL); ib_action_t *local_action; ib_status_t rc; rc = ib_action_create( &local_action, ib_engine_mm_main_get(ib), name, create_fn, create_cbdata, destroy_fn, destroy_cbdata, execute_fn, execute_cbdata ); if (rc != IB_OK) { return rc; } rc = ib_action_register(ib, local_action); if (rc != IB_OK) { return rc; } if (action != NULL) { *action = local_action; } return IB_OK; }
void ConstAction::register_with(Engine engine) { throw_if_error(ib_action_register(engine.ib(), ib())); }