vol: avoid MAXINT redefinition warning in vnode.c
[openafs.git] / tests / auth / keys-t.c
index 2e3dc6c..ba7391e 100644 (file)
@@ -101,11 +101,12 @@ int main(int argc, char **argv)
     struct afsconf_typedKeyList *typedKeyList;
     char *dirname;
     char *keyfile;
+    char *keyfilesrc;
     afs_int32 kvno;
     int code;
     int i;
 
-    plan(127);
+    plan(134);
 
     /* Create a temporary afs configuration directory */
 
@@ -114,8 +115,18 @@ int main(int argc, char **argv)
     if (asprintf(&keyfile, "%s/KeyFile", dirname) == -1)
        goto out;
 
+    /* Work out the path to our KeyFile. If the test harness hasn't set
+     * the SOURCE environment variable, then assume it is in our CWD */
+    if (getenv("SOURCE") == NULL) {
+       keyfilesrc = strdup("KeyFile");
+    } else {
+       if (asprintf(&keyfilesrc, "%s/auth/KeyFile", getenv("SOURCE")) == -1)
+           goto out;
+    }
+
     /* First, copy in a known keyfile */
-    code = copy("KeyFile", keyfile);
+    code = copy(keyfilesrc, keyfile);
+    free(keyfilesrc);
     if (code)
        goto out;
 
@@ -527,6 +538,23 @@ int main(int argc, char **argv)
        " ... with the right key in slot 1");
     afsconf_PutTypedKeyList(&typedKeyList);
 
+    /* Check that GetAllKeys works as expected */
+    code = afsconf_GetAllKeys(dir, &typedKeyList);
+    is_int(0, code, "afsconf_GetAllKeys returns success");
+    is_int(5, typedKeyList->nkeys, " ... with the correct number of keys");
+    ok(keyMatches(typedKeyList->keys[0], afsconf_rxkad, 1, 0,
+                 "\x10\x10\x10\x10\x10\x10\x10\x10", 8),
+       " ... with right key in slot 0");
+    ok(keyMatches(typedKeyList->keys[1], afsconf_rxkad, 2, 0,
+                  "\x30\x30\x30\x30\x30\x30\x30\x30", 8),
+       " ... with right key in slot 1");
+    ok(keyMatches(typedKeyList->keys[2], 1, 1, 0, "\x03", 1),
+       " ... with right key in slot 2");
+    ok(keyMatches(typedKeyList->keys[3], 1, 2, 0, "\x01", 1),
+       " ... with right key in slot 3");
+    ok(keyMatches(typedKeyList->keys[4], 1, 2, 1, "\x02\03", 2),
+       " ... with right key in slot 4");
+
     afsconf_Close(dir);
 
     unlinkTestConfig(dirname);