summaryrefslogtreecommitdiffstats
path: root/src/ccapi/test
diff options
context:
space:
mode:
authorAlexandra Ellwood <lxs@mit.edu>2008-03-12 16:50:21 +0000
committerAlexandra Ellwood <lxs@mit.edu>2008-03-12 16:50:21 +0000
commit9b58ededdc28757a3a203e645094a2cd854434cf (patch)
treefc92e9bf3fbd2ff26887abd80bfa3015298417b0 /src/ccapi/test
parentb03001c9aad53a6ecdc8ebef0493882bad0a826c (diff)
downloadkrb5-9b58ededdc28757a3a203e645094a2cd854434cf.tar.gz
krb5-9b58ededdc28757a3a203e645094a2cd854434cf.tar.xz
krb5-9b58ededdc28757a3a203e645094a2cd854434cf.zip
Added tests for iterators and NC info. Added test programs for
each test. Cleaned up portability issues introduced by Windows testing. ticket: 5909 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20270 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/ccapi/test')
-rw-r--r--src/ccapi/test/Makefile62
-rw-r--r--src/ccapi/test/Makefile.in22
-rw-r--r--src/ccapi/test/check_cc_destroy.c0
-rw-r--r--src/ccapi/test/main.c10
-rw-r--r--src/ccapi/test/simple_lock_test.c39
-rw-r--r--src/ccapi/test/test_cc_close.c14
-rw-r--r--src/ccapi/test/test_cc_create.c14
-rw-r--r--src/ccapi/test/test_cc_destroy.c14
-rw-r--r--src/ccapi/test/test_cc_get_NC_info.c14
-rw-r--r--src/ccapi/test/test_cc_get_change_time.c14
-rw-r--r--src/ccapi/test/test_cc_get_cred_version.c14
-rw-r--r--src/ccapi/test/test_cc_get_name.c14
-rw-r--r--src/ccapi/test/test_cc_get_principal.c14
-rw-r--r--src/ccapi/test/test_cc_open.c14
-rw-r--r--src/ccapi/test/test_cc_remove_cred.c14
-rw-r--r--src/ccapi/test/test_cc_seq_fetch_NCs_begin.c14
-rw-r--r--src/ccapi/test/test_cc_seq_fetch_NCs_next.c14
-rw-r--r--src/ccapi/test/test_cc_seq_fetch_creds_begin.c14
-rw-r--r--src/ccapi/test/test_cc_seq_fetch_creds_next.c14
-rw-r--r--src/ccapi/test/test_cc_set_principal.c14
-rw-r--r--src/ccapi/test/test_cc_shutdown.c14
-rw-r--r--src/ccapi/test/test_cc_store.c14
-rw-r--r--src/ccapi/test/test_ccapi.sh18
-rw-r--r--src/ccapi/test/test_ccapi_ccache.c32
-rw-r--r--src/ccapi/test/test_ccapi_globals.h4
-rw-r--r--src/ccapi/test/test_ccapi_iterators.c12
-rw-r--r--src/ccapi/test/test_ccapi_log.h8
-rw-r--r--src/ccapi/test/test_ccapi_util.c1
-rw-r--r--src/ccapi/test/test_ccapi_v2.c526
-rw-r--r--src/ccapi/test/test_ccapi_v2.h22
-rw-r--r--src/ccapi/test/untitled0
31 files changed, 930 insertions, 64 deletions
diff --git a/src/ccapi/test/Makefile b/src/ccapi/test/Makefile
index f1f9fc4d8a..40aad41a50 100644
--- a/src/ccapi/test/Makefile
+++ b/src/ccapi/test/Makefile
@@ -12,11 +12,67 @@ TESTDIR = $(DSTDIR)/tests
SCRIPT_NAME = test_ccapi.sh
-_OBJECTS = test_ccapi_ccache test_ccapi_check test_ccapi_constants test_ccapi_context test_ccapi_globals test_ccapi_iterators test_ccapi_log test_ccapi_util
+_OBJECTS = test_ccapi_ccache \
+ test_ccapi_check \
+ test_ccapi_constants \
+ test_ccapi_context \
+ test_ccapi_globals \
+ test_ccapi_iterators \
+ test_ccapi_log \
+ test_ccapi_util \
+ test_ccapi_v2
OBJECTS = $(patsubst %,$(OBJDIR)/%.o,$(_OBJECTS))
-TEST_NAMES = test_constants test_cc_initialize test_cc_context_release test_cc_context_get_change_time test_cc_context_get_default_ccache_name test_cc_context_open_ccache test_cc_context_open_default_ccache test_cc_context_create_ccache test_cc_context_create_default_ccache test_cc_context_create_new_ccache test_cc_context_new_ccache_iterator test_cc_context_compare test_cc_ccache_release test_cc_ccache_destroy test_cc_ccache_set_default test_cc_ccache_get_credentials_version test_cc_ccache_get_name test_cc_ccache_get_principal test_cc_ccache_set_principal test_cc_ccache_store_credentials test_cc_ccache_remove_credentials test_cc_ccache_new_credentials_iterator test_cc_ccache_get_change_time test_cc_ccache_get_last_default_time test_cc_ccache_move test_cc_ccache_compare test_cc_ccache_get_kdc_time_offset test_cc_ccache_set_kdc_time_offset test_cc_ccache_clear_kdc_time_offset test_cc_ccache_iterator_next test_cc_credentials_iterator_next
+TEST_NAMES = test_constants \
+ test_cc_initialize \
+ test_cc_context_release \
+ test_cc_context_get_change_time \
+ test_cc_context_get_default_ccache_name \
+ test_cc_context_open_ccache \
+ test_cc_context_open_default_ccache \
+ test_cc_context_create_ccache \
+ test_cc_context_create_default_ccache \
+ test_cc_context_create_new_ccache \
+ test_cc_context_new_ccache_iterator \
+ test_cc_context_compare \
+ test_cc_ccache_release \
+ test_cc_ccache_destroy \
+ test_cc_ccache_set_default \
+ test_cc_ccache_get_credentials_version \
+ test_cc_ccache_get_name \
+ test_cc_ccache_get_principal \
+ test_cc_ccache_set_principal \
+ test_cc_ccache_store_credentials \
+ test_cc_ccache_remove_credentials \
+ test_cc_ccache_new_credentials_iterator \
+ test_cc_ccache_get_change_time \
+ test_cc_ccache_get_last_default_time \
+ test_cc_ccache_move \
+ test_cc_ccache_compare \
+ test_cc_ccache_get_kdc_time_offset \
+ test_cc_ccache_set_kdc_time_offset \
+ test_cc_ccache_clear_kdc_time_offset \
+ test_cc_ccache_iterator_next \
+ test_cc_credentials_iterator_next\
+ test_cc_shutdown \
+ test_cc_get_change_time \
+ test_cc_open \
+ test_cc_create \
+ test_cc_close \
+ test_cc_destroy \
+ test_cc_get_cred_version \
+ test_cc_get_name \
+ test_cc_get_principal \
+ test_cc_set_principal \
+ test_cc_store \
+ test_cc_remove_cred \
+ test_cc_seq_fetch_NCs_begin \
+ test_cc_seq_fetch_NCs_next \
+ test_cc_seq_fetch_creds_begin \
+ test_cc_seq_fetch_creds_next \
+ test_cc_get_NC_info
+
TEST_OBJECTS = $(patsubst %,$(OBJDIR)/%.o,$(TEST_NAMES))
@@ -46,7 +102,7 @@ $(TEST_NAMES): $(TEST_OBJECTS)
$(CC) -o $(TESTDIR)/$@ $(OBJDIR)/$@.o $(OBJECTS) $(LIBS)
simple_lock_test:
- $(CC) -o $(TESTDIR)/simple_lock_test simple_lock_test.c $(LIBS)
+ $(CC) -o $(TESTDIR)/simple_lock_test simple_lock_test.c test_ccapi_log.c $(LIBS)
copy-script:
cp $(SCRIPT_NAME) $(DSTDIR)/$(SCRIPT_NAME)
diff --git a/src/ccapi/test/Makefile.in b/src/ccapi/test/Makefile.in
index e5238c2c7a..514b1d8832 100644
--- a/src/ccapi/test/Makefile.in
+++ b/src/ccapi/test/Makefile.in
@@ -38,6 +38,7 @@ OBJECTS = $(OUTPRE)test_ccapi_ccache.$(OBJEXT) \
$(OUTPRE)test_ccapi_check.$(OBJEXT) \
$(OUTPRE)test_ccapi_constants.$(OBJEXT) \
$(OUTPRE)test_ccapi_context.$(OBJEXT) \
+ $(OUTPRE)test_ccapi_v2.$(OBJEXT) \
$(OUTPRE)test_ccapi_globals.$(OBJEXT) \
$(OUTPRE)test_ccapi_iterators.$(OBJEXT) \
$(OUTPRE)test_ccapi_log.$(OBJEXT) \
@@ -53,7 +54,6 @@ TESTALLOBJS=$(OUTPRE)main.$(OBJEXT) \
TEST_NAMES = test_cc_ccache_iterator_next \
test_constants \
test_cc_initialize \
- test_cc_context_get_version \
test_cc_credentials_iterator_next
MORE_TESTS = test_cc_context_release \
@@ -82,7 +82,25 @@ MORE_TESTS = test_cc_context_release \
test_cc_ccache_compare \
test_cc_ccache_get_kdc_time_offset \
test_cc_ccache_set_kdc_time_offset \
- test_cc_ccache_clear_kdc_time_offset
+ test_cc_ccache_clear_kdc_time_offset \
+ test_cc_shutdown \
+ test_cc_get_change_time \
+ test_cc_open \
+ test_cc_create \
+ test_cc_close \
+ test_cc_destroy \
+ test_cc_get_cred_version \
+ test_cc_get_name \
+ test_cc_get_principal \
+ test_cc_set_principal \
+ test_cc_store \
+ test_cc_remove_cred \
+ test_cc_seq_fetch_NCs_begin \
+ test_cc_seq_fetch_NCs_next \
+ test_cc_seq_fetch_creds_begin \
+ test_cc_seq_fetch_creds_next \
+ test_cc_get_NC_info
+
##### Linker
LINK = link
diff --git a/src/ccapi/test/check_cc_destroy.c b/src/ccapi/test/check_cc_destroy.c
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/ccapi/test/check_cc_destroy.c
diff --git a/src/ccapi/test/main.c b/src/ccapi/test/main.c
index 995cb1c8b9..d48601003c 100644
--- a/src/ccapi/test/main.c
+++ b/src/ccapi/test/main.c
@@ -34,11 +34,11 @@ int main (int argc, const char * argv[]) {
err = check_cc_set_principal();
err = check_cc_store();
err = check_cc_remove_cred();
- //err = check_cc_seq_fetch_NCs_begin();
- //err = check_cc_seq_fetch_NCs_next();
- //err = check_cc_seq_fetch_creds_begin();
- //err = check_cc_seq_fetch_creds_next();
- //err = check_cc_get_NC_info();
+ err = check_cc_seq_fetch_NCs_begin();
+ err = check_cc_seq_fetch_NCs_next();
+ err = check_cc_seq_fetch_creds_begin();
+ err = check_cc_seq_fetch_creds_next();
+ err = check_cc_get_NC_info();
err = check_constants();
diff --git a/src/ccapi/test/simple_lock_test.c b/src/ccapi/test/simple_lock_test.c
index 26bd74ed90..418d56ad06 100644
--- a/src/ccapi/test/simple_lock_test.c
+++ b/src/ccapi/test/simple_lock_test.c
@@ -7,36 +7,41 @@
#include <stdio.h>
#include <stdarg.h>
-#include "cci_debugging.h"
+#include "test_ccapi_log.h"
+
+#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
+#include <TargetConditionals.h>
+#endif
#ifdef TARGET_OS_MAC
#include <stdlib.h>
+#include <pthread.h>
#include <Kerberos/CredentialsCache.h>
#else
#include "CredentialsCache.h"
#endif
-void * other_thread (void) {
+void *other_thread (void) {
cc_int32 err;
cc_context_t context = NULL;
err = cc_initialize(&context, ccapi_version_7, NULL, NULL);
- cci_debug_printf("thread: attempting lock. may hang. err == %d", err);
+ log_error("thread: attempting lock. may hang. err == %d", err);
if (!err) {
// hangs with cc_lock_read which should succeed immediately, but does not hang with write, upgrade, and downgrade, which fail immediately
err = cc_context_lock(context, cc_lock_read, cc_lock_noblock);
- }
+ }
if (context) {
cc_context_unlock(context);
cc_context_release(context);
context = NULL;
- }
- cci_debug_printf("thread: return. err == %d", err);
}
+ log_error("thread: return. err == %d", err);
+}
int main (int argc, char *argv[]) {
@@ -51,14 +56,14 @@ int main (int argc, char *argv[]) {
err = cc_initialize(&context, ccapi_version_7, NULL, NULL);
if (!err) {
err = cc_context_lock(context, cc_lock_read, cc_lock_noblock);
- }
+ }
- cci_debug_printf("main: initialized and read locked context. err == %d", err);
+ log_error("main: initialized and read locked context. err == %d", err);
#ifdef TARGET_OS_MAC
status = pthread_create (&thread_id, NULL, (void *) other_thread, NULL);
if (status != 0) {
- cci_debug_printf("Create error!");
+ log_error("pthread_create() returned %d", status);
exit(-1);
}
@@ -67,18 +72,20 @@ int main (int argc, char *argv[]) {
#endif
- cci_debug_printf("main: unlocking and releasing context. err == %d", err);
+ log_error("main: unlocking and releasing context. err == %d", err);
if (context) {
- cci_debug_printf("main: calling cc_context_unlock");
+ log_error("main: calling cc_context_unlock");
cc_context_unlock(context);
- cci_debug_printf("main: calling cc_context_release");
+ log_error("main: calling cc_context_release");
cc_context_release(context);
context = NULL;
- }
+ }
- cci_debug_printf("main: return. err == %d", err);
+ log_error("main: return. err == %d", err);
- UNREFERENCED_PARAMETER(status); // no whining!
+#if defined(_WIN32)
+ UNREFERENCED_PARAMETER(status); // no whining!
+#endif
return 0;
- } \ No newline at end of file
+}
diff --git a/src/ccapi/test/test_cc_close.c b/src/ccapi/test/test_cc_close.c
new file mode 100644
index 0000000000..b3a5bc2ef5
--- /dev/null
+++ b/src/ccapi/test/test_cc_close.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_close();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_create.c b/src/ccapi/test/test_cc_create.c
new file mode 100644
index 0000000000..d591d47be2
--- /dev/null
+++ b/src/ccapi/test/test_cc_create.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_create();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_destroy.c b/src/ccapi/test/test_cc_destroy.c
new file mode 100644
index 0000000000..13eae7b007
--- /dev/null
+++ b/src/ccapi/test/test_cc_destroy.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_destroy();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_get_NC_info.c b/src/ccapi/test/test_cc_get_NC_info.c
new file mode 100644
index 0000000000..fe72cbe35e
--- /dev/null
+++ b/src/ccapi/test/test_cc_get_NC_info.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_get_NC_info();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_get_change_time.c b/src/ccapi/test/test_cc_get_change_time.c
new file mode 100644
index 0000000000..8b031c1a31
--- /dev/null
+++ b/src/ccapi/test/test_cc_get_change_time.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_get_change_time();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_get_cred_version.c b/src/ccapi/test/test_cc_get_cred_version.c
new file mode 100644
index 0000000000..865abf00f4
--- /dev/null
+++ b/src/ccapi/test/test_cc_get_cred_version.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_get_cred_version();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_get_name.c b/src/ccapi/test/test_cc_get_name.c
new file mode 100644
index 0000000000..b4efa40fce
--- /dev/null
+++ b/src/ccapi/test/test_cc_get_name.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_get_name();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_get_principal.c b/src/ccapi/test/test_cc_get_principal.c
new file mode 100644
index 0000000000..f0078561dd
--- /dev/null
+++ b/src/ccapi/test/test_cc_get_principal.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_get_principal();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_open.c b/src/ccapi/test/test_cc_open.c
new file mode 100644
index 0000000000..d3253d8a3e
--- /dev/null
+++ b/src/ccapi/test/test_cc_open.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_open();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_remove_cred.c b/src/ccapi/test/test_cc_remove_cred.c
new file mode 100644
index 0000000000..121ad1b529
--- /dev/null
+++ b/src/ccapi/test/test_cc_remove_cred.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_remove_cred();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_seq_fetch_NCs_begin.c b/src/ccapi/test/test_cc_seq_fetch_NCs_begin.c
new file mode 100644
index 0000000000..0d08e9151f
--- /dev/null
+++ b/src/ccapi/test/test_cc_seq_fetch_NCs_begin.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_seq_fetch_NCs_begin();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_seq_fetch_NCs_next.c b/src/ccapi/test/test_cc_seq_fetch_NCs_next.c
new file mode 100644
index 0000000000..c941fd4fee
--- /dev/null
+++ b/src/ccapi/test/test_cc_seq_fetch_NCs_next.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_seq_fetch_NCs_next();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_seq_fetch_creds_begin.c b/src/ccapi/test/test_cc_seq_fetch_creds_begin.c
new file mode 100644
index 0000000000..16c0a72cba
--- /dev/null
+++ b/src/ccapi/test/test_cc_seq_fetch_creds_begin.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_seq_fetch_creds_begin();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_seq_fetch_creds_next.c b/src/ccapi/test/test_cc_seq_fetch_creds_next.c
new file mode 100644
index 0000000000..eaaf451c48
--- /dev/null
+++ b/src/ccapi/test/test_cc_seq_fetch_creds_next.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_seq_fetch_creds_next();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_set_principal.c b/src/ccapi/test/test_cc_set_principal.c
new file mode 100644
index 0000000000..bfe9162bf8
--- /dev/null
+++ b/src/ccapi/test/test_cc_set_principal.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_set_principal();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_shutdown.c b/src/ccapi/test/test_cc_shutdown.c
new file mode 100644
index 0000000000..31c3d7c57b
--- /dev/null
+++ b/src/ccapi/test/test_cc_shutdown.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_shutdown();
+ return err;
+}
diff --git a/src/ccapi/test/test_cc_store.c b/src/ccapi/test/test_cc_store.c
new file mode 100644
index 0000000000..7edc77715f
--- /dev/null
+++ b/src/ccapi/test/test_cc_store.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <limits.h>
+
+#include "test_ccapi_check.h"
+#include "test_ccapi_constants.h"
+#include "test_ccapi_v2.h"
+
+int main (int argc, const char * argv[]) {
+
+ cc_int32 err = ccNoError;
+ T_CCAPI_INIT;
+ err = check_cc_store();
+ return err;
+}
diff --git a/src/ccapi/test/test_ccapi.sh b/src/ccapi/test/test_ccapi.sh
index 9682e54467..c8959d688e 100644
--- a/src/ccapi/test/test_ccapi.sh
+++ b/src/ccapi/test/test_ccapi.sh
@@ -53,6 +53,24 @@ run_test test_cc_ccache_iterator_next
run_test test_cc_credentials_iterator_next
+run_test test_cc_shutdown
+run_test test_cc_get_change_time
+run_test test_cc_open
+run_test test_cc_create
+run_test test_cc_close
+run_test test_cc_destroy
+run_test test_cc_get_cred_version
+run_test test_cc_get_name
+run_test test_cc_get_principal
+run_test test_cc_set_principal
+run_test test_cc_store
+run_test test_cc_remove_cred
+run_test test_cc_seq_fetch_NCs_begin
+run_test test_cc_seq_fetch_NCs_next
+run_test test_cc_seq_fetch_creds_begin
+run_test test_cc_seq_fetch_creds_next
+run_test test_cc_get_NC_info
+
printf "\nFinished testing CCAPI. $failure_count failures in total.\n"
exit 0 \ No newline at end of file
diff --git a/src/ccapi/test/test_ccapi_ccache.c b/src/ccapi/test/test_ccapi_ccache.c
index 265804e677..64a70e3c2c 100644
--- a/src/ccapi/test/test_ccapi_ccache.c
+++ b/src/ccapi/test/test_ccapi_ccache.c
@@ -85,7 +85,7 @@ cc_int32 check_once_cc_ccache_release(cc_context_t context, cc_ccache_t ccache,
// ---------------------------------------------------------------------------
-int check_cc_ccache_destroy() {
+int check_cc_ccache_destroy(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -159,7 +159,7 @@ cc_int32 check_once_cc_ccache_destroy(cc_context_t context, cc_ccache_t ccache,
// ---------------------------------------------------------------------------
-int check_cc_ccache_set_default() {
+int check_cc_ccache_set_default(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -278,7 +278,7 @@ cc_int32 check_once_cc_ccache_set_default(cc_context_t context, cc_ccache_t ccac
// ---------------------------------------------------------------------------
-int check_cc_ccache_get_credentials_version() {
+int check_cc_ccache_get_credentials_version(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -397,7 +397,7 @@ cc_int32 check_once_cc_ccache_get_credentials_version(cc_ccache_t ccache, cc_uin
// ---------------------------------------------------------------------------
-int check_cc_ccache_get_name() {
+int check_cc_ccache_get_name(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -554,7 +554,7 @@ cc_int32 check_once_cc_ccache_get_principal(cc_ccache_t ccache,
// ---------------------------------------------------------------------------
-int check_cc_ccache_get_principal() {
+int check_cc_ccache_get_principal(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -626,7 +626,7 @@ int check_cc_ccache_get_principal() {
// ---------------------------------------------------------------------------
-int check_cc_ccache_set_principal() {
+int check_cc_ccache_set_principal(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -794,7 +794,7 @@ cc_int32 check_once_cc_ccache_set_principal(cc_ccache_t ccache, cc_uint32 cred_v
// ---------------------------------------------------------------------------
-int check_cc_ccache_store_credentials() {
+int check_cc_ccache_store_credentials(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -950,7 +950,7 @@ cc_int32 check_once_cc_ccache_store_credentials(cc_ccache_t ccache, const cc_cre
// ---------------------------------------------------------------------------
-int check_cc_ccache_remove_credentials() {
+int check_cc_ccache_remove_credentials(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -1104,7 +1104,7 @@ cc_int32 check_once_cc_ccache_remove_credentials(cc_ccache_t ccache, cc_credenti
// ---------------------------------------------------------------------------
-int check_cc_ccache_new_credentials_iterator() {
+int check_cc_ccache_new_credentials_iterator(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -1249,7 +1249,7 @@ cc_int32 check_once_cc_ccache_get_change_time(cc_ccache_t ccache, cc_time_t *las
// ---------------------------------------------------------------------------
-int check_cc_ccache_get_change_time() {
+int check_cc_ccache_get_change_time(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t dummy_ccache = NULL;
@@ -1417,7 +1417,7 @@ cc_int32 check_once_cc_ccache_get_last_default_time(cc_ccache_t ccache, cc_time_
// ---------------------------------------------------------------------------
-int check_cc_ccache_get_last_default_time() {
+int check_cc_ccache_get_last_default_time(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache_1 = NULL;
@@ -1509,7 +1509,7 @@ int check_cc_ccache_get_last_default_time() {
// ---------------------------------------------------------------------------
-int check_cc_ccache_move() {
+int check_cc_ccache_move(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t source = NULL;
@@ -1681,7 +1681,7 @@ cc_int32 check_once_cc_ccache_move(cc_ccache_t source, cc_ccache_t destination,
// ---------------------------------------------------------------------------
-int check_cc_ccache_compare() {
+int check_cc_ccache_compare(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache_a = NULL;
@@ -1780,7 +1780,7 @@ cc_int32 check_once_cc_ccache_compare(cc_ccache_t ccache, cc_ccache_t compare_to
// ---------------------------------------------------------------------------
-int check_cc_ccache_get_kdc_time_offset() {
+int check_cc_ccache_get_kdc_time_offset(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -1879,7 +1879,7 @@ cc_int32 check_once_cc_ccache_get_kdc_time_offset(cc_ccache_t ccache, cc_int32 c
// ---------------------------------------------------------------------------
-int check_cc_ccache_set_kdc_time_offset() {
+int check_cc_ccache_set_kdc_time_offset(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -1957,7 +1957,7 @@ cc_int32 check_once_cc_ccache_set_kdc_time_offset(cc_ccache_t ccache, cc_int32 c
// ---------------------------------------------------------------------------
-int check_cc_ccache_clear_kdc_time_offset() {
+int check_cc_ccache_clear_kdc_time_offset(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
diff --git a/src/ccapi/test/test_ccapi_globals.h b/src/ccapi/test/test_ccapi_globals.h
index a5c165df2e..fb2d5dbbd6 100644
--- a/src/ccapi/test/test_ccapi_globals.h
+++ b/src/ccapi/test/test_ccapi_globals.h
@@ -3,6 +3,10 @@
#include <krb5.h> // gets us TARGET_OS_MAC
+#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
+#include <TargetConditionals.h>
+#endif
+
#ifdef TARGET_OS_MAC
#include <Kerberos/CredentialsCache.h>
#else
diff --git a/src/ccapi/test/test_ccapi_iterators.c b/src/ccapi/test/test_ccapi_iterators.c
index 74f4fcab01..c3254fbb21 100644
--- a/src/ccapi/test/test_ccapi_iterators.c
+++ b/src/ccapi/test/test_ccapi_iterators.c
@@ -2,12 +2,10 @@
#include "test_ccapi_iterators.h"
#include "test_ccapi_check.h"
#include "test_ccapi_util.h"
-#include "cci_debugging.h"
-
// ---------------------------------------------------------------------------
-int check_cc_ccache_iterator_next() {
+int check_cc_ccache_iterator_next(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -56,7 +54,7 @@ int check_cc_ccache_iterator_next() {
}
for(i = 0; !err && (i < 1000); i++)
{
- if (i%10 == 0) cci_debug_printf("%s loop: %d", __FUNCTION__, i);
+ if (i%100 == 0) fprintf(stdout, ".");
err = cc_context_create_new_ccache(context, cc_credentials_v5, "foo@BAR.ORG", &ccache);
if (ccache) {
cc_ccache_release(ccache);
@@ -126,7 +124,7 @@ cc_int32 check_once_cc_ccache_iterator_next(cc_ccache_iterator_t iterator, cc_ui
// ---------------------------------------------------------------------------
-int check_cc_credentials_iterator_next() {
+int check_cc_credentials_iterator_next(void) {
cc_int32 err = 0;
cc_context_t context = NULL;
cc_ccache_t ccache = NULL;
@@ -188,8 +186,8 @@ int check_cc_credentials_iterator_next() {
err = cc_context_create_new_ccache(context, cc_credentials_v5, "foo@BAR.ORG", &ccache);
}
for(i = 0; !err && (i < 1000); i++) {
- if (i%10 == 0) cci_debug_printf("%s loop: %d", __FUNCTION__, i);
- new_v5_creds_union(&creds_union, "BAR.ORG");
+ if (i%100 == 0) fprintf(stdout, ".");
+ new_v5_creds_union(&creds_union, "BAR.ORG");
err = cc_ccache_store_credentials(ccache, &creds_union);
release_v5_creds_union(&creds_union);
}
diff --git a/src/ccapi/test/test_ccapi_log.h b/src/ccapi/test/test_ccapi_log.h
index 5c3cce0107..6305c1845f 100644
--- a/src/ccapi/test/test_ccapi_log.h
+++ b/src/ccapi/test/test_ccapi_log.h
@@ -9,9 +9,11 @@
_log_error(__FILE__, __LINE__, format , ## __VA_ARGS__)
void _log_error_v(const char *file, int line, const char *format, va_list ap);
-// void _log_error(const char *file, int line, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-void _log_error(const char *file, int line, const char *format, ...);
-
+void _log_error(const char *file, int line, const char *format, ...)
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+__attribute__ ((__format__ (__printf__, 3, 4)))
+#endif
+;
void test_header(const char *msg);
void test_footer(const char *msg, int err);
diff --git a/src/ccapi/test/test_ccapi_util.c b/src/ccapi/test/test_ccapi_util.c
index e2ad2b7d86..eb37868aec 100644
--- a/src/ccapi/test/test_ccapi_util.c
+++ b/src/ccapi/test/test_ccapi_util.c
@@ -4,7 +4,6 @@
#include <stdarg.h>
#include <stdlib.h>
-#include "k5-platform.h"
#include "test_ccapi_util.h"
diff --git a/src/ccapi/test/test_ccapi_v2.c b/src/ccapi/test/test_ccapi_v2.c
index a5ce3d9d67..20e09f2c49 100644
--- a/src/ccapi/test/test_ccapi_v2.c
+++ b/src/ccapi/test/test_ccapi_v2.c
@@ -8,7 +8,7 @@
// ---------------------------------------------------------------------------
static cc_result destroy_all_ccaches_v2(apiCB *context) {
- cc_result err = ccNoError;
+ cc_result err = CC_NOERROR;
infoNC **info = NULL;
int i = 0;
@@ -80,7 +80,7 @@ static cc_result new_v5_creds_union_compat (cred_union *out_union, const char *r
if (!err) {
v5creds = malloc (sizeof (*v5creds));
if (!v5creds) {
- err = ccErrNoMem;
+ err = CC_NOMEM;
}
}
@@ -88,7 +88,7 @@ static cc_result new_v5_creds_union_compat (cred_union *out_union, const char *r
asprintf(&client, "client@%s", realm);
asprintf(&server, "host/%d%s@%s", num_runs++, realm, realm);
if (!client || !server) {
- err = ccErrNoMem;
+ err = CC_NOMEM;
}
}
@@ -121,7 +121,7 @@ static cc_result new_v5_creds_union_compat (cred_union *out_union, const char *r
creds_union->cred_type = CC_CRED_V5;
creds_union->cred.pV5Cred = v5creds;
} else {
- err = ccErrNoMem;
+ err = CC_NOMEM;
}
}
if (!err) {
@@ -248,7 +248,7 @@ int check_cc_get_change_time(void) {
check_once_cc_get_change_time(context, &last_change_time, CC_NOERROR, "after creating a new ccache");
if (!err) {
- // change principal (fails with ccErrBadInternalMessage)
+ // change principal
err = cc_set_principal(context, ccache, CC_CRED_V5, "foo@BAR.ORG");
if (err) {
log_error("failed to change ccache's principal - %s (%d)", translate_ccapi_error(err), err);
@@ -1184,9 +1184,9 @@ cc_result check_once_cc_store(apiCB *context, ccache_p *ccache, const cred_union
if (creds) { cc_free_creds(context, &creds); }
}
- if (err == ccIteratorEnd) {
+ if (err == CC_END) {
check_if(found, "stored credentials not found in ccache");
- err = ccNoError;
+ err = CC_NOERROR;
}
if (iterator) { cc_seq_fetch_creds_end(context, &iterator); }
@@ -1239,7 +1239,7 @@ int check_cc_remove_cred(void) {
creds_array[i] = NULL;
err = cc_seq_fetch_creds_next(context, &creds_array[i], iterator);
}
- if (err == ccIteratorEnd) { err = ccNoError; }
+ if (err == CC_END) { err = CC_NOERROR; }
// remove 10 valid creds
for (i = 0; !err && (i < 10); i++) {
@@ -1322,9 +1322,9 @@ cc_result check_once_cc_remove_cred(apiCB *context, ccache_p *ccache, cred_union
if (creds) { cc_free_creds(context, &creds); }
}
- if (err == ccIteratorEnd) {
- check_if(!found, "credentials not removed from ccache");
- err = ccNoError;
+ if (err == CC_END) {
+ check_if(found, "credentials not removed from ccache");
+ err = CC_NOERROR;
}
if (iterator) { cc_seq_fetch_creds_end(context, &iterator); }
@@ -1333,3 +1333,507 @@ cc_result check_once_cc_remove_cred(apiCB *context, ccache_p *ccache, cred_union
return err;
}
+
+// ---------------------------------------------------------------------------
+
+int check_cc_seq_fetch_NCs_begin(void) {
+ cc_result err = 0;
+ apiCB *context = NULL;
+ ccache_p *ccache = NULL;
+ ccache_cit *iterator = NULL;
+
+ BEGIN_TEST("cc_seq_fetch_NCs_begin");
+
+ err = cc_initialize(&context, ccapi_version_2, NULL, NULL);
+ if (!err) {
+ err = destroy_all_ccaches_v2(context);
+ }
+ if (!err) {
+ // try making when there are no existing ccaches (shouldn't make a difference, but just in case)
+ check_once_cc_seq_fetch_NCs_begin(context, &iterator, CC_NOERROR, "when there are no existing ccaches");
+
+ err = cc_create(context, "TEST_CC_SEQ_FETCH_NCS_BEGIN", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+ if (!err) {
+ // try making when at least one ccache already exists (just to cover all our bases)
+ check_once_cc_seq_fetch_NCs_begin(context, &iterator, CC_NOERROR, "when at least one ccache already exists");
+
+ // try bad parameters
+ check_once_cc_seq_fetch_NCs_begin(context, NULL, CC_BAD_PARM, "NULL param"); // NULL iterator
+ }
+ // we'll do a comprehensive test of cc_ccache_iterator related functions later in the test suite
+
+ if (ccache ) { cc_close(context, &ccache); }
+ if (context) { cc_shutdown(&context); }
+
+ END_TEST_AND_RETURN
+}
+
+// ---------------------------------------------------------------------------
+
+cc_result check_once_cc_seq_fetch_NCs_begin(apiCB *context, ccache_cit **iterator, cc_result expected_err, const char *description) {
+ cc_result err = CC_NOERROR;
+
+ cc_result possible_return_values[4] = {
+ CC_NOERROR,
+ CC_BAD_PARM,
+ CC_NOMEM,
+ CC_NO_EXIST
+ };
+
+ BEGIN_CHECK_ONCE(description);
+
+#define possible_ret_val_count sizeof(possible_return_values)/sizeof(possible_return_values[0])
+
+ err = cc_seq_fetch_NCs_begin(context, iterator);
+
+ // check returned error
+ check_err(err, expected_err, possible_return_values);
+
+ // we'll do a comprehensive test of cc_ccache_iterator related functions later
+
+ return err;
+}
+
+// ---------------------------------------------------------------------------
+
+int check_cc_seq_fetch_NCs_next(void) {
+ cc_result err = 0;
+ apiCB *context = NULL;
+ ccache_p *ccache = NULL;
+ ccache_cit *iterator = NULL;
+ unsigned int i;
+
+ BEGIN_TEST("cc_seq_fetch_NCs_next");
+
+ err = cc_initialize(&context, ccapi_version_2, NULL, NULL);
+
+ if (!err) {
+ err = destroy_all_ccaches_v2(context);
+ }
+
+ // iterate with no ccaches
+ if (!err) {
+ err = cc_seq_fetch_NCs_begin(context, &iterator);
+ }
+ check_once_cc_seq_fetch_NCs_next(context, iterator, 0, CC_NOERROR, "iterating over an empty collection");
+ if (iterator) {
+ cc_seq_fetch_creds_end(context, &iterator);
+ iterator = NULL;
+ }
+
+ // iterate with one ccache
+ if (!err) {
+ destroy_all_ccaches_v2(context);
+ err = cc_create(context, "TEST_CC_SEQ_FETCH_NCS_NEXT", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+ if (ccache) {
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+ if (!err) {
+ err = cc_seq_fetch_NCs_begin(context, &iterator);
+ }
+ check_once_cc_seq_fetch_NCs_next(context, iterator, 1, CC_NOERROR, "iterating over a collection of 1 ccache");
+ if (iterator) {
+ cc_seq_fetch_creds_end(context, &iterator);
+ iterator = NULL;
+ }
+
+ // iterate with several ccaches
+ if (!err) {
+ destroy_all_ccaches_v2(context);
+ }
+ for(i = 0; !err && (i < 1000); i++)
+ {
+ char *name = NULL;
+
+ if (i%100 == 0) fprintf(stdout, ".");
+ asprintf (&name, "TEST_CC_SEQ_FETCH_NCS_NEXT_%d", i);
+ err = cc_create(context, name, "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ if (ccache) {
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+ free (name);
+ }
+ if (!err) {
+ err = cc_seq_fetch_NCs_begin(context, &iterator);
+ }
+ check_once_cc_seq_fetch_NCs_next(context, iterator, 1000, CC_NOERROR, "iterating over a collection of 1000 ccache");
+ if (iterator) {
+ cc_seq_fetch_creds_end(context, &iterator);
+ iterator = NULL;
+ }
+
+
+ if (ccache) { cc_close(context, &ccache); }
+ if (iterator) { cc_seq_fetch_creds_end(context, &iterator); }
+ if (context) {
+ destroy_all_ccaches_v2(context);
+ cc_shutdown(&context);
+ }
+
+ END_TEST_AND_RETURN
+}
+
+// ---------------------------------------------------------------------------
+
+cc_result check_once_cc_seq_fetch_NCs_next(apiCB *context, ccache_cit *iterator, cc_uint32 expected_count, cc_result expected_err, const char *description) {
+ cc_result err = CC_NOERROR;
+
+ BEGIN_CHECK_ONCE(description);
+
+ cc_result possible_return_values[5] = {
+ CC_NOERROR,
+ CC_END,
+ CC_BAD_PARM,
+ CC_NOMEM,
+ CC_NO_EXIST
+ };
+#define possible_ret_val_count sizeof(possible_return_values)/sizeof(possible_return_values[0])
+
+ ccache_p *ccache = NULL;
+ cc_uint32 actual_count = 0;
+
+ while (!err) {
+ err = cc_seq_fetch_NCs_next(context, &ccache, iterator);
+ if (ccache) {
+ actual_count++;
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+ }
+ if (err == CC_END) {
+ err = CC_NOERROR;
+ }
+
+ // check returned error
+ check_err(err, expected_err, possible_return_values);
+
+ check_if(actual_count != expected_count, "iterator didn't iterate over all ccaches");
+
+ END_CHECK_ONCE;
+
+ return err;
+}
+
+// ---------------------------------------------------------------------------
+
+int check_cc_get_NC_info(void) {
+ cc_result err = 0;
+ apiCB *context = NULL;
+ ccache_p *ccache = NULL;
+ unsigned int i;
+
+ BEGIN_TEST("cc_get_NC_info");
+
+ err = cc_initialize(&context, ccapi_version_2, NULL, NULL);
+
+ if (!err) {
+ err = destroy_all_ccaches_v2(context);
+ }
+
+ // iterate with no ccaches
+ check_once_cc_get_NC_info(context, "", "", CC_CRED_MAX, 0, CC_NOERROR, "iterating over an empty collection");
+
+ // iterate with one ccache
+ if (!err) {
+ destroy_all_ccaches_v2(context);
+ err = cc_create(context, "TEST_CC_GET_NC_INFO", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+ if (ccache) {
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+ check_once_cc_get_NC_info(context, "TEST_CC_GET_NC_INFO", "foo@BAR.ORG", CC_CRED_V5, 1, CC_NOERROR, "iterating over a collection of 1 ccache");
+
+ // iterate with several ccaches
+ if (!err) {
+ destroy_all_ccaches_v2(context);
+ }
+ for(i = 0; !err && (i < 1000); i++)
+ {
+ char *name = NULL;
+
+ if (i%100 == 0) fprintf(stdout, ".");
+ asprintf (&name, "TEST_CC_GET_NC_INFO_%d", i);
+ err = cc_create(context, name, "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ if (ccache) {
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+ free (name);
+ }
+ check_once_cc_get_NC_info(context, "TEST_CC_GET_NC_INFO", "foo@BAR.ORG", CC_CRED_V5, 1000, CC_NOERROR, "iterating over a collection of 1000 ccache");
+
+ if (ccache) { cc_close(context, &ccache); }
+ if (context) {
+ destroy_all_ccaches_v2(context);
+ cc_shutdown(&context);
+ }
+
+ END_TEST_AND_RETURN
+}
+
+// ---------------------------------------------------------------------------
+
+cc_result check_once_cc_get_NC_info(apiCB *context,
+ const char *expected_name_prefix,
+ const char *expected_principal,
+ cc_int32 expected_version,
+ cc_uint32 expected_count,
+ cc_result expected_err,
+ const char *description) {
+ cc_result err = CC_NOERROR;
+ infoNC **info = NULL;
+
+ BEGIN_CHECK_ONCE(description);
+
+ cc_result possible_return_values[4] = {
+ CC_NOERROR,
+ CC_BAD_PARM,
+ CC_NOMEM,
+ CC_NO_EXIST
+ };
+#define possible_ret_val_count sizeof(possible_return_values)/sizeof(possible_return_values[0])
+
+ cc_uint32 actual_count = 0;
+
+ err = cc_get_NC_info(context, &info);
+
+ for (actual_count = 0; !err && info[actual_count]; actual_count++) {
+ check_if(strncmp(info[actual_count]->name, expected_name_prefix, strlen(expected_name_prefix)), "got incorrect ccache name");
+ check_if(strcmp(info[actual_count]->principal, expected_principal), "got incorrect principal name");
+ check_if(info[actual_count]->vers != expected_version, "got incorrect cred version");
+ }
+
+ // check returned error
+ check_err(err, expected_err, possible_return_values);
+
+ check_if(actual_count != expected_count, "NC info didn't list all ccaches");
+
+ if (info) { cc_free_NC_info (context, &info); }
+ END_CHECK_ONCE;
+
+ return err;
+}
+
+// ---------------------------------------------------------------------------
+
+int check_cc_seq_fetch_creds_begin(void) {
+ cc_result err = 0;
+ apiCB *context = NULL;
+ ccache_p *ccache = NULL;
+ ccache_p *dup_ccache = NULL;
+ ccache_cit *creds_iterator = NULL;
+ char *name = NULL;
+
+ BEGIN_TEST("cc_seq_fetch_creds_begin");
+
+ err = cc_initialize(&context, ccapi_version_2, NULL, NULL);
+
+ if (!err) {
+ err = destroy_all_ccaches_v2(context);
+ }
+
+ if (!err) {
+ err = cc_create(context, "TEST_CC_SEQ_FETCH_CREDS_BEGIN", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+
+ // valid params
+ if (!err) {
+ check_once_cc_seq_fetch_creds_begin(context, ccache, &creds_iterator, CC_NOERROR, "valid params");
+ }
+ if (creds_iterator) {
+ cc_seq_fetch_creds_end(context, &creds_iterator);
+ creds_iterator = NULL;
+ }
+
+ // NULL out param
+ if (!err) {
+ check_once_cc_seq_fetch_creds_begin(context, ccache, NULL, CC_BAD_PARM, "NULL out iterator param");
+ }
+ if (creds_iterator) {
+ cc_seq_fetch_creds_end(context, &creds_iterator);
+ creds_iterator = NULL;
+ }
+
+ // non-existent ccache
+ if (ccache) {
+ err = cc_get_name(context, ccache, &name);
+ if (!err) {
+ err = cc_open(context, name, CC_CRED_V5, 0, &dup_ccache);
+ }
+ if (name) { cc_free_name(context, &name); }
+ if (dup_ccache) { cc_destroy(context, &dup_ccache); }
+ }
+
+ if (!err) {
+ check_once_cc_seq_fetch_creds_begin(context, ccache, &creds_iterator, CC_NO_EXIST, "invalid ccache");
+ }
+
+ if (creds_iterator) {
+ cc_seq_fetch_creds_end(context, &creds_iterator);
+ creds_iterator = NULL;
+ }
+ if (ccache) { cc_close(context, &ccache); }
+ if (context) {
+ destroy_all_ccaches_v2(context);
+ cc_shutdown(&context);
+ }
+
+ END_TEST_AND_RETURN
+}
+
+// ---------------------------------------------------------------------------
+
+cc_result check_once_cc_seq_fetch_creds_begin(apiCB *context, ccache_p *ccache, ccache_cit **iterator, cc_result expected_err, const char *description) {
+ cc_result err = CC_NOERROR;
+
+ cc_result possible_return_values[5] = {
+ CC_NOERROR,
+ CC_BAD_PARM,
+ CC_NOMEM,
+ CC_NO_EXIST
+ };
+
+ BEGIN_CHECK_ONCE(description);
+
+#define possible_ret_val_count sizeof(possible_return_values)/sizeof(possible_return_values[0])
+
+ err = cc_seq_fetch_creds_begin(context, ccache, iterator);
+
+ // check returned error
+ check_err(err, expected_err, possible_return_values);
+
+ END_CHECK_ONCE;
+
+ return err;
+}
+
+// ---------------------------------------------------------------------------
+
+int check_cc_seq_fetch_creds_next(void) {
+ cc_result err = 0;
+ apiCB *context = NULL;
+ ccache_p *ccache = NULL;
+ cred_union creds_union;
+ ccache_cit *iterator = NULL;
+ unsigned int i;
+
+ BEGIN_TEST("cc_seq_fetch_creds_next");
+
+ err = cc_initialize(&context, ccapi_version_2, NULL, NULL);
+
+ if (!err) {
+ err = destroy_all_ccaches_v2(context);
+ }
+
+ // iterate with no creds
+ if (!err) {
+ err = cc_create(context, "TEST_CC_SEQ_FETCH_CREDS_NEXT", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+ if (!err) {
+ err = cc_seq_fetch_creds_begin(context, ccache, &iterator);
+ }
+ check_once_cc_seq_fetch_creds_next(context, iterator, 0, CC_NOERROR, "iterating over an empty ccache");
+ if (iterator) {
+ cc_seq_fetch_creds_end(context, &iterator);
+ iterator = NULL;
+ }
+ if (ccache) {
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+
+ // iterate with one cred
+ if (!err) {
+ destroy_all_ccaches_v2(context);
+ err = cc_create(context, "TEST_CC_SEQ_FETCH_CREDS_NEXT", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+ if (!err) {
+ new_v5_creds_union_compat(&creds_union, "BAR.ORG");
+ err = cc_store(context, ccache, creds_union);
+ release_v5_creds_union_compat(&creds_union);
+ }
+ if (!err) {
+ err = cc_seq_fetch_creds_begin(context, ccache, &iterator);
+ }
+ check_once_cc_seq_fetch_creds_next(context, iterator, 1, CC_NOERROR, "iterating over a ccache with 1 cred");
+ if (iterator) {
+ cc_seq_fetch_creds_end(context, &iterator);
+ iterator = NULL;
+ }
+ if (ccache) {
+ cc_close(context, &ccache);
+ ccache = NULL;
+ }
+
+ // iterate with several creds
+ if (!err) {
+ destroy_all_ccaches_v2(context);
+ err = cc_create(context, "TEST_CC_SEQ_FETCH_CREDS_NEXT", "foo@BAR.ORG", CC_CRED_V5, 0, &ccache);
+ }
+ for(i = 0; !err && (i < 1000); i++) {
+ if (i%100 == 0) fprintf(stdout, ".");
+ new_v5_creds_union_compat(&creds_union, "BAR.ORG");
+ err = cc_store(context, ccache, creds_union);
+ release_v5_creds_union_compat(&creds_union);
+ }
+ if (!err) {
+ err = cc_seq_fetch_creds_begin(context, ccache, &iterator);
+ }
+ check_once_cc_seq_fetch_creds_next(context, iterator, 1000, CC_NOERROR, "iterating over a ccache with 1000 creds");
+
+ if (ccache) { cc_close(context, &ccache); }
+ if (iterator) { cc_seq_fetch_creds_end(context, &iterator); }
+ if (context) {
+ destroy_all_ccaches_v2(context);
+ cc_shutdown(&context);
+ }
+
+ END_TEST_AND_RETURN
+}
+
+// ---------------------------------------------------------------------------
+
+cc_result check_once_cc_seq_fetch_creds_next(apiCB *context, ccache_cit *iterator, cc_uint32 expected_count, cc_result expected_err, const char *description) {
+ cc_result err = CC_NOERROR;
+ cred_union *creds = NULL;
+ cc_uint32 actual_count = 0;
+
+ cc_result possible_return_values[5] = {
+ CC_NOERROR,
+ CC_END,
+ CC_BAD_PARM,
+ CC_NOMEM,
+ CC_NO_EXIST,
+ };
+
+ BEGIN_CHECK_ONCE(description);
+
+#define possible_ret_val_count sizeof(possible_return_values)/sizeof(possible_return_values[0])
+
+ while (!err) {
+ err = cc_seq_fetch_creds_next(context, &creds, iterator);
+ if (creds) {
+ actual_count++;
+ cc_free_creds(context, &creds);
+ creds = NULL;
+ }
+ }
+ if (err == CC_END) {
+ err = CC_NOERROR;
+ }
+
+ // check returned error
+ check_err(err, expected_err, possible_return_values);
+
+ check_if(actual_count != expected_count, "iterator didn't iterate over all ccaches");
+
+ END_CHECK_ONCE;
+
+ return err;
+}
+
diff --git a/src/ccapi/test/test_ccapi_v2.h b/src/ccapi/test/test_ccapi_v2.h
index 4596bb5d6b..55abdffde1 100644
--- a/src/ccapi/test/test_ccapi_v2.h
+++ b/src/ccapi/test/test_ccapi_v2.h
@@ -48,4 +48,26 @@ cc_result check_once_cc_store(apiCB *context, ccache_p *ccache, const cred_union
int check_cc_remove_cred(void);
cc_result check_once_cc_remove_cred(apiCB *context, ccache_p *ccache, cred_union in_creds, cc_int32 expected_err, const char *description);
+
+int check_cc_seq_fetch_NCs_begin(void);
+cc_result check_once_cc_seq_fetch_NCs_begin(apiCB *context, ccache_cit **iterator, cc_result expected_err, const char *description);
+
+int check_cc_seq_fetch_NCs_next(void);
+cc_result check_once_cc_seq_fetch_NCs_next(apiCB *context, ccache_cit *iterator, cc_uint32 expected_count, cc_result expected_err, const char *description);
+
+int check_cc_get_NC_info(void);
+cc_result check_once_cc_get_NC_info(apiCB *context,
+ const char *expected_name,
+ const char *expected_principal,
+ cc_int32 expected_version,
+ cc_uint32 expected_count,
+ cc_result expected_err,
+ const char *description);
+
+int check_cc_seq_fetch_creds_begin(void);
+cc_result check_once_cc_seq_fetch_creds_begin(apiCB *context, ccache_p *ccache, ccache_cit **iterator, cc_result expected_err, const char *description);
+
+int check_cc_seq_fetch_creds_next(void);
+cc_result check_once_cc_seq_fetch_creds_next(apiCB *context, ccache_cit *iterator, cc_uint32 expected_count, cc_result expected_err, const char *description);
+
#endif /* _TEST_CCAPI_V2_H_ */
diff --git a/src/ccapi/test/untitled b/src/ccapi/test/untitled
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/ccapi/test/untitled