aboutsummaryrefslogtreecommitdiffstats
path: root/camel/tests/smime
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-08-02 03:13:20 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-08-02 03:13:20 +0800
commit1b7da17c253261888de022fa0d6bebaa2d63df7a (patch)
tree437ce2c5efc4030255de834f3d8376cc6f9eb30f /camel/tests/smime
parent6f83476809513754e89400048254958c6ac02896 (diff)
downloadgsoc2013-evolution-1b7da17c253261888de022fa0d6bebaa2d63df7a.tar.gz
gsoc2013-evolution-1b7da17c253261888de022fa0d6bebaa2d63df7a.tar.zst
gsoc2013-evolution-1b7da17c253261888de022fa0d6bebaa2d63df7a.zip
Same.
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. svn path=/trunk/; revision=22055
Diffstat (limited to 'camel/tests/smime')
-rw-r--r--camel/tests/smime/pgp-mime.c55
-rw-r--r--camel/tests/smime/pgp.c55
2 files changed, 88 insertions, 22 deletions
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);