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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 gchar 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
  47. rspamd_dkim_test_func (void)
  48. {
  49. #if 0
  50. rspamd_dkim_context_t *ctx;
  51. rspamd_dkim_key_t *key;
  52. rspamd_mempool_t *pool;
  53. struct rspamd_dns_resolver *resolver;
  54. struct rspamd_config *cfg;
  55. GError *err = NULL;
  56. struct rspamd_async_session *s;
  57. cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
  58. bzero (cfg, sizeof (struct rspamd_config));
  59. cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
  60. cfg->dns_retransmits = 2;
  61. cfg->dns_timeout = 0.5;
  62. pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
  63. resolver = dns_resolver_init (NULL, base, cfg);
  64. g_assert (resolver != NULL);
  65. ctx = rspamd_create_dkim_context (test_dkim_sig, pool, 0, &err);
  66. g_assert (ctx != NULL);
  67. /* Key part */
  68. s = rspamd_session_create (pool, session_fin, NULL, NULL, NULL);
  69. g_assert (rspamd_get_dkim_key (ctx, resolver, s, test_key_handler, s));
  70. event_base_loop (base, 0);
  71. #endif
  72. }