main.c 1.2 KB

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