diff --git a/selftest/knownfail.d/keytab b/selftest/knownfail.d/keytab new file mode 100644 index 00000000000..6777d98ff28 --- /dev/null +++ b/selftest/knownfail.d/keytab @@ -0,0 +1 @@ +^samba.unittests.kerberos.test_krb5_remove_obsolete_keytab_entries_many diff --git a/selftest/tests.py b/selftest/tests.py index 185ad37fd4a..f354bb57ef5 100644 --- a/selftest/tests.py +++ b/selftest/tests.py @@ -187,5 +187,7 @@ plantestsuite("samba.unittests.tldap", "none", [os.path.join(bindir(), "default/source3/test_tldap")]) plantestsuite("samba.unittests.rfc1738", "none", [os.path.join(bindir(), "default/lib/util/test_rfc1738")]) +plantestsuite("samba.unittests.kerberos", "none", + [os.path.join(bindir(), "test_kerberos")]) plantestsuite("samba.unittests.ms_fnmatch", "none", [os.path.join(bindir(), "default/lib/util/test_ms_fnmatch")]) diff --git a/source4/auth/tests/kerberos.c b/source4/auth/tests/kerberos.c new file mode 100644 index 00000000000..703c8067908 --- /dev/null +++ b/source4/auth/tests/kerberos.c @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "includes.h" +#include "system/kerberos.h" +#include "auth/kerberos/kerberos.h" +#include "auth/credentials/credentials.h" +#include "auth/credentials/credentials_proto.h" +#include "auth/credentials/credentials_krb5.h" +#include "auth/kerberos/kerberos_credentials.h" +#include "auth/kerberos/kerberos_util.h" + +static void internal_obsolete_keytab_test(int num_principals, int num_kvnos, + krb5_kvno kvno, const char *kt_name) +{ + krb5_context krb5_ctx; + krb5_keytab keytab; + krb5_keytab_entry kt_entry; + krb5_kt_cursor cursor; + krb5_error_code code; + + int i,j; + char princ_name[6] = "user0"; + char expect_princ_name[23] = "user0@samba.example.com"; + bool found_previous; + const char *error_str; + + TALLOC_CTX *tmp_ctx = talloc_new(NULL); + krb5_principal *principals = talloc_zero_array(tmp_ctx, + krb5_principal, + num_principals); + krb5_init_context(&krb5_ctx); + krb5_kt_resolve(krb5_ctx, kt_name, &keytab); + ZERO_STRUCT(kt_entry); + + for(i=0; i