test-pop3-migration-plugin.c revision 29fc8f1dc678f9698363181ea599e6db105ea50f
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2015-2017 Dovecot authors, see the included COPYING file */
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainenstatic void test_pop3_migration_get_hdr_sha1(void)
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen static const struct {
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen { "", "da39a3ee5e6b4b0d3255bfef95601890afd80709", FALSE },
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen { "\n", "adc83b19e793491b1c6ea0fd8b46cd9f32e592fc", TRUE },
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen { "a: \r\n", "a3871371f2d468493005286282ae10549dab2c57", FALSE },
e3678f7bfba87b5aa1446a1a7b9928272b4f72a3Timo Sirainen { "a: b\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen { "a: b \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen { "a: b \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen { "a: b \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen { "a: b\r\n\r\n", "938b96404495cced816e3a4f6031734eab4e71b3", TRUE },
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen { "a: b\r\n\r\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen { "a: b\r\n\r\r\nc: d\r\n\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", TRUE },
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen { "a: b\r\n \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen { "a: b\r\n \r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen { "a: b\r\n\t\r\n", "44ef6a20971148dd54a161f79814e22e2d098ddb", FALSE },
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen unsigned int i;
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen input = i_stream_create_from_data(tests[i].input,
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen test_assert_idx(pop3_migration_get_hdr_sha1(1, input, digest, &have_eoh) == 0, i);
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen test_assert_idx(strcasecmp(binary_to_hex(digest, sizeof(digest)), tests[i].sha1) == 0, i);
862ec874f9373e3e499e237d3b9f71fdf1413feeTimo Sirainen test_assert_idx(tests[i].have_eoh == have_eoh, i);
9a48c2243fe98ca8393be7908f84d20c634bcdf9Timo Sirainen static void (*const test_functions[])(void) = {