1/*
2 * lws-api-test-jose
3 *
4 * Written in 2010-2019 by Andy Green <andy@warmcat.com>
5 *
6 * This file is made available under the Creative Commons CC0 1.0
7 * Universal Public Domain Dedication.
8 */
9
10#include <libwebsockets.h>
11
12int
13test_jwk(struct lws_context *context);
14int
15test_jws(struct lws_context *context);
16int
17test_jwe(struct lws_context *context);
18
19int main(int argc, const char **argv)
20{
21	struct lws_context_creation_info info;
22	struct lws_context *context;
23	const char *p;
24	int result = 0, logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE;
25
26	if ((p = lws_cmdline_option(argc, argv, "-d")))
27		logs = atoi(p);
28
29	lws_set_log_level(logs, NULL);
30	lwsl_user("LWS JOSE api tests\n");
31
32	memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */
33#if defined(LWS_WITH_NETWORK)
34	info.port = CONTEXT_PORT_NO_LISTEN;
35#endif
36	info.options = 0;
37
38	context = lws_create_context(&info);
39	if (!context) {
40		lwsl_err("lws init failed\n");
41		return 1;
42	}
43
44	result |= test_jwk(context);
45	lwsl_notice("%d\n", result);
46	result |= test_jws(context);
47	lwsl_notice("%d\n", result);
48	result |= test_jwe(context);
49	lwsl_notice("%d\n", result);
50
51	lwsl_user("Completed: %s\n", result ? "FAIL" : "PASS");
52
53	lws_context_destroy(context);
54
55	return result;
56}
57