Asterisk - The Open Source Telephony Project GIT-master-b023714
Loading...
Searching...
No Matches
Functions | Variables
test_ari.c File Reference

Test ARI API.

Author
David M. Lee, II <dlee@digium.com> 
.
More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/ari.h"
Include dependency graph for test_ari.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
 AST_TEST_DEFINE (get_docs)
 
 AST_TEST_DEFINE (get_docs_hackerz)
 
 AST_TEST_DEFINE (get_docs_nohost)
 
 AST_TEST_DEFINE (get_docs_notfound)
 
 AST_TEST_DEFINE (invoke_bad_post)
 
 AST_TEST_DEFINE (invoke_delete)
 
 AST_TEST_DEFINE (invoke_get)
 
 AST_TEST_DEFINE (invoke_not_found)
 
 AST_TEST_DEFINE (invoke_post)
 
 AST_TEST_DEFINE (invoke_wildcard)
 
static int load_module (void)
 
static struct ast_ari_responseresponse_alloc (void)
 
static void response_free (struct ast_ari_response *resp)
 
static void * setup_invocation_test (void)
 
static void tear_down_invocation_test (void *ignore)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "ARI testing" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_ari", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct stasis_rest_handlers bam
 
static struct stasis_rest_handlers bang
 
static struct stasis_rest_handlers bar
 
static void handler (const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
 
#define HANDLER(name, response_code)
 
static int invocation_count
 
static struct stasis_rest_handlers test_root
 

Detailed Description

Test ARI API.

Author
David M. Lee, II <dlee@digium.com> 
.

Definition in file test_ari.c.

Macro Definition Documentation

◆ HANDLER

#define HANDLER (   name,
  response_code 
)

Definition at line 97 of file test_ari.c.

104 { \
105 handler(#name, response_code, get_params, path_vars, headers, body, response); \
106 }
static const char name[]
Definition format_mp3.c:68

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 578 of file test_ari.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 578 of file test_ari.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 578 of file test_ari.c.

◆ AST_TEST_DEFINE() [1/10]

AST_TEST_DEFINE ( get_docs  )

Definition at line 201 of file test_ari.c.

202{
203 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
204 RAII_VAR(struct ast_variable *, headers, NULL, ast_variables_destroy);
205 struct ast_json *basePathJson;
206 const char *basePath;
207
208 switch (cmd) {
209 case TEST_INIT:
210 info->name = __func__;
211 info->category = "/res/ari/";
212 info->summary = "Test simple API get.";
213 info->description = "Test ARI binding logic.";
214 return AST_TEST_NOT_RUN;
215 case TEST_EXECUTE:
216 break;
217 }
218
219 response = response_alloc();
220 headers = ast_variable_new("Host", "stasis.asterisk.org", __FILE__);
221 ast_ari_get_docs("resources.json", "", headers, response);
222 ast_test_validate(test, 200 == response->response_code);
223
224 /* basePath should be relative to the Host header */
225 basePathJson = ast_json_object_get(response->message, "basePath");
226 ast_test_validate(test, NULL != basePathJson);
227 basePath = ast_json_string_get(basePathJson);
228 ast_test_validate(test, 0 == strcmp("http://stasis.asterisk.org/ari", basePath));
229
230 return AST_TEST_PASS;
231}
void ast_ari_get_docs(const char *uri, const char *prefix, struct ast_variable *headers, struct ast_ari_response *response)
Definition res_ari.c:726
#define ast_variable_new(name, value, filename)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition extconf.c:1260
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Definition json.c:283
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
Definition json.c:407
#define NULL
Definition resample.c:96
Abstract JSON element (object, array, string, int, ...).
Structure for variables, used for configurations and for channel variables.
@ TEST_INIT
Definition test.h:200
@ TEST_EXECUTE
Definition test.h:201
@ AST_TEST_PASS
Definition test.h:195
@ AST_TEST_NOT_RUN
Definition test.h:194
static void response_free(struct ast_ari_response *resp)
Definition test_ari.c:167
static struct ast_ari_response * response_alloc(void)
Definition test_ari.c:156
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:978

References ast_ari_get_docs(), ast_json_object_get(), ast_json_string_get(), AST_TEST_NOT_RUN, AST_TEST_PASS, ast_variable_new, ast_variables_destroy(), ast_ari_response::headers, NULL, RAII_VAR, response_alloc(), response_free(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [2/10]

AST_TEST_DEFINE ( get_docs_hackerz  )

Definition at line 284 of file test_ari.c.

285{
286 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
287 struct ast_variable *headers = NULL;
288
289 switch (cmd) {
290 case TEST_INIT:
291 info->name = __func__;
292 info->category = "/res/ari/";
293 info->summary = "Test API get for a file outside the rest-api path";
294 info->description = "Test ARI binding logic.";
295 return AST_TEST_NOT_RUN;
296 case TEST_EXECUTE:
297 break;
298 }
299
300 response = response_alloc();
301 ast_ari_get_docs("../../../../sbin/asterisk", "", headers, response);
302 ast_test_validate(test, 404 == response->response_code);
303
304 return AST_TEST_PASS;
305}

References ast_ari_get_docs(), AST_TEST_NOT_RUN, AST_TEST_PASS, NULL, RAII_VAR, response_alloc(), response_free(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [3/10]

AST_TEST_DEFINE ( get_docs_nohost  )

Definition at line 233 of file test_ari.c.

234{
235 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
236 struct ast_variable *headers = NULL;
237 struct ast_json *basePathJson;
238
239 switch (cmd) {
240 case TEST_INIT:
241 info->name = __func__;
242 info->category = "/res/ari/";
243 info->summary = "Test API get without a Host header";
244 info->description = "Test ARI binding logic.";
245 return AST_TEST_NOT_RUN;
246 case TEST_EXECUTE:
247 break;
248 }
249
250 response = response_alloc();
251 ast_ari_get_docs("resources.json", "", headers, response);
252 ast_test_validate(test, 200 == response->response_code);
253
254 /* basePath should be relative to the Host header */
255 basePathJson = ast_json_object_get(response->message, "basePath");
256 ast_test_validate(test, NULL == basePathJson);
257
258 return AST_TEST_PASS;
259}

References ast_ari_get_docs(), ast_json_object_get(), AST_TEST_NOT_RUN, AST_TEST_PASS, NULL, RAII_VAR, response_alloc(), response_free(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [4/10]

AST_TEST_DEFINE ( get_docs_notfound  )

Definition at line 261 of file test_ari.c.

262{
263 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
264 struct ast_variable *headers = NULL;
265
266 switch (cmd) {
267 case TEST_INIT:
268 info->name = __func__;
269 info->category = "/res/ari/";
270 info->summary = "Test API get for invalid resource";
271 info->description = "Test ARI binding logic.";
272 return AST_TEST_NOT_RUN;
273 case TEST_EXECUTE:
274 break;
275 }
276
277 response = response_alloc();
278 ast_ari_get_docs("i-am-not-a-resource.json", "", headers, response);
279 ast_test_validate(test, 404 == response->response_code);
280
281 return AST_TEST_PASS;
282}

References ast_ari_get_docs(), AST_TEST_NOT_RUN, AST_TEST_PASS, NULL, RAII_VAR, response_alloc(), response_free(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [5/10]

AST_TEST_DEFINE ( invoke_bad_post  )

Definition at line 485 of file test_ari.c.

486{
487 RAII_VAR(void *, fixture, NULL, tear_down_invocation_test);
488 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
489 struct ast_variable *get_params = NULL;
490 struct ast_variable *headers = NULL;
491
492 switch (cmd) {
493 case TEST_INIT:
494 info->name = __func__;
495 info->category = "/res/ari/";
496 info->summary = "Test POST on a resource that doesn't support it.";
497 info->description = "Test ARI binding logic.";
498 return AST_TEST_NOT_RUN;
499 case TEST_EXECUTE:
500 break;
501 }
502
503 fixture = setup_invocation_test();
504 response = response_alloc();
505 ast_ari_invoke(NULL, ARI_INVOKE_SOURCE_TEST, NULL, "foo", AST_HTTP_POST, get_params, headers,
506 ast_json_null(), response);
507
508 ast_test_validate(test, 0 == invocation_count);
509 ast_test_validate(test, 405 == response->response_code);
510
511 return AST_TEST_PASS;
512}
@ ARI_INVOKE_SOURCE_TEST
Definition ari.h:150
enum ast_ari_invoke_result ast_ari_invoke(struct ast_tcptls_session_instance *ser, enum ast_ari_invoke_source source, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Definition res_ari.c:528
@ AST_HTTP_POST
Definition http.h:61
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition json.c:248
static void * setup_invocation_test(void)
Definition test_ari.c:181
static int invocation_count
Definition test_ari.c:53
static void tear_down_invocation_test(void *ignore)
Definition test_ari.c:193

References ARI_INVOKE_SOURCE_TEST, ast_ari_invoke(), AST_HTTP_POST, ast_json_null(), AST_TEST_NOT_RUN, AST_TEST_PASS, invocation_count, NULL, RAII_VAR, response_alloc(), response_free(), setup_invocation_test(), tear_down_invocation_test(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [6/10]

AST_TEST_DEFINE ( invoke_delete  )

Definition at line 396 of file test_ari.c.

397{
398 RAII_VAR(void *, fixture, NULL, tear_down_invocation_test);
399 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
400 RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
401 struct ast_variable *get_params = NULL;
402 struct ast_variable *headers = NULL;
403
404 switch (cmd) {
405 case TEST_INIT:
406 info->name = __func__;
407 info->category = "/res/ari/";
408 info->summary = "Test DELETE of an HTTP resource.";
409 info->description = "Test ARI binding logic.";
410 return AST_TEST_NOT_RUN;
411 case TEST_EXECUTE:
412 break;
413 }
414
415 fixture = setup_invocation_test();
416 response = response_alloc();
417 expected = ast_json_pack("{s: s, s: {}, s: {}, s: {s: s}}",
418 "name", "bang_delete",
419 "get_params",
420 "headers",
421 "path_vars",
422 "bam", "foshizzle");
423
424 ast_ari_invoke(NULL, ARI_INVOKE_SOURCE_TEST, NULL, "foo/foshizzle/bang", AST_HTTP_DELETE, get_params, headers,
425 ast_json_null(), response);
426
427 ast_test_validate(test, 1 == invocation_count);
428 ast_test_validate(test, 204 == response->response_code);
429 ast_test_validate(test, ast_json_equal(expected, response->message));
430
431 return AST_TEST_PASS;
432}
@ AST_HTTP_DELETE
Definition http.h:64
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition json.c:73
int ast_json_equal(const struct ast_json *lhs, const struct ast_json *rhs)
Compare two JSON objects.
Definition json.c:357
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition json.c:612

References ARI_INVOKE_SOURCE_TEST, ast_ari_invoke(), AST_HTTP_DELETE, ast_json_equal(), ast_json_null(), ast_json_pack(), ast_json_unref(), AST_TEST_NOT_RUN, AST_TEST_PASS, invocation_count, NULL, RAII_VAR, response_alloc(), response_free(), setup_invocation_test(), tear_down_invocation_test(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [7/10]

AST_TEST_DEFINE ( invoke_get  )

Definition at line 307 of file test_ari.c.

308{
309 RAII_VAR(void *, fixture, NULL, tear_down_invocation_test);
310 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
311 RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
312 struct ast_variable *get_params = NULL;
313 struct ast_variable *headers = NULL;
314
315 switch (cmd) {
316 case TEST_INIT:
317 info->name = __func__;
318 info->category = "/res/ari/";
319 info->summary = "Test simple GET of an HTTP resource.";
320 info->description = "Test ARI binding logic.";
321 return AST_TEST_NOT_RUN;
322 case TEST_EXECUTE:
323 break;
324 }
325
326 fixture = setup_invocation_test();
327 response = response_alloc();
328 get_params = ast_variable_new("get1", "get-one", __FILE__);
329 ast_assert(get_params != NULL);
330 get_params->next = ast_variable_new("get2", "get-two", __FILE__);
331 ast_assert(get_params->next != NULL);
332
333 headers = ast_variable_new("head1", "head-one", __FILE__);
334 ast_assert(headers != NULL);
335 headers->next = ast_variable_new("head2", "head-two", __FILE__);
336 ast_assert(headers->next != NULL);
337
338 expected = ast_json_pack("{s: s, s: {s: s, s: s}, s: {s: s, s: s}, s: {}}",
339 "name", "foo_get",
340 "get_params",
341 "get1", "get-one",
342 "get2", "get-two",
343 "headers",
344 "head1", "head-one",
345 "head2", "head-two",
346 "path_vars");
347
348 ast_ari_invoke(NULL, ARI_INVOKE_SOURCE_TEST, NULL, "foo", AST_HTTP_GET, get_params, headers,
349 ast_json_null(), response);
350
351 ast_test_validate(test, 1 == invocation_count);
352 ast_test_validate(test, 200 == response->response_code);
353 ast_test_validate(test, ast_json_equal(expected, response->message));
354
355 return AST_TEST_PASS;
356}
@ AST_HTTP_GET
Definition http.h:60
struct ast_variable * next
#define ast_assert(a)
Definition utils.h:776

References ARI_INVOKE_SOURCE_TEST, ast_ari_invoke(), ast_assert, AST_HTTP_GET, ast_json_equal(), ast_json_null(), ast_json_pack(), ast_json_unref(), AST_TEST_NOT_RUN, AST_TEST_PASS, ast_variable_new, invocation_count, ast_variable::next, NULL, RAII_VAR, response_alloc(), response_free(), setup_invocation_test(), tear_down_invocation_test(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [8/10]

AST_TEST_DEFINE ( invoke_not_found  )

Definition at line 514 of file test_ari.c.

515{
516 RAII_VAR(void *, fixture, NULL, tear_down_invocation_test);
517 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
518 struct ast_variable *get_params = NULL;
519 struct ast_variable *headers = NULL;
520
521 switch (cmd) {
522 case TEST_INIT:
523 info->name = __func__;
524 info->category = "/res/ari/";
525 info->summary = "Test GET on a resource that does not exist.";
526 info->description = "Test ARI binding logic.";
527 return AST_TEST_NOT_RUN;
528 case TEST_EXECUTE:
529 break;
530 }
531
532 fixture = setup_invocation_test();
533 response = response_alloc();
534 ast_ari_invoke(NULL, ARI_INVOKE_SOURCE_TEST, NULL, "foo/fizzle/i-am-not-a-resource", AST_HTTP_GET, get_params, headers,
535 ast_json_null(), response);
536
537 ast_test_validate(test, 0 == invocation_count);
538 ast_test_validate(test, 404 == response->response_code);
539
540 return AST_TEST_PASS;
541}

References ARI_INVOKE_SOURCE_TEST, ast_ari_invoke(), AST_HTTP_GET, ast_json_null(), AST_TEST_NOT_RUN, AST_TEST_PASS, invocation_count, NULL, RAII_VAR, response_alloc(), response_free(), setup_invocation_test(), tear_down_invocation_test(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [9/10]

AST_TEST_DEFINE ( invoke_post  )

Definition at line 434 of file test_ari.c.

435{
436 RAII_VAR(void *, fixture, NULL, tear_down_invocation_test);
437 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
438 RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
439 struct ast_variable *get_params = NULL;
440 struct ast_variable *headers = NULL;
441
442 switch (cmd) {
443 case TEST_INIT:
444 info->name = __func__;
445 info->category = "/res/ari/";
446 info->summary = "Test POST of an HTTP resource.";
447 info->description = "Test ARI binding logic.";
448 return AST_TEST_NOT_RUN;
449 case TEST_EXECUTE:
450 break;
451 }
452
453 fixture = setup_invocation_test();
454 response = response_alloc();
455 get_params = ast_variable_new("get1", "get-one", __FILE__);
456 ast_assert(get_params != NULL);
457 get_params->next = ast_variable_new("get2", "get-two", __FILE__);
458 ast_assert(get_params->next != NULL);
459
460 headers = ast_variable_new("head1", "head-one", __FILE__);
461 ast_assert(headers != NULL);
462 headers->next = ast_variable_new("head2", "head-two", __FILE__);
463 ast_assert(headers->next != NULL);
464
465 expected = ast_json_pack("{s: s, s: {s: s, s: s}, s: {s: s, s: s}, s: {}}",
466 "name", "bar_post",
467 "get_params",
468 "get1", "get-one",
469 "get2", "get-two",
470 "headers",
471 "head1", "head-one",
472 "head2", "head-two",
473 "path_vars");
474
475 ast_ari_invoke(NULL, ARI_INVOKE_SOURCE_TEST, NULL, "foo/bar", AST_HTTP_POST, get_params, headers,
476 ast_json_null(), response);
477
478 ast_test_validate(test, 1 == invocation_count);
479 ast_test_validate(test, 200 == response->response_code);
480 ast_test_validate(test, ast_json_equal(expected, response->message));
481
482 return AST_TEST_PASS;
483}

References ARI_INVOKE_SOURCE_TEST, ast_ari_invoke(), ast_assert, AST_HTTP_POST, ast_json_equal(), ast_json_null(), ast_json_pack(), ast_json_unref(), AST_TEST_NOT_RUN, AST_TEST_PASS, ast_variable_new, invocation_count, ast_variable::next, NULL, RAII_VAR, response_alloc(), response_free(), setup_invocation_test(), tear_down_invocation_test(), TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [10/10]

AST_TEST_DEFINE ( invoke_wildcard  )

Definition at line 358 of file test_ari.c.

359{
360 RAII_VAR(void *, fixture, NULL, tear_down_invocation_test);
361 RAII_VAR(struct ast_ari_response *, response, NULL, response_free);
362 RAII_VAR(struct ast_json *, expected, NULL, ast_json_unref);
363 struct ast_variable *get_params = NULL;
364 struct ast_variable *headers = NULL;
365
366 switch (cmd) {
367 case TEST_INIT:
368 info->name = __func__;
369 info->category = "/res/ari/";
370 info->summary = "Test GET of a wildcard resource.";
371 info->description = "Test ARI binding logic.";
372 return AST_TEST_NOT_RUN;
373 case TEST_EXECUTE:
374 break;
375 }
376
377 fixture = setup_invocation_test();
378 response = response_alloc();
379 expected = ast_json_pack("{s: s, s: {}, s: {}, s: {s: s}}",
380 "name", "bam_get",
381 "get_params",
382 "headers",
383 "path_vars",
384 "bam", "foshizzle");
385
386 ast_ari_invoke(NULL, ARI_INVOKE_SOURCE_TEST, NULL, "foo/foshizzle", AST_HTTP_GET, get_params, headers,
387 ast_json_null(), response);
388
389 ast_test_validate(test, 1 == invocation_count);
390 ast_test_validate(test, 200 == response->response_code);
391 ast_test_validate(test, ast_json_equal(expected, response->message));
392
393 return AST_TEST_PASS;
394}

References ARI_INVOKE_SOURCE_TEST, ast_ari_invoke(), AST_HTTP_GET, ast_json_equal(), ast_json_null(), ast_json_pack(), ast_json_unref(), AST_TEST_NOT_RUN, AST_TEST_PASS, invocation_count, NULL, RAII_VAR, response_alloc(), response_free(), setup_invocation_test(), tear_down_invocation_test(), TEST_EXECUTE, and TEST_INIT.

◆ handler()

static void handler ( const char *  name,
int  response_code,
struct ast_variable get_params,
struct ast_variable path_vars,
struct ast_variable headers,
struct ast_json body,
struct ast_ari_response response 
)
static

Definition at line 59 of file test_ari.c.

66{
67 struct ast_json *message = ast_json_pack("{s: s, s: {}, s: {}, s: {}}",
68 "name", name,
69 "get_params",
70 "path_vars",
71 "headers");
72 struct ast_json *get_params_obj = ast_json_object_get(message, "get_params");
73 struct ast_json *path_vars_obj = ast_json_object_get(message, "path_vars");
74 struct ast_json *headers_obj = ast_json_object_get(message, "headers");
75
76 for (; get_params != NULL; get_params = get_params->next) {
77 ast_json_object_set(get_params_obj, get_params->name, ast_json_string_create(get_params->value));
78 }
79
80 for (; path_vars != NULL; path_vars = path_vars->next) {
81 ast_json_object_set(path_vars_obj, path_vars->name, ast_json_string_create(path_vars->value));
82 }
83
84 for (; headers != NULL; headers = headers->next) {
85 ast_json_object_set(headers_obj, headers->name, ast_json_string_create(headers->value));
86 }
87
89 response->response_code = response_code;
90 response->message = message;
91}
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition json.c:278
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition json.c:414
struct ast_json * message
Definition ari.h:103
int response_code
Definition ari.h:108

References ast_json_object_get(), ast_json_object_set(), ast_json_pack(), ast_json_string_create(), invocation_count, ast_ari_response::message, name, ast_variable::name, ast_variable::next, NULL, ast_ari_response::response_code, and ast_variable::value.

Referenced by __aco_option_register(), __stasis_app_register(), add_allow_header(), add_sdp_streams(), allocate_subscription(), app_create(), app_handle_subscriptions(), app_send(), app_update(), ast_ari_add_handler(), ast_ari_invoke(), ast_ari_remove_handler(), ast_msg_handler_register(), ast_msg_handler_unregister(), ast_msg_has_destination(), ast_mwi_state_callback_all(), ast_mwi_state_callback_subscribed(), ast_pbx_hangup_handler_push(), ast_sip_create_subscription(), ast_sip_register_event_publisher_handler(), ast_sip_register_publish_handler(), ast_sip_register_subscription_handler(), ast_sip_session_register_sdp_handler(), ast_sip_session_unregister_sdp_handler(), ast_sip_unregister_event_publisher_handler(), ast_sip_unregister_publish_handler(), ast_sip_unregister_subscription_handler(), build_node_children(), build_resource_tree(), channel_hangup_handler_cb(), create_subscription_tree(), create_virtual_subscriptions(), handle_conf_user_join(), handle_conf_user_leave(), handle_debug_or_trace(), handle_incoming_sdp(), handle_negotiated_sdp_session_media(), handle_options(), handle_stasis_state(), msg_q_cb(), publish_add_handler(), publish_hangup_handler_message(), publish_request_initial(), pubsub_on_rx_publish_request(), pubsub_on_rx_subscribe_request(), remove_handler(), root_handler_create(), sdp_requires_deferral(), session_media_set_handler(), session_outgoing_nat_hook(), sip_outbound_publish_synchronize(), stasis_app_register(), stasis_app_register_all(), stasis_state_callback_all(), stasis_state_callback_subscribed(), status_debug_verbose(), stop_publishing(), stream_destroy(), sub_add_handler(), sub_add_handler(), sub_persistence_recreate(), subscription_get_generator_from_rdata(), subscription_get_handler_from_rdata(), and xmpp_action_hook().

◆ load_module()

static int load_module ( void  )
static

Definition at line 558 of file test_ari.c.

559{
560 AST_TEST_REGISTER(get_docs);
561 AST_TEST_REGISTER(get_docs_nohost);
562 AST_TEST_REGISTER(get_docs_notfound);
563 AST_TEST_REGISTER(get_docs_hackerz);
564 AST_TEST_REGISTER(invoke_get);
565 AST_TEST_REGISTER(invoke_wildcard);
566 AST_TEST_REGISTER(invoke_delete);
567 AST_TEST_REGISTER(invoke_post);
568 AST_TEST_REGISTER(invoke_bad_post);
569 AST_TEST_REGISTER(invoke_not_found);
571}
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
#define AST_TEST_REGISTER(cb)
Definition test.h:127

References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.

◆ response_alloc()

static struct ast_ari_response * response_alloc ( void  )
static

Definition at line 156 of file test_ari.c.

157{
158 struct ast_ari_response *resp = ast_calloc(1, sizeof(struct ast_ari_response));
159 resp->headers = ast_str_create(24);
160 return resp;
161}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659
struct ast_str * headers
Definition ari.h:105

References ast_calloc, ast_str_create, and ast_ari_response::headers.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ response_free()

static void response_free ( struct ast_ari_response resp)
static

◆ setup_invocation_test()

static void * setup_invocation_test ( void  )
static

\ internal Setup test fixture for invocation tests.

Definition at line 181 of file test_ari.c.

181 {
182 int r;
185 ast_assert(r == 0);
186 return &invocation_count;
187}
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
Definition res_ari.c:132
static struct stasis_rest_handlers test_root
Definition test_ari.c:142

References ast_ari_add_handler(), ast_assert, invocation_count, and test_root.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ tear_down_invocation_test()

static void tear_down_invocation_test ( void *  ignore)
static

\ internal Tear down test fixture for invocation tests.

Definition at line 193 of file test_ari.c.

193 {
194 if (!ignore) {
195 return;
196 }
198}
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
Definition res_ari.c:155

References ast_ari_remove_handler(), and test_root.

Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 543 of file test_ari.c.

544{
545 AST_TEST_UNREGISTER(get_docs);
546 AST_TEST_UNREGISTER(get_docs_nohost);
547 AST_TEST_UNREGISTER(get_docs_notfound);
548 AST_TEST_UNREGISTER(get_docs_hackerz);
549 AST_TEST_UNREGISTER(invoke_get);
550 AST_TEST_UNREGISTER(invoke_wildcard);
551 AST_TEST_UNREGISTER(invoke_delete);
552 AST_TEST_UNREGISTER(invoke_post);
553 AST_TEST_UNREGISTER(invoke_bad_post);
554 AST_TEST_UNREGISTER(invoke_not_found);
555 return 0;
556}
#define AST_TEST_UNREGISTER(cb)
Definition test.h:128

References AST_TEST_UNREGISTER.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "ARI testing" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_ari", }
static

Definition at line 578 of file test_ari.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 578 of file test_ari.c.

◆ bam

struct stasis_rest_handlers bam
static

Definition at line 133 of file test_ari.c.

133 {
134 .path_segment = "bam",
135 .is_wildcard = 1,
136 .callbacks = {
137 [AST_HTTP_GET] = bam_get,
138 },
139 .num_children = 1,
140 .children = { &bang }
141};
static struct stasis_rest_handlers bang
Definition test_ari.c:116

◆ bang

struct stasis_rest_handlers bang
static

Definition at line 116 of file test_ari.c.

116 {
117 .path_segment = "bang",
118 .callbacks = {
119 [AST_HTTP_GET] = bang_get,
120 [AST_HTTP_POST] = bang_post,
121 [AST_HTTP_DELETE] = bang_delete,
122 },
123 .num_children = 0
124};

◆ bar

struct stasis_rest_handlers bar
static

Definition at line 125 of file test_ari.c.

125 {
126 .path_segment = "bar",
127 .callbacks = {
128 [AST_HTTP_GET] = bar_get,
129 [AST_HTTP_POST] = bar_post,
130 },
131 .num_children = 0
132};

◆ invocation_count

int invocation_count
static

◆ test_root

struct stasis_rest_handlers test_root
static

Definition at line 142 of file test_ari.c.

142 {
143 .path_segment = "foo",
144 .callbacks = {
145 [AST_HTTP_GET] = foo_get,
146 },
147 .num_children = 3,
148 .children = { &bar, &bam, &bang }
149};
static struct stasis_rest_handlers bar
Definition test_ari.c:125
static struct stasis_rest_handlers bam
Definition test_ari.c:133

Referenced by setup_invocation_test(), and tear_down_invocation_test().