summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-01-19 08:05:36 -0700
committerGeorge Joseph <gjoseph@digium.com>2017-01-24 10:48:41 -0700
commit17f4989d49c7117684c04bff8a3e6fed1c6e6aad (patch)
tree5436f731a73646821429231d51038bbb9bde7ce8 /tests
parent48178e5918967337624a7e43ff1d84a7bb63fa85 (diff)
ari: Implement 'debug all' and request/response logging
The 'ari set debug' command has been enhanced to accept 'all' as an application name. This allows dumping of all apps even if an app hasn't registered yet. To accomplish this, a new global_debug global variable was added to res/stasis/app.c and new APIs were added to set and query the value. 'ari set debug' now displays requests and responses as well as events. This required refactoring the existing debug code. * The implementation for 'ari set debug' was moved from stasis/cli.{c,h} to ari/cli.{c,h}, and stasis/cli.{c,h} were deleted. * In order to print the body of incoming requests even if a request failed, the consumption of the body was moved from the ari stubs to ast_ari_callback in res_ari.c and the moustache templates were then regenerated. The body is now passed to ast_ari_invoke and then on to the handlers. This results in code savings since that template was inserted multiple times into all the stubs. An additional change was made to the ao2_str_container implementation to add partial key searching and a sort function. The existing cli code assumed it was already there when it wasn't so the tab completion was never working. Change-Id: Ief936f747ce47f1fb14035fbe61152cf766406bf
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ari.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/test_ari.c b/tests/test_ari.c
index a61a1182d..e2c36fb38 100644
--- a/tests/test_ari.c
+++ b/tests/test_ari.c
@@ -62,6 +62,7 @@ static void handler(const char *name,
struct ast_variable *get_params,
struct ast_variable *path_vars,
struct ast_variable *headers,
+ struct ast_json *body,
struct ast_ari_response *response)
{
struct ast_json *message = ast_json_pack("{s: s, s: {}, s: {}, s: {}}",
@@ -99,9 +100,10 @@ static void handler(const char *name,
struct ast_variable *get_params, \
struct ast_variable *path_vars, \
struct ast_variable *headers, \
+ struct ast_json *body, \
struct ast_ari_response *response) \
{ \
- handler(#name, response_code, get_params, path_vars, headers, response); \
+ handler(#name, response_code, get_params, path_vars, headers, body, response); \
}
HANDLER(bang_get, 200)
@@ -344,7 +346,8 @@ AST_TEST_DEFINE(invoke_get)
"head2", "head-two",
"path_vars");
- ast_ari_invoke(NULL, "foo", AST_HTTP_GET, get_params, headers, response);
+ ast_ari_invoke(NULL, "foo", AST_HTTP_GET, get_params, headers,
+ ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 200 == response->response_code);
@@ -381,7 +384,8 @@ AST_TEST_DEFINE(invoke_wildcard)
"path_vars",
"bam", "foshizzle");
- ast_ari_invoke(NULL, "foo/foshizzle", AST_HTTP_GET, get_params, headers, response);
+ ast_ari_invoke(NULL, "foo/foshizzle", AST_HTTP_GET, get_params, headers,
+ ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 200 == response->response_code);
@@ -418,7 +422,8 @@ AST_TEST_DEFINE(invoke_delete)
"path_vars",
"bam", "foshizzle");
- ast_ari_invoke(NULL, "foo/foshizzle/bang", AST_HTTP_DELETE, get_params, headers, response);
+ ast_ari_invoke(NULL, "foo/foshizzle/bang", AST_HTTP_DELETE, get_params, headers,
+ ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 204 == response->response_code);
@@ -468,7 +473,8 @@ AST_TEST_DEFINE(invoke_post)
"head2", "head-two",
"path_vars");
- ast_ari_invoke(NULL, "foo/bar", AST_HTTP_POST, get_params, headers, response);
+ ast_ari_invoke(NULL, "foo/bar", AST_HTTP_POST, get_params, headers,
+ ast_json_null(), response);
ast_test_validate(test, 1 == invocation_count);
ast_test_validate(test, 200 == response->response_code);
@@ -497,7 +503,8 @@ AST_TEST_DEFINE(invoke_bad_post)
fixture = setup_invocation_test();
response = response_alloc();
- ast_ari_invoke(NULL, "foo", AST_HTTP_POST, get_params, headers, response);
+ ast_ari_invoke(NULL, "foo", AST_HTTP_POST, get_params, headers,
+ ast_json_null(), response);
ast_test_validate(test, 0 == invocation_count);
ast_test_validate(test, 405 == response->response_code);
@@ -525,7 +532,8 @@ AST_TEST_DEFINE(invoke_not_found)
fixture = setup_invocation_test();
response = response_alloc();
- ast_ari_invoke(NULL, "foo/fizzle/i-am-not-a-resource", AST_HTTP_GET, get_params, headers, response);
+ ast_ari_invoke(NULL, "foo/fizzle/i-am-not-a-resource", AST_HTTP_GET, get_params, headers,
+ ast_json_null(), response);
ast_test_validate(test, 0 == invocation_count);
ast_test_validate(test, 404 == response->response_code);