37 #include "../res/ari/ari_model_validators.h" 39 #if defined(TEST_FRAMEWORK) 52 #if defined(TEST_FRAMEWORK) 73 info->name = __func__;
74 info->category =
"/ari/validators/";
75 info->summary =
"Test byte validation";
77 "Test byte validation";
84 ast_test_validate(
test,
NULL != uut);
88 ast_test_validate(
test, 0 == res);
92 ast_test_validate(
test, 0 == res);
96 ast_test_validate(
test, 0 == res);
100 ast_test_validate(
test, 0 == res);
109 ast_test_validate(
test, 0 == res);
124 info->name = __func__;
125 info->category =
"/ari/validators/";
126 info->summary =
"Test byte validation";
128 "Test byte validation";
143 ast_test_validate(
test, 0 == res);
148 ast_test_validate(
test, 0 == res);
164 info->name = __func__;
165 info->category =
"/ari/validators/";
166 info->summary =
"Test int validation";
168 "Test int validation";
175 ast_test_validate(
test,
NULL != uut);
179 ast_test_validate(
test, 0 == res);
183 ast_test_validate(
test, 0 == res);
187 ast_test_validate(
test, 0 == res);
191 ast_test_validate(
test, 0 == res);
200 ast_test_validate(
test, 0 == res);
216 info->name = __func__;
217 info->category =
"/ari/validators/";
218 info->summary =
"Test long validation";
220 "Test long validation";
227 ast_test_validate(
test,
NULL != uut);
236 ast_test_validate(
test, 0 == res);
252 info->name = __func__;
253 info->category =
"/ari/validators/";
254 info->summary =
"Test string validation";
256 "Test string validation";
263 ast_test_validate(
test,
NULL != uut);
267 ast_test_validate(
test, 0 == res);
282 const char *valid_dates[] = {
288 "2013-06-17T23:59:59Z",
290 "2013-06-30T23:59:61Z",
292 "2013-06-17T23:59:59.999999Z",
294 "2013-06-17T23:59-06:00",
295 "2013-06-17T23:59:59-06:00",
296 "2013-06-30T23:59:61-06:00",
297 "2013-06-17T23:59:59.999999-06:00",
299 "2013-06-17T23:59+06:30",
300 "2013-06-17T23:59:59+06:30",
301 "2013-06-30T23:59:61+06:30",
302 "2013-06-17T23:59:59.999999+06:30",
304 "2013-06-17T23:59-0600",
305 "2013-06-17T23:59:59-0600",
306 "2013-06-30T23:59:61-0600",
307 "2013-06-17T23:59:59.999999-0600",
309 "2013-06-17T23:59+0630",
310 "2013-06-17T23:59:59+0630",
311 "2013-06-30T23:59:61+0630",
312 "2013-06-17T23:59:59.999999+0630",
313 "9999-12-31T23:59:61.999999Z",
315 "2013-06-17T23:59-06",
316 "2013-06-17T23:59:59-06",
317 "2013-06-30T23:59:61-06",
318 "2013-06-17T23:59:59.999999-06",
328 const char *invalid_dates[] = {
332 "2013-06-17T23:59:59.Z",
334 "2013-06-17T23:59:59.999999",
335 "9999-99-31T23:59:61.999999Z",
336 "9999-12-99T23:59:61.999999Z",
337 "9999-12-31T99:59:61.999999Z",
338 "9999-12-31T23:99:61.999999Z",
339 "9999-12-31T23:59:99.999999Z",
340 "2013-06-17T23:59:59.999999-99:00",
341 "2013-06-17T23:59:59.999999-06:99",
342 "2013-06-17T23:59:59.999999-06:",
343 "2013-06-17T23:59:59.999999-06:0",
344 "2013-06-17T23:59:59.999999-060",
349 info->name = __func__;
350 info->category =
"/ari/validators/";
351 info->summary =
"Test date validation";
353 "Test date validation";
360 ast_test_validate(
test,
NULL != uut);
365 for (i = 0; i <
ARRAY_LEN(valid_dates); ++i) {
367 ast_test_validate(
test, 0 == res);
370 "Expected '%s' to be a valid date\n",
376 for (i = 0; i <
ARRAY_LEN(invalid_dates); ++i) {
378 ast_test_validate(
test, 0 == res);
381 "Expected '%s' to be an invalid date\n",
400 info->name = __func__;
401 info->category =
"/ari/validators/";
402 info->summary =
"Test list validation";
404 "Test list validation";
411 ast_test_validate(
test,
NULL != uut);
416 ast_test_validate(
test, 0 == res);
421 ast_test_validate(
test, 0 == res);
425 ast_test_validate(
test,
459 .requires =
"res_ari_model",
static int wrap_ast_ari_validate_string(struct ast_json *json)
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
#define AST_TEST_REGISTER(cb)
int ast_ari_validate_boolean(struct ast_json *json)
Validator for native Swagger boolean.
struct ast_json * ast_json_null(void)
Get the JSON null value.
int ast_ari_validate_date(struct ast_json *json)
Validator for native Swagger date.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_test_status_update(a, b, c...)
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
int ast_ari_validate_long(struct ast_json *json)
Validator for native Swagger long.
int ast_json_integer_set(struct ast_json *integer, intmax_t value)
Set the value of a JSON integer.
#define AST_TEST_UNREGISTER(cb)
static enum ast_test_result_state test_res
static int load_module(void)
int ast_ari_validate_int(struct ast_json *json)
Validator for native Swagger int.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
int ast_ari_validate_byte(struct ast_json *json)
Validator for native Swagger byte.
struct ast_json * ast_json_false(void)
Get the JSON false value.
int ast_ari_validate_string(struct ast_json *json)
Validator for native Swagger string.
Abstract JSON element (object, array, string, int, ...).
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
int ast_json_string_set(struct ast_json *string, const char *value)
Change the value of a JSON string.
#define ASTERISK_GPL_KEY
The text the key() function should return.
AST_TEST_DEFINE(validate_byte)
Asterisk module definitions.
struct ast_json * ast_json_true(void)
Get the JSON true value.
static int wrap_ast_ari_validate_int(struct ast_json *json)
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.