diff options
-rw-r--r-- | camel/ChangeLog | 7 | ||||
-rw-r--r-- | camel/tests/data/camel-test.gpg.pub | 24 | ||||
-rw-r--r-- | camel/tests/data/camel-test.gpg.sec | 33 | ||||
-rw-r--r-- | camel/tests/smime/pgp-mime.c | 55 | ||||
-rw-r--r-- | camel/tests/smime/pgp.c | 55 |
5 files changed, 152 insertions, 22 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index def25b1598..2c2516c433 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2003-08-01 Jeffrey Stedfast <fejj@ximian.com> + + * tests/smime/pgp-mime.c: Same. + + * tests/smime/pgp.c: Updated to build and to import some custom + gpg keys for use with testing. + 2003-07-30 Jeffrey Stedfast <fejj@ximian.com> * camel-mime-message.c (write_to_stream): Also updated. diff --git a/camel/tests/data/camel-test.gpg.pub b/camel/tests/data/camel-test.gpg.pub new file mode 100644 index 0000000000..fdf28a59bd --- /dev/null +++ b/camel/tests/data/camel-test.gpg.pub @@ -0,0 +1,24 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.0.7 (GNU/Linux) + +mQGiBD8qsjARBACkS39GA1e6pDUumC9sQyZaE2PEZW6VEHMGQ9IlJ/Qi2wJBFKgl +Myl2Cko9Rpj2DmgGkBnoL6fPJNM9aCV0RvclvE15EViURU7mjYzF41uspvVMBg7b +y3cwAzkkgyhLc/V0Inzm9UpJZ6JvrqYO5OvJUA+ka5SHrhuX4ptmjKLjNwCgwNCx +CQHx9RIbPggYtfci1w9npm8D/3vks1q+G9r91JkRBqGTboBZ7HI1yU2tHJ38wsKp +kamloFr3j0hmN0s5PY4wgz4daJ120yTmweJQfIljcN2+aHeI5838u7f3Wk5LJtLG ++0xKBpBeejzqT/FzhxLIOoQl3L8aF+KAY+Oz7Bm/J/5MRPEPdxWGIB1LhnkoDP5F +5szGA/9POpFU7y34ACid5Grzk77LUVyHMGob+vgqoVITfCNGjfGf7tnXn1LlRf6N +TE81p1vYDz2K4bpPmOgBXuESmpaTfXvlDy6oW7buslFqgddm/MfzzM0wC2jdx5TV +NdNApku4PKA4pE2oTSg5EuGgxQLjJG/PHkoiRiK6yG8gign8vrQbTm8gVXNlciA8 +bm8udXNlckBuby5kb21haW4+iFkEExECABkFAj8qsjAECwcDAgMVAgMDFgIBAh4B +AheAAAoJEOvMhgJ6QMoGIQcAoIweyKELWnksPUk5mmZz26JFsmQVAJ9aTm+OO289 ++fdwq95xw/6KH2dEtrkBDQQ/KrIxEAQA26Y+QRaR7RymzyUW7MQlDbshD/vInLtb +36FusuOWzL5TgYn6fiiu/e/J+qjZO5psucWelnBIbnLTZZJs06EgybLPCeEP34X7 +cSsAPZ2JE+TKPM93pxpQpRdWKhv+ocjJ4xPlwI8LTrQIHKxB3yF2WNCh/TQDi0hm +6ktEi2RVusMAAwUD/3Wp0UbJ2/bgM9wOMAD8celvbl9V/L+9/UVBJrw4tH87FMZi +NMNg13TbMrARqJjdpOoHzozMv1GOumC5sE8A0/pwbIdU9oSYA07D3+02dCQq+52a +qtCGJoRq5okccQelRcs0cZIy/z5lzwsNnbshrmnqNdmuVf7BSdw7DjoFj5OLiEYE +GBECAAYFAj8qsjEACgkQ68yGAnpAygZaCgCfZu68SOUfcUZC3CWi4ITBvcKGvmUA +n1wrC5ZGv0SIRo5G1PswsKRZuEpl +=SWoX +-----END PGP PUBLIC KEY BLOCK----- diff --git a/camel/tests/data/camel-test.gpg.sec b/camel/tests/data/camel-test.gpg.sec new file mode 100644 index 0000000000..f2af11e82e --- /dev/null +++ b/camel/tests/data/camel-test.gpg.sec @@ -0,0 +1,33 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: GnuPG v1.0.7 (GNU/Linux) + +lQHhBD8qsjARBACkS39GA1e6pDUumC9sQyZaE2PEZW6VEHMGQ9IlJ/Qi2wJBFKgl +Myl2Cko9Rpj2DmgGkBnoL6fPJNM9aCV0RvclvE15EViURU7mjYzF41uspvVMBg7b +y3cwAz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UVBJrw4tH87FMZiNMNg13TbMrAR +qJjdpOoHzozMv1GOumC5sE8A0/pwbIdU9oSYA07D3+02dCQq+52aqtCGJoRq5okc +cQelRcs0cZIy/z5lzwsNnbshrmnqNdmuVf7BSdw7DjoFj5OL/gMDAkqyI1nEMCws +YMk7XUGj7+BY1uyYyNpYp50F52HFsGXEffiKYPGIuybuP+Yz3ic4W9aQTJJPcIJg +ZqUP9b14WfY4mgIm1Tz9JiM6RUxHX2ZhY3RvcjoAAKsH4JdVQugM+lGnuNuGoj7I +V8O8bIsP/SYjOkVMR19mYWN0b3I6AACrBzvFd1NLrbYGMjsN3SKhgBtuHjGQx/0m +IzpFTEdfZmFjdG9yOgAAqwR77L22dgo/dV8XO8NThXMbEmQgoY39JiM6RUxHX2Zh +Y3RvcjoAAKsFRPzjSodiTFMeiwWHgpdgf4e2qzEN/SYjOkVMR19mYWN0b3I6AACr +BX9hqiLZJKfgpo/hs/0wK8yHq6GXh4hGBBgRAgAGBQI/KrIxAAoJEOvMhgJ6QMoG +WgoAoKwAHwpedO9qQNBu0REM1jNR9PuuAJ9ZtHyuOiziV/JageUT+hZ8s27U3A== +=xLRp +-----END PGP PRIVATE KEY BLOCK----- diff --git a/camel/tests/smime/pgp-mime.c b/camel/tests/smime/pgp-mime.c index c58b1866f3..578baac938 100644 --- a/camel/tests/smime/pgp-mime.c +++ b/camel/tests/smime/pgp-mime.c @@ -1,4 +1,29 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Jeffrey Stedfast <fejj@ximian.com> + * + * Copyright 2003 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include <stdio.h> #include <stdlib.h> @@ -35,8 +60,9 @@ typedef struct _CamelPgpSessionClass { static char *get_password (CamelSession *session, const char *prompt, - gboolean secret, CamelService *service, - const char *item, CamelException *ex); + gboolean reprompt, gboolean secret, + CamelService *service, const char *item, + CamelException *ex); static void init (CamelPgpSession *session) @@ -75,10 +101,10 @@ camel_pgp_session_get_type (void) } static char * -get_password (CamelSession *session, const char *prompt, gboolean secret, +get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, CamelService *service, const char *item, CamelException *ex) { - return g_strdup ("PGP/MIME is rfc2015, now go and read it."); + return g_strdup ("no.secret"); } static CamelSession * @@ -107,14 +133,21 @@ int main (int argc, char **argv) camel_test_init (argc, argv); - ex = camel_exception_new (); - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); + system ("/bin/rm -rf /tmp/camel-test"); + system ("/bin/mkdir /tmp/camel-test"); + setenv ("GNUPGHOME", "/tmp/camel-test/.gnupg", 1); + + /* import the gpg keys */ + system ("gpg > /dev/null 2>&1"); /* creates gpg directory and stuff */ + system ("gpg --import camel-test.gpg.pub > /dev/null 2>&1"); + system ("gpg --import camel-test.gpg.sec > /dev/null 2>&1"); session = camel_pgp_session_new ("/tmp/camel-test"); - ctx = camel_gpg_context_new (session, "/usr/bin/gpg"); + ex = camel_exception_new (); + + ctx = camel_gpg_context_new (session); camel_gpg_context_set_always_trust (CAMEL_GPG_CONTEXT (ctx), TRUE); camel_test_start ("Test of PGP/MIME functions"); @@ -125,7 +158,7 @@ int main (int argc, char **argv) camel_test_push ("PGP/MIME signing"); mps = camel_multipart_signed_new (); - camel_multipart_signed_sign (mps, ctx, mime_part, "pgp-mime@xtorshun.org", CAMEL_CIPHER_HASH_SHA1, ex); + camel_multipart_signed_sign (mps, ctx, mime_part, "no.user@no.domain", CAMEL_CIPHER_HASH_SHA1, ex); check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); camel_test_pull (); @@ -148,10 +181,10 @@ int main (int argc, char **argv) camel_test_push ("PGP/MIME encrypt"); recipients = g_ptr_array_new (); - g_ptr_array_add (recipients, "pgp-mime@xtorshun.org"); + g_ptr_array_add (recipients, "no.user@no.domain"); mpe = camel_multipart_encrypted_new (); - camel_multipart_encrypted_encrypt (mpe, mime_part, ctx, "pgp-mime@xtorshun.org", recipients, ex); + camel_multipart_encrypted_encrypt (mpe, mime_part, ctx, "no.user@no.domain", recipients, ex); check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); g_ptr_array_free (recipients, TRUE); camel_test_pull (); diff --git a/camel/tests/smime/pgp.c b/camel/tests/smime/pgp.c index 3b422d222b..98f708a27e 100644 --- a/camel/tests/smime/pgp.c +++ b/camel/tests/smime/pgp.c @@ -1,4 +1,29 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Jeffrey Stedfast <fejj@ximian.com> + * + * Copyright 2003 Ximian, Inc. (www.ximian.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include <stdio.h> #include <stdlib.h> @@ -27,8 +52,9 @@ typedef struct _CamelPgpSessionClass { static char *get_password (CamelSession *session, const char *prompt, - gboolean secret, CamelService *service, - const char *item, CamelException *ex); + gboolean reprompt, gboolean secret, + CamelService *service, const char *item, + CamelException *ex); static void init (CamelPgpSession *session) @@ -67,10 +93,10 @@ camel_pgp_session_get_type (void) } static char * -get_password (CamelSession *session, const char *prompt, gboolean secret, +get_password (CamelSession *session, const char *prompt, gboolean reprompt, gboolean secret, CamelService *service, const char *item, CamelException *ex) { - return g_strdup ("PGP/MIME is rfc2015, now go and read it."); + return g_strdup ("no.secret"); } static CamelSession * @@ -99,14 +125,21 @@ int main (int argc, char **argv) camel_test_init (argc, argv); - ex = camel_exception_new (); - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); + system ("/bin/rm -rf /tmp/camel-test"); + system ("/bin/mkdir /tmp/camel-test"); + setenv ("GNUPGHOME", "/tmp/camel-test/.gnupg", 1); + + /* import the gpg keys */ + system ("gpg > /dev/null 2>&1"); /* creates gpg directory and stuff */ + system ("gpg --import ../data/camel-test.gpg.pub > /dev/null 2>&1"); + system ("gpg --import ../data/camel-test.gpg.sec > /dev/null 2>&1"); session = camel_pgp_session_new ("/tmp/camel-test"); - ctx = camel_gpg_context_new (session, "/usr/bin/gpg"); + ex = camel_exception_new (); + + ctx = camel_gpg_context_new (session); camel_gpg_context_set_always_trust (CAMEL_GPG_CONTEXT (ctx), TRUE); camel_test_start ("Test of PGP functions"); @@ -118,7 +151,7 @@ int main (int argc, char **argv) stream2 = camel_stream_mem_new (); camel_test_push ("PGP signing"); - camel_cipher_sign (ctx, "pgp-mime@xtorshun.org", CAMEL_CIPHER_HASH_SHA1, + camel_cipher_sign (ctx, "no.user@no.domain", CAMEL_CIPHER_HASH_SHA1, stream1, stream2, ex); check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); camel_test_pull (); @@ -148,8 +181,8 @@ int main (int argc, char **argv) camel_test_push ("PGP encrypt"); recipients = g_ptr_array_new (); - g_ptr_array_add (recipients, "pgp-mime@xtorshun.org"); - camel_cipher_encrypt (ctx, FALSE, "pgp-mime@xtorshun.org", recipients, + g_ptr_array_add (recipients, "no.user@no.domain"); + camel_cipher_encrypt (ctx, FALSE, "no.user@no.domain", recipients, stream1, stream2, ex); check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); g_ptr_array_free (recipients, TRUE); |