aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2022-01-13 15:30:56 +0000
committerIngo Klöcker <[email protected]>2022-01-13 15:30:56 +0000
commite16729edcbdf2c35e3729b6d54c21b9b27250326 (patch)
treeaa25a12e425366b0faacd0b576305431de0e95d8 /tests
parenttests: Remove unsupported option --status from usage help (diff)
downloadgpgme-e16729edcbdf2c35e3729b6d54c21b9b27250326.tar.gz
gpgme-e16729edcbdf2c35e3729b6d54c21b9b27250326.zip
tests: Fix generation of keys without expiration
* tests/run-genkey.c (parse_expire_string): Support default expiration and no expiration. Set flag for no expiration. (main): Allow update of flags when generating new key. -- This makes the parsing of different values for expiration match the parsing done by gpg's --quick-gen-key. In particular, this makes it possible again to generate keys without expiration.
Diffstat (limited to 'tests')
-rw-r--r--tests/run-genkey.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/run-genkey.c b/tests/run-genkey.c
index f0f6e302..8572db26 100644
--- a/tests/run-genkey.c
+++ b/tests/run-genkey.c
@@ -131,15 +131,23 @@ progress_cb (void *opaque, const char *what, int type, int current, int total)
static unsigned long
-parse_expire_string (const char *string)
+parse_expire_string (const char *string, unsigned int *flags)
{
- unsigned long seconds;
+ unsigned long seconds = 0;
- if (!string || !*string || !strcmp (string, "none")
- || !strcmp (string, "never") || !strcmp (string, "-"))
- seconds = 0;
+ if (!string || !*string || !strcmp (string, "-"))
+ ;
+ else if (!strcmp (string, "none") || !strcmp (string, "never"))
+ {
+ if (flags)
+ *flags |= GPGME_CREATE_NOEXPIRE;
+ }
else if (strspn (string, "01234567890") == strlen (string))
- seconds = strtoul (string, NULL, 10);
+ {
+ seconds = strtoul (string, NULL, 10);
+ if (!seconds && flags)
+ *flags |= GPGME_CREATE_NOEXPIRE;
+ }
else
{
fprintf (stderr, PGM ": invalid value '%s'\n", string);
@@ -370,7 +378,7 @@ main (int argc, char **argv)
}
userid = argv[0];
argc--; argv++;
- expire = parse_expire_string (argv[0]);
+ expire = parse_expire_string (argv[0], NULL);
argc--; argv++;
if (argc > 1)
{
@@ -414,7 +422,7 @@ main (int argc, char **argv)
if (argc > 2)
flags |= parse_usage_string (argv[2]);
if (argc > 3)
- expire = parse_expire_string (argv[3]);
+ expire = parse_expire_string (argv[3], &flags);
}
init_gpgme (protocol);