]> eyrie.org Git - kerberos/krb5-strength.git/blobdiff - tests/plugin/mit-t.c
Declare fast forward from 3.1-2
[kerberos/krb5-strength.git] / tests / plugin / mit-t.c
index 9857bb9e5bac050d19fe7ca9118fcbe203a67210..485ff75d686b0916a8475aedb4d66aba4ede31e4 100644 (file)
@@ -3,10 +3,10 @@
  *
  * Written by Russ Allbery <eagle@eyrie.org>
  * Copyright 2017, 2020 Russ Allbery <eagle@eyrie.org>
- * Copyright 2010, 20132014
+ * Copyright 2010, 2013-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
- * See LICENSE for licensing terms.
+ * SPDX-License-Identifier: MIT
  */
 
 #include <config.h>
@@ -71,7 +71,7 @@ load_plugin(krb5_context ctx, void **handle)
     char *path;
     krb5_error_code code;
     krb5_pwqual_vtable vtable = NULL;
-    krb5_error_code (*init)(krb5_context, int, int, krb5_plugin_vtable);
+    pwqual_strength_initvt *init;
 
     /* Load the module. */
     path = test_file_path("../plugin/.libs/strength.so");
@@ -83,7 +83,7 @@ load_plugin(krb5_context ctx, void **handle)
     test_file_path_free(path);
 
     /* Find the entry point function. */
-    init = dlsym(*handle, "pwqual_strength_initvt");
+    init = (pwqual_strength_initvt *) dlsym(*handle, "pwqual_strength_initvt");
     if (init == NULL)
         bail("cannot get pwqual_strength_initvt symbol: %s", dlerror());
 
@@ -207,9 +207,20 @@ main(void)
         is_password_test(ctx, vtable, data, &principal_tests[i]);
 
 #    ifdef HAVE_CRACKLIB
-    /* Run the CrackLib tests if CrackLib is available, otherwise skip them. */
-    for (i = 0; i < ARRAY_SIZE(cracklib_tests); i++)
+    /*
+     * Run the CrackLib tests if CrackLib is available, otherwise skip them.
+     * If built with the system CrackLib, skip tests that are marked as only
+     * working with the tougher rules of our embedded CrackLib.
+     */
+    for (i = 0; i < ARRAY_SIZE(cracklib_tests); i++) {
+#        ifdef HAVE_SYSTEM_CRACKLIB
+        if (cracklib_tests[i].skip_for_system_cracklib) {
+            skip_block(2, "not built with embedded CrackLib");
+            continue;
+        }
+#        endif
         is_password_test(ctx, vtable, data, &cracklib_tests[i]);
+    }
 #    else
     count = ARRAY_SIZE(cracklib_tests);
     skip_block(count * 2, "not built with CrackLib support");
@@ -227,7 +238,6 @@ main(void)
         bail("cannot find data/make-krb5-conf in the test suite");
     setup_argv[1] = path;
     setup_argv[2] = tmpdir;
-    setup_argv[3] = NULL;
 
     /* Point KRB5_CONFIG at the newly-generated krb5.conf file. */
     basprintf(&krb5_config, "KRB5_CONFIG=%s/krb5.conf", tmpdir);
@@ -253,8 +263,15 @@ main(void)
     is_int(0, code, "Plugin initialization (krb5.conf dictionary)");
     if (code != 0)
         bail("cannot continue after plugin initialization failure");
-    for (i = 0; i < ARRAY_SIZE(cracklib_tests); i++)
+    for (i = 0; i < ARRAY_SIZE(cracklib_tests); i++) {
+#        ifdef HAVE_SYSTEM_CRACKLIB
+        if (cracklib_tests[i].skip_for_system_cracklib) {
+            skip_block(2, "not built with embedded CrackLib");
+            continue;
+        }
+#        endif
         is_password_test(ctx, vtable, data, &cracklib_tests[i]);
+    }
     vtable->close(ctx, data);
 
     /*
@@ -288,7 +305,7 @@ main(void)
 
     /* Otherwise mark the CrackLib tests as skipped. */
     count = ARRAY_SIZE(cracklib_tests) + ARRAY_SIZE(length_tests);
-    skip_block(count * 2 + 1, "not built with CrackLib support");
+    skip_block(count * 2 + 2, "not built with CrackLib support");
 
 #    endif /* !HAVE_CRACKLIB */