Hi Team,
I went thru Kamen's old tests for the torture test suite and noted one commit
that might be usable in the new mapitest suite. This is my attempt to add a
negative test for NspiResolveName function. I think i am missing the
interpretation of flaglist parameter that seems the one in which the result of
the test is returned, but this also is true for the test case that was already
there, so i am not sure what to do with that. Anyway, i don't have exchange
machine here, so i only tested this against OpenChange setup, if i should
change something please write back.
Regards, Anatoliy
Index: utils/mapitest/modules/module_nspi.c
===================================================================
--- utils/mapitest/modules/module_nspi.c (revision 2368)
+++ utils/mapitest/modules/module_nspi.c (working copy)
@@ -939,12 +939,16 @@
struct SRowSet *SRowSet = NULL;
struct SPropTagArray *flaglist = NULL;
const char *username[2];
+ const char *username_err[2];
nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
/* Build the username array */
username[0] = (const char *)mt->profile->mailbox;
username[1] = NULL;
+ /* Build the err username array */
+ username_err[0] = talloc_asprintf(mt->mem_ctx, "%s%s", mt->info.szDNPrefix, "nspi_resolve_testcase");
+ username_err[1] = NULL;
SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0xd,
PR_ENTRYID,
@@ -961,13 +965,14 @@
PR_TRANSMITTABLE_DISPLAY_NAME,
PR_7BIT_DISPLAY_NAME);
+ /* Test with existing username */
/* NspiResolveNames (0x13) */
flaglist = talloc_zero(mt->mem_ctx, struct SPropTagArray);
SRowSet = talloc_zero(mt->mem_ctx, struct SRowSet);
retval = ResolveNames(mt->session, (const char **)username, SPropTagArray, &SRowSet, &flaglist, 0);
if (retval != MAPI_E_SUCCESS) {
- mapitest_print_retval_clean(mt, "NspiResolveNames", retval);
+ mapitest_print_retval_clean(mt, "NspiResolveNames - existing", retval);
MAPIFreeBuffer(SPropTagArray);
talloc_free(flaglist);
talloc_free(SRowSet);
@@ -975,12 +980,11 @@
}
talloc_free(flaglist);
talloc_free(SRowSet);
- mapitest_print_retval(mt, "NspiResolveNames");
+ mapitest_print_retval(mt, "NspiResolveNames - existing");
/* NspiResolveNamesW (0x14) */
retval = ResolveNames(mt->session, (const char **)username, SPropTagArray, &SRowSet, &flaglist, MAPI_UNICODE);
- MAPIFreeBuffer(SPropTagArray);
- mapitest_print_retval_clean(mt, "NspiResolveNamesW", retval);
+ mapitest_print_retval_clean(mt, "NspiResolveNamesW - existing", retval);
if (retval != MAPI_E_SUCCESS) {
talloc_free(flaglist);
talloc_free(SRowSet);
@@ -989,6 +993,34 @@
talloc_free(flaglist);
talloc_free(SRowSet);
+ /* Test with non existing username */
+ /* NspiResolveNames (0x13) */
+ flaglist = talloc_zero(mt->mem_ctx, struct SPropTagArray);
+ SRowSet = talloc_zero(mt->mem_ctx, struct SRowSet);
+
+ retval = ResolveNames(mt->session, (const char **)username_err, SPropTagArray, &SRowSet, &flaglist, 0);
+ if (retval != MAPI_E_SUCCESS) {
+ mapitest_print_retval_clean(mt, "NspiResolveNames - non existing", retval);
+ MAPIFreeBuffer(SPropTagArray);
+ talloc_free(flaglist);
+ talloc_free(SRowSet);
+ return false;
+ }
+ talloc_free(flaglist);
+ talloc_free(SRowSet);
+ mapitest_print_retval(mt, "NspiResolveNames - non existing");
+
+ /* NspiResolveNamesW (0x14) */
+ retval = ResolveNames(mt->session, (const char **)username_err, SPropTagArray, &SRowSet, &flaglist, MAPI_UNICODE);
+ mapitest_print_retval_clean(mt, "NspiResolveNamesW - non existing", retval);
+ if (retval != MAPI_E_SUCCESS) {
+ talloc_free(flaglist);
+ talloc_free(SRowSet);
+ return false;
+ }
+ talloc_free(flaglist);
+ talloc_free(SRowSet);
+
return true;
}
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel