You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rspamd_dkim_test.c 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "config.h"
  17. #include "tests.h"
  18. #include "rspamd.h"
  19. #include "dkim.h"
  20. static const char test_dkim_sig[] = "v=1; a=rsa-sha256; c=relaxed/relaxed; "
  21. "d=highsecure.ru; s=dkim; t=1410516996; "
  22. "bh=guFoWYHWVzFRqVyAQebnvPcdm7bUQo7pRHt/uIHD7gs=; "
  23. "h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding; "
  24. "b=PCiECkOaPFb99DW+gApgfmdlTUo6XN6YXjnj52Cxoz2FoA857B0ZHFgeQe4JAKHuhW"
  25. "oq3BLHap0GcMTTpSOgfQOKa8Df35Ns11JoOFjdBQ8GpM99kOrJP+vZcT8b7AMfthYm0Kwy"
  26. "D9TjlkpScuoY5LjsWVnijh9dSNVLFqLatzg=;";
  27. extern struct ev_loop *event_loop;
  28. #if 0
  29. static void
  30. test_key_handler (rspamd_dkim_key_t *key, gsize keylen, rspamd_dkim_context_t *ctx, gpointer ud, GError *err)
  31. {
  32. struct rspamd_async_session *s = ud;
  33. g_assert (key != NULL);
  34. rspamd_session_destroy (s);
  35. }
  36. static gboolean
  37. session_fin (gpointer unused)
  38. {
  39. struct timeval tv;
  40. tv.tv_sec = 0;
  41. tv.tv_usec = 0;
  42. event_loopexit (&tv);
  43. return TRUE;
  44. }
  45. #endif
  46. void rspamd_dkim_test_func(void)
  47. {
  48. #if 0
  49. rspamd_dkim_context_t *ctx;
  50. rspamd_dkim_key_t *key;
  51. rspamd_mempool_t *pool;
  52. struct rspamd_dns_resolver *resolver;
  53. struct rspamd_config *cfg;
  54. GError *err = NULL;
  55. struct rspamd_async_session *s;
  56. cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
  57. bzero (cfg, sizeof (struct rspamd_config));
  58. cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
  59. cfg->dns_retransmits = 2;
  60. cfg->dns_timeout = 0.5;
  61. pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
  62. resolver = dns_resolver_init (NULL, base, cfg);
  63. g_assert (resolver != NULL);
  64. ctx = rspamd_create_dkim_context (test_dkim_sig, pool, 0, &err);
  65. g_assert (ctx != NULL);
  66. /* Key part */
  67. s = rspamd_session_create (pool, session_fin, NULL, NULL, NULL);
  68. g_assert (rspamd_get_dkim_key (ctx, resolver, s, test_key_handler, s));
  69. event_base_loop (base, 0);
  70. #endif
  71. }