• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 int
13 test_jwk(struct lws_context *context);
14 int
15 test_jws(struct lws_context *context);
16 int
17 test_jwe(struct lws_context *context);
18 
main(int argc,const char ** argv)19 int 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 	info.port = CONTEXT_PORT_NO_LISTEN;
34 	info.options = 0;
35 
36 	context = lws_create_context(&info);
37 	if (!context) {
38 		lwsl_err("lws init failed\n");
39 		return 1;
40 	}
41 
42 	result |= test_jwk(context);
43 	lwsl_notice("%d\n", result);
44 	result |= test_jws(context);
45 	lwsl_notice("%d\n", result);
46 	result |= test_jwe(context);
47 	lwsl_notice("%d\n", result);
48 
49 	lwsl_user("Completed: %s\n", result ? "FAIL" : "PASS");
50 
51 	lws_context_destroy(context);
52 
53 	return result;
54 }
55