[evolution-patches] pgp test suite patch



fixed the pgp test suite to build

-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1858
retrieving revision 1.1859
diff -u -r1.1858 -r1.1859
--- ChangeLog	30 Jul 2003 17:25:00 -0000	1.1858
+++ ChangeLog	1 Aug 2003 19:13:14 -0000	1.1859
@@ -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.
Index: tests/data/camel-test.gpg.pub
===================================================================
RCS file: tests/data/camel-test.gpg.pub
diff -N tests/data/camel-test.gpg.pub
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/data/camel-test.gpg.pub	1 Aug 2003 19:13:19 -0000	1.1
@@ -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-----
Index: tests/data/camel-test.gpg.sec
===================================================================
RCS file: tests/data/camel-test.gpg.sec
diff -N tests/data/camel-test.gpg.sec
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/data/camel-test.gpg.sec	1 Aug 2003 19:13:19 -0000	1.1
@@ -0,0 +1,33 @@
+-----BEGIN PGP PRIVATE KEY BLOCK-----
+Version: GnuPG v1.0.7 (GNU/Linux)
+
+lQHhBD8qsjARBACkS39GA1e6pDUumC9sQyZaE2PEZW6VEH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PM93pxpQpRdWKhv+ocjJ4xPlwI8LTrQIHKxB3yF2WNCh/TQDi0hm6ktEi2RVusMA
+AwUD/3Wp0UbJ2/bgM9wOMAD8celvbl9V/L+9/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-----
Index: tests/smime/pgp.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/tests/smime/pgp.c,v
retrieving revision 1.6
retrieving revision 1.9
diff -u -r1.6 -r1.9
--- tests/smime/pgp.c	19 Aug 2002 20:14:12 -0000	1.6
+++ tests/smime/pgp.c	1 Aug 2003 19:31:31 -0000	1.9
@@ -1,8 +1,34 @@
+/* -*- 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>
 #include <string.h>
+#include <sys/wait.h>
 #include <camel/camel-gpg-context.h>
 #include <camel/camel-stream-mem.h>
 
@@ -27,8 +53,9 @@
 
 
 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 +94,10 @@
 }
 
 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 *
@@ -96,17 +123,29 @@
 	GPtrArray *recipients;
 	GByteArray *buf;
 	char *before, *after;
+	int ret;
 	
 	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 */
+	if ((ret = system ("gpg > /dev/null 2>&1")) == -1)
+		return 77;
+	else if (WEXITSTATUS (ret) == 127)
+		return 77;
+	
+	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 +157,7 @@
 	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 +187,8 @@
 	
 	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);
Index: tests/smime/pgp-mime.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/tests/smime/pgp-mime.c,v
retrieving revision 1.6
retrieving revision 1.8
diff -u -r1.6 -r1.8
--- tests/smime/pgp-mime.c	19 Aug 2002 20:14:12 -0000	1.6
+++ tests/smime/pgp-mime.c	1 Aug 2003 19:30:50 -0000	1.8
@@ -1,8 +1,34 @@
+/* -*- 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>
 #include <string.h>
+#include <sys/wait.h>
 #include <camel/camel-gpg-context.h>
 #include <camel/camel-multipart-signed.h>
 #include <camel/camel-multipart-encrypted.h>
@@ -35,8 +61,9 @@
 
 
 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 +102,10 @@
 }
 
 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 +134,25 @@
 	
 	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 */
+	if ((ret = system ("gpg > /dev/null 2>&1")) == -1)
+		return 77;
+	else if (WEXITSTATUS (ret) == 127)
+		return 127;
+	
+	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 +163,7 @@
 	
 	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 +186,10 @@
 	
 	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 ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]