Пример #1
0
static bool mapitest_no_server_props_mv_i2(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;
	struct ShortArray_r shortarray;
	const struct ShortArray_r *shortarrayget;

	// create and initialise shortarray
	shortarray.cValues = 3;
	shortarray.lpi = talloc_array(mt->mem_ctx, uint16_t, shortarray.cValues);
	shortarray.lpi[0] = 0x1245;
	shortarray.lpi[1] = 0x3498;
	shortarray.lpi[2] = 0x5675;
	res = set_SPropValue_proptag(&propvalue, PT_MV_SHORT, &shortarray);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_MV_SHORT");
		return false;
	}
	shortarrayget = (const struct ShortArray_r *)get_SPropValue_data(&propvalue);
	if (!shortarrayget || (shortarray.cValues != shortarrayget->cValues) || (shortarray.lpi != shortarrayget->lpi)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_MV_SHORT");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_MV_SHORT");

	talloc_free(shortarray.lpi);

	return true;
}
Пример #2
0
static bool mapitest_no_server_props_mv_string8(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;
	struct StringArray_r stringarray;
	const struct StringArray_r *stringarrayget;

	// create and initialise stringarray
	stringarray.cValues = 4;
	stringarray.lppszA = talloc_array(mt->mem_ctx, const char*, stringarray.cValues);
	stringarray.lppszA[0] = "Fedora";
	stringarray.lppszA[1] = "FreeBSD";
	stringarray.lppszA[2] = "OpenSolaris";
	stringarray.lppszA[3] = "Debian";

	res = set_SPropValue_proptag(&propvalue, PT_MV_STRING8, &stringarray);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_MV_STRING8");
		return false;
	}
	stringarrayget = (const struct StringArray_r *)get_SPropValue_data(&propvalue);
	if (!stringarrayget || (stringarray.cValues != stringarrayget->cValues) || (stringarray.lppszA != stringarrayget->lppszA)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_MV_STRING8");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_MV_STRING8");

	talloc_free(stringarray.lppszA);

	return true;
}
Пример #3
0
static bool mapitest_no_server_props_mv_i4(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;
	struct LongArray_r longarray;
	const struct LongArray_r *longarrayget;

	// create and initialise longarray
	longarray.cValues = 2;
	longarray.lpl = talloc_array(mt->mem_ctx, uint32_t, longarray.cValues);
	longarray.lpl[0] = 0x34124543;
	longarray.lpl[1] = 0x88567576;
	res = set_SPropValue_proptag(&propvalue, PT_MV_LONG, &longarray);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_MV_LONG");
		return false;
	}
	longarrayget = (const struct LongArray_r *)get_SPropValue_data(&propvalue);
	if (!longarrayget || (longarray.cValues != longarrayget->cValues) || (longarray.lpl != longarrayget->lpl)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_MV_LONG");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_MV_LONG");

	talloc_free(longarray.lpl);

	return true;
}
Пример #4
0
static bool mapitest_no_server_props_mv_unicode(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;
	struct StringArrayW_r unicodearray;
	const struct StringArrayW_r *unicodearrayget;

	// create and initialise unicodearray
	unicodearray.cValues = 4;
	unicodearray.lppszW = talloc_array(mt->mem_ctx, const char*, unicodearray.cValues);
	unicodearray.lppszW[0] = "Fedora";  /* not valid UTF16, but should still be OK */
	unicodearray.lppszW[1] = "FreeBSD";
	unicodearray.lppszW[2] = "OpenSolaris";
	unicodearray.lppszW[3] = "Debian";

	res = set_SPropValue_proptag(&propvalue, PT_MV_UNICODE, &unicodearray);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_MV_UNICODE");
		return false;
	}
	unicodearrayget = (const struct StringArrayW_r *)get_SPropValue_data(&propvalue);
	if (!unicodearrayget || (unicodearray.cValues != unicodearrayget->cValues) || (unicodearray.lppszW != unicodearrayget->lppszW)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_MV_UNICODE");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_MV_UNICODE");

	talloc_free(unicodearray.lppszW);

	return true;
}
Пример #5
0
/**
     \details Test the get_proptag_value() function

   This function:
   -# Checks the first value in the list
   -# Checks a random value from the list
   -# Checks the last value in the list
   -# Checks a value that doesn't exist

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
*/
_PUBLIC_ bool mapitest_noserver_proptagvalue(struct mapitest *mt) 
{
	uint32_t proptag;
	
	proptag = get_proptag_value("PidTagTemplateData");
	if (proptag != PidTagTemplateData) {
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "get_proptag_value with PidTagTemplateData");
		return false;
	}

	proptag = get_proptag_value("PidTagDelegatedByRule");
	if (proptag != PidTagDelegatedByRule) {
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "get_proptag_value with PidTagDelegatedByRule");
		return false;
	}

	proptag = get_proptag_value("PidTagAddressBookContainerId_Error");
	if (proptag != PidTagAddressBookContainerId_Error) {
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "get_proptag_value with PidTagAddressBookContainerId_Error");
		return false;
	}

	proptag = get_proptag_value("No such tag, ok?");
	if (proptag != 0) {
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "get_proptag_value with non-existent tag");
		return false;
	}

	return true;
}
Пример #6
0
static bool mapitest_no_server_props_mv_filetime(struct mapitest *mt)
{
	struct SPropValue propvalue;
	struct FILETIME ft1, ft2, ft3;
	struct DateTimeArray_r ftarray;
	const struct DateTimeArray_r *ftarrayget;

	ft1.dwLowDateTime = 0x12345678;
	ft1.dwHighDateTime = 0x87653491;
	ft2.dwLowDateTime = 0x10234324;
	ft2.dwHighDateTime = 0x98748756;
	ft3.dwLowDateTime = 0x53245324;
	ft3.dwHighDateTime = 0x54324633;

	ftarray.cValues = 3;
	ftarray.lpft = talloc_array(mt->mem_ctx, struct FILETIME, ftarray.cValues);
	ftarray.lpft[0] = ft1;
	ftarray.lpft[1] = ft2;
	ftarray.lpft[2] = ft3;

	set_SPropValue_proptag(&propvalue, PT_MV_SYSTIME, &ftarray);
	ftarrayget = (const struct DateTimeArray_r *)get_SPropValue_data(&propvalue);
	if (!ftarrayget || (ftarray.cValues != ftarrayget->cValues) || (ftarray.lpft != ftarrayget->lpft)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_MV_SYSTIME");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_MV_SYSTIME");

	talloc_free(ftarray.lpft);

	return true;
}
Пример #7
0
static bool mapitest_no_server_props_bin(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;

	struct Binary_r bin;
	const struct Binary_r *binget;
	uint32_t	i;

	// initialise bin
	bin.cb = 8;
	bin.lpb = talloc_array(mt->mem_ctx, uint8_t, bin.cb);
	for (i = 0; i < bin.cb; ++i) {
		bin.lpb[i] = 0xF0 + i;
	}

	res = set_SPropValue_proptag(&propvalue, PT_BINARY, &bin);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_BINARY");
		return false;
	}
	binget = (const struct Binary_r *)get_SPropValue_data(&propvalue);
	if (!binget || (bin.cb != binget->cb) || (bin.lpb != binget->lpb)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_BINARY");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_BINARY");

	talloc_free(bin.lpb);

	return true;
}
Пример #8
0
/**
   \details Test the QueryColumns (0x37) operation

   This function:
   	-# Opens the Inbox folder and gets the hierarchy table
	-# Calls the QueryColumn operation
	-# Calls SetColumns on the test folder
	-# Checks that QueryColumns on the test folder is correct
	-# Cleans up

   \param mt pointer to the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_oxctable_QueryColumns(struct mapitest *mt)
{
	mapi_object_t		obj_htable;
	mapi_object_t		obj_test_folder;
	struct SPropTagArray	columns;
	struct mt_common_tf_ctx	*context;
	uint32_t		count;

	/* Step 1. Logon */
	if (! mapitest_common_setup(mt, &obj_htable, NULL)) {
		return false;
	}

	/* Step 2. QueryColumns */
	QueryColumns(&obj_htable, &columns);
	mapitest_print_retval(mt, "QueryColumns");
	if (GetLastError() != MAPI_E_SUCCESS) {
		return false;
	}

	/* Step 3. Get the test folder */
	context = mt->priv;
	mapi_object_init(&(obj_test_folder));
	GetContentsTable(&(context->obj_test_folder), &(obj_test_folder), 0, &count);
	mapitest_print_retval(mt, "GetContentsTable");
	if (GetLastError() != MAPI_E_SUCCESS) {
		return false;
	}
	if (count != 10) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "GetContentsTable", count);
		/* This isn't a hard error for this test though, because it might be from a 
		   previous test failure. Clean up and try again */
	}


	/* Step 4. QueryColumns on a contents folder */
	QueryColumns(&(obj_test_folder), &columns);
	mapitest_print_retval(mt, "QueryColumns");
	if (GetLastError() != MAPI_E_SUCCESS) {
		return false;
	}
	/* TODO: check the return count against something */
	mapitest_print(mt, "column count: %i\n", columns.cValues);

	/* Step 6. Release */
	mapi_object_release(&obj_htable);
	mapi_object_release(&(obj_test_folder));
	mapitest_common_cleanup(mt);

	return true;
}
Пример #9
0
/**
   \details Print mapitest report headers information
   
   \param mt pointer to the top-level mapitest structure
 */
_PUBLIC_ void mapitest_print_headers_info(struct mapitest *mt)
{
	time_t		t;
	char		*date;

	time (&t);
	date = ctime(&t);

	mapitest_print(mt, MT_HDR_FMT_DATE, "Date", date);
	mapitest_print(mt, MT_HDR_FMT, "Confidential mode", 
		       (mt->confidential == true) ? MT_YES : MT_NO);
	mapitest_print(mt, MT_HDR_FMT, "Samba Version (Build Time)", SAMBA_VERSION_STRING);
	mapitest_print(mt, MT_HDR_FMT, "OpenChange Information", OPENCHANGE_VERSION_STRING);
}
Пример #10
0
static bool mapitest_no_server_props_mv_bin(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;
	struct BinaryArray_r binarray;
	const struct BinaryArray_r *binarrayget;

	// create and initialise binarray
	struct Binary_r bin1, bin2;
	uint32_t i;

	// initialise bin
	bin1.cb = 8;
	bin1.lpb = talloc_array(mt->mem_ctx, uint8_t, bin1.cb);
	for (i = 0; i < bin1.cb; ++i) {
		bin1.lpb[i] = 0xC0 + i;
	}
	bin2.cb = 12;
	bin2.lpb = talloc_array(mt->mem_ctx, uint8_t, bin2.cb);
	for (i = 0; i < bin2.cb; ++i) {
		bin2.lpb[i] = 0xA0 + i;
	}

	binarray.cValues = 2;
	binarray.lpbin = talloc_array(mt->mem_ctx, struct Binary_r, binarray.cValues);
	binarray.lpbin[0] = bin1;
	binarray.lpbin[1] = bin2;

	res = set_SPropValue_proptag(&propvalue, PT_MV_BINARY, &binarray);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_MV_BINARY");
		return false;
	}
	binarrayget = (const struct BinaryArray_r *)get_SPropValue_data(&propvalue);
	if (!binarrayget || (binarray.cValues != binarrayget->cValues) || (binarray.lpbin != binarrayget->lpbin)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_MV_BINARY");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_MV_BINARY");

	talloc_free(binarray.lpbin);
	talloc_free(bin1.lpb);
	talloc_free(bin2.lpb);

	return true;
}
Пример #11
0
static bool mapitest_no_server_props_i2(struct mapitest *mt)
{
	struct SPropValue propvalue;
	uint16_t i2 = 0x5693; /* just a random, not zero value */
	const uint16_t *i2get;

	set_SPropValue_proptag(&propvalue, PT_SHORT, &i2);
	i2get = (const uint16_t*)get_SPropValue_data(&propvalue);
	if (!i2get || (*i2get != i2)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_SHORT");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_SHORT");
	return true;
}
Пример #12
0
/**
   \details Test the NspiQueryColumns RPC operation (0x10)

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_nspi_QueryColumns(struct mapitest *mt)
{
	TALLOC_CTX		*mem_ctx;
	enum MAPISTATUS		retval;
	struct nspi_context	*nspi_ctx;
	struct SPropTagArray	*SPropTagArray = NULL;
	
	mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_QueryColumns");
	nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
	
	SPropTagArray = talloc_zero(mem_ctx, struct SPropTagArray);

	retval = nspi_QueryColumns(nspi_ctx, mem_ctx, true, &SPropTagArray);
	if (retval != MAPI_E_SUCCESS) {
		mapitest_print_retval_clean(mt, "NspiQueryColumns", retval);
		MAPIFreeBuffer(SPropTagArray);
		talloc_free(mem_ctx);
		return false;
	}

	if (SPropTagArray) {
		mapitest_print(mt, "* %d columns returned\n", SPropTagArray->cValues);
		mapitest_print_retval_clean(mt, "NspiQueryColumns", retval);
		MAPIFreeBuffer(SPropTagArray);
	}
	talloc_free(mem_ctx);

	return true;
}
Пример #13
0
/**
   \details Test the NspiGetPropList RPC operation (0x08)

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_nspi_GetPropList(struct mapitest *mt)
{
	TALLOC_CTX			*mem_ctx;
	enum MAPISTATUS			retval;
	struct nspi_context		*nspi_ctx;
	struct SPropTagArray		*pPropTags = 0;
	struct PropertyTagArray_r	*MIds;
	struct PropertyValue_r		*lpProp;
	struct Restriction_r		Filter;
	struct SPropTagArray		*SPropTagArray;
	struct PropertyRowSet_r		*RowSet;

	mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetPropList");
	nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;

	/* Step 1. Query for current profile username */
	SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_DISPLAY_NAME);
	lpProp = talloc_zero(mem_ctx, struct PropertyValue_r);
	lpProp->ulPropTag = PR_ANR_UNICODE;
	lpProp->dwAlignPad = 0;
	lpProp->value.lpszW = mt->mapi_ctx->session->profile->username;

	Filter.rt = RES_PROPERTY;
	Filter.res.resProperty.relop = RES_PROPERTY;
	Filter.res.resProperty.ulPropTag = PR_ANR_UNICODE;
	Filter.res.resProperty.lpProp = lpProp;

	RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r);
	MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
	retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &RowSet, &MIds);
	MAPIFreeBuffer(SPropTagArray);
	MAPIFreeBuffer(lpProp);
	MAPIFreeBuffer(RowSet);
	if (retval != MAPI_E_SUCCESS) {
		MAPIFreeBuffer(MIds);
		talloc_free(mem_ctx);
		return retval;
	}


	/* Step 2. Call NspiGetPropList using the MId returned by NspiGetMatches */
	pPropTags = talloc_zero(mt->mem_ctx, struct SPropTagArray);
	retval = nspi_GetPropList(nspi_ctx, mem_ctx, 0, MIds->aulPropTag[0], &pPropTags);
	MAPIFreeBuffer(MIds);
	mapitest_print_retval(mt, "NspiGetPropList");

	if (retval != MAPI_E_SUCCESS) {
		MAPIFreeBuffer(pPropTags);
		talloc_free(mem_ctx);
		return false;
	}

	if (pPropTags) {
		mapitest_print(mt, "* %-35s: %d\n", "Properties number", pPropTags->cValues);
		MAPIFreeBuffer(pPropTags);
	}
	talloc_free(mem_ctx);

	return true;
}
Пример #14
0
/**
   \details Test the GetStatus (0x16) operation

   This function:
   -# Opens the Inbox folder and gets the hierarchy table
   -# Call GetStatus
   -# Cleans up
 */
_PUBLIC_ bool mapitest_oxctable_GetStatus(struct mapitest *mt)
{
	bool			ret = true;
	mapi_object_t		obj_htable;
	uint8_t			TableStatus;

	/* Step 1. Logon */
	if (! mapitest_common_setup(mt, &obj_htable, NULL)) {
		return false;
	}

	/* Step 2. GetStatus */
	GetStatus(&obj_htable, &TableStatus);
	mapitest_print_retval(mt, "GetStatus");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
	} else {
		mapitest_print(mt, "* %-35s: TableStatus: %d\n", "GetStatus", TableStatus);
	}

	/* Step 3. Release */
	mapi_object_release(&obj_htable);
	mapitest_common_cleanup(mt);

	return ret;
}
Пример #15
0
/**
   \details Test the NspiUpdateStat RPC operation (0x02)

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_nspi_UpdateStat(struct mapitest *mt)
{
	TALLOC_CTX		*mem_ctx;
	enum MAPISTATUS		retval;
	struct nspi_context	*nspi_ctx;
	int32_t       		plDelta = 1;
	struct PropertyRowSet_r	*RowSet;

	mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_UpdateStat");
	nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;

	RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r);
	retval = nspi_GetSpecialTable(nspi_ctx, mem_ctx, 0x2, &RowSet);
	MAPIFreeBuffer(RowSet);
	if (retval != MAPI_E_SUCCESS) {
		talloc_free(mem_ctx);
		return false;
	}

	retval = nspi_UpdateStat(nspi_ctx, mem_ctx, &plDelta);
	mapitest_print_retval(mt, "NspiUpdateStat");
	if (retval != MAPI_E_SUCCESS) {
		talloc_free(mem_ctx);
		return false;
	}
	mapitest_print(mt, "* %-35s: %d\n", "plDelta", plDelta);
	talloc_free(mem_ctx);

	return true;
}
Пример #16
0
static bool mapitest_no_server_props_i4(struct mapitest *mt)
{
	struct SPropValue propvalue;
	uint32_t i4 = 0x33870911;
	const uint32_t *i4get;

	set_SPropValue_proptag(&propvalue, PT_LONG, &i4);
	i4get = (const uint32_t*)get_SPropValue_data(&propvalue);
	if (!i4get || (*i4get != i4)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_LONG");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_LONG");

	return true;
}
Пример #17
0
static bool mapitest_no_server_props_unicode(struct mapitest *mt)
{
	struct SPropValue propvalue;
	char *string = "OpenChange Project"; /* OK, so it probably isn't valid UTF16.. */
	const char **stringget;

	set_SPropValue_proptag(&propvalue, PT_UNICODE, &string);
	stringget = (const char**)get_SPropValue_data(&propvalue);
	if (!stringget || (strncmp(*stringget, string, sizeof(*stringget)) != 0)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_UNICODE");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_UNICODE");

	return true;
}
Пример #18
0
static bool mapitest_no_server_props_string8(struct mapitest *mt)
{
	struct SPropValue propvalue;
	char *string = "OpenChange Project";
	const char **stringget;

	set_SPropValue_proptag(&propvalue, PT_STRING8, &string);
	stringget = (const char**)get_SPropValue_data(&propvalue);
	if (!stringget || (strncmp(*stringget, string, sizeof(*stringget)) != 0)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_STRING8");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_STRING8");

	return true;
}
Пример #19
0
static bool mapitest_no_server_props_i8(struct mapitest *mt)
{
	struct SPropValue propvalue;
	uint64_t i8 = 0x098763aa;
	const uint64_t *i8get;

	set_SPropValue_proptag(&propvalue, PT_I8, &i8);
	i8get = (const uint64_t*)get_SPropValue_data(&propvalue);
	if (!i8get || (*i8get != i8)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_I8");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_I8");

	return true;
}
Пример #20
0
static bool mapitest_no_server_props_bool(struct mapitest *mt)
{
	struct SPropValue propvalue;
	bool b = false;
	const bool *boolget;

	set_SPropValue_proptag(&propvalue, PT_BOOLEAN, &b);
	boolget = (const bool*)get_SPropValue_data(&propvalue);
	if (!boolget || (*boolget != b)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_BOOLEAN");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_BOOLEAN");

	return true;
}
Пример #21
0
static bool mapitest_no_server_props_err(struct mapitest *mt)
{
	struct SPropValue propvalue;
	enum MAPISTATUS err = MAPI_E_NOT_ME;
	enum MAPISTATUS *errget;

	set_SPropValue_proptag(&propvalue, PT_ERROR, &err);
	errget = (enum MAPISTATUS*)get_SPropValue_data(&propvalue);
	if (!errget || (*errget != err)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_ERROR");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_ERROR");

	return true;
}
Пример #22
0
static bool mapitest_no_server_props_filetime(struct mapitest *mt)
{
	struct SPropValue propvalue;
	struct FILETIME ft;
	const struct FILETIME *ftget;

	ft.dwLowDateTime = 0x12345678;
	ft.dwHighDateTime = 0x87653491;
	set_SPropValue_proptag(&propvalue, PT_SYSTIME, &ft);
	ftget = (const struct FILETIME *)get_SPropValue_data(&propvalue);
	if (!ftget || (ft.dwLowDateTime != ftget->dwLowDateTime) || (ft.dwHighDateTime != ftget->dwHighDateTime)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_SYSTIME");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_SYSTIME");

	return true;
}
Пример #23
0
static bool mapitest_no_server_props_flatuid(struct mapitest *mt)
{
	bool res;
	struct SPropValue propvalue;
	struct FlatUID_r uid;
	const struct FlatUID_r *uidget;
	int i;

	// initialise uid
	for (i = 0; i < 16; ++i) {
		uid.ab[i] = 0x40 + i;
	}
	printf("uid:");
	for (i = 0; i < 16; ++i) {
		printf("%c", uid.ab[i]);
	}
	printf("\n");

	res = set_SPropValue_proptag(&propvalue, PT_CLSID, &uid);
	if (res == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue set with PT_CLSID");
		return false;
	}
	uidget = (const struct FlatUID_r*)get_SPropValue_data(&propvalue);
	if (!uidget) {
		printf("null uidget\n");
		return false;
	}
	printf("uidget:");
	for (i = 0; i < 16; ++i) {
		printf("%c", uidget->ab[i]);
	}
	printf("\n");
	if (!uidget || (memcmp(uid.ab, uidget->ab, 16))) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_CLSID");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_CLSID");

	return true;
}
Пример #24
0
/* this seems strange... */
static bool mapitest_no_server_props_null(struct mapitest *mt)
{
	struct SPropValue propvalue;
	uint32_t nullval = 0;
	const uint32_t *nullget;

	set_SPropValue_proptag(&propvalue, PT_NULL, &nullval);
	nullget = (const uint32_t*)get_SPropValue_data(&propvalue);
	if (!nullget) {
		printf("null nullget\n");
	}
	if (!nullget || (*nullget != nullval)) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SPropValue get/set with PT_NULL");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SPropValue get/set with PT_NULL");

	return true;
}
Пример #25
0
/**
   \details Print the module title

   \param mt pointer to the top-level mapitest structure
   \param str the module title string
 */
_PUBLIC_ void mapitest_print_module_title_start(struct mapitest *mt, const char *str)
{
	char	*title = NULL;

	if (!str) return;

	title = talloc_asprintf(mt->mem_ctx, MODULE_TITLE, str);
	mapitest_print(mt, "%s", title);
	mapitest_print_tab(mt);
	mapitest_print_line(mt, MODULE_TITLE_LINELEN, MODULE_TITLE_DELIM);
	mapitest_indent();
	talloc_free(title);
}
Пример #26
0
/**
     \details Test the SRowSet parsing / assembly code

   This function:
   -# Loads some test data and checks it
   -# Parses the test data 
   -# Checks that the parsed data matches the expected result

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
*/
_PUBLIC_ bool mapitest_noserver_srowset(struct mapitest *mt) 
{
	bool result;

	result = mapitest_noserver_srowset_untagged(mt);
	if (result == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SRowSet Untagged");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SRowSet Untagged");

	result = mapitest_noserver_srowset_tagged(mt);
	if (result == false) {
		/* failure */
		mapitest_print(mt, "* %-40s: [FAILURE]\n", "SRowSet Tagged");
		return false;
	}
	mapitest_print(mt, "* %-40s: [SUCCESS]\n", "SRowSet Tagged");

	return true;
}
Пример #27
0
/**
   \details print the test title
   
   \param mt pointer to the top-level mapitest structure
   \param str the test title
 */
_PUBLIC_ void mapitest_print_test_title_start(struct mapitest *mt, const char *str)
{
	char		*title = NULL;

	if (!str) return;

#ifdef HAVE_SUBUNIT
	if (mt->subunit_output) {
		subunit_test_start(str);
		return;
	}
#endif
	title = talloc_asprintf(mt->mem_ctx, MODULE_TEST_TITLE, str);
	mapitest_print(mt, "%s", title);
	mapitest_print_tab(mt);
	mapitest_print_line(mt, MODULE_TEST_LINELEN, MODULE_TEST_DELIM);
	mapitest_indent();
	talloc_free(title);
}
Пример #28
0
/**
   \details Test the SortTable (0x13), ExpandRow (0x59), CollapseRow(0x5a),
   GetCollapseState(0x6b) and SetCollapseState (0x6c) operations

   This function:
   -# Opens the Inbox folder and creates some test content
   -# Checks that the content is OK
   -# Applies a sort and categorisation
   -# Checks the results are as expected.
   -# Save away the Row ID and Insatnce Number for the first header
   -# Collapse the first category
   -# Checks the results are as expected.
   -# Save the "collapse state"
   -# Expand the first category again
   -# Checks the results are as expected
   -# Restore the saved "collapse state"
   -# Checks the results are as expected
   -# Cleans up

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_oxctable_Category(struct mapitest *mt)
{
	mapi_object_t		obj_htable;
	mapi_object_t		obj_test_folder;
	struct mt_common_tf_ctx	*context;
	uint32_t		count = 0;
	uint32_t		origcount = 0;
	bool			ret = true;
	struct SSortOrderSet	criteria;
	uint64_t		inst_id = 0;
	uint64_t		inst_num = 0;
	struct SPropTagArray	*SPropTagArray;
	struct SRowSet		SRowSet;
	uint32_t                rowcount = 0;
	uint32_t		Numerator = 0;
	uint32_t		Denominator = 0;
	struct SBinary_short	collapseState;

	/* Step 1. Logon */
	if (! mapitest_common_setup(mt, &obj_htable, &count)) {
		return false;
	}

	/* Step 2. Get the test folder */
	context = mt->priv;
	mapi_object_init(&(obj_test_folder));
	GetContentsTable(&(context->obj_test_folder), &(obj_test_folder), 0, &origcount);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "GetContentsTable");
		ret = false;
		goto cleanup;
	}
	if (origcount != 10) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "GetContentsTable", count);
		/* This isn't a hard error for this test though, because it might be from a 
		   previous test failure. Clean up and try again */
	}

	/* We need the header row InstanceId to fold/unfold the headers */
	SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0x6,
					  PR_SENDER_NAME,
					  PR_BODY,
					  PR_LAST_MODIFICATION_TIME,
					  PR_SUBJECT,
					  PR_INST_ID,
					  PR_INSTANCE_NUM);
	SetColumns(&(obj_test_folder), SPropTagArray);
	MAPIFreeBuffer(SPropTagArray);
	mapitest_print_retval(mt, "SetColumns");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Apply a categorised sort */
	memset(&criteria, 0x0, sizeof (struct SSortOrderSet));
	criteria.cSorts = 1;
	criteria.cCategories = 1;
	criteria.cExpanded = 1;
	criteria.aSort = talloc_array(mt->mem_ctx, struct SSortOrder, criteria.cSorts);
	criteria.aSort[0].ulPropTag = PR_SENDER_NAME;
	criteria.aSort[0].ulOrder = TABLE_SORT_ASCEND;
	SortTable(&(obj_test_folder), &criteria);
	mapitest_print_retval(mt, "SortTable");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	rowcount =  2 * origcount;
	QueryRows(&(obj_test_folder), rowcount, TBL_ADVANCE, &SRowSet);
	mapitest_print_retval(mt, "QueryRows");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Checks the results are as expected */
	QueryPosition(&(obj_test_folder), &Numerator, &Denominator);
	mapitest_print_retval(mt, "QueryPosition");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}
	/* the categories are expanded, and there are six unique senders, so there are six
	   extra rows - one for each header row */
	if (Denominator != origcount + 6) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "QueryPosition", Numerator);
		ret = false;
		goto cleanup;
	}

	/* save away ID/instance values for first row header */
	inst_id = (*(const uint64_t *)get_SPropValue_data(&(SRowSet.aRow[0].lpProps[4])));
	inst_num = (*(const uint32_t *)get_SPropValue_data(&(SRowSet.aRow[0].lpProps[5])));

	/* Collapse a row header */
	CollapseRow(&(obj_test_folder), inst_id, &rowcount);
	mapitest_print_retval(mt, "CollapseRow");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Checks the results are as expected */
	QueryPosition(&(obj_test_folder), &Numerator, &Denominator);
	mapitest_print_retval(mt, "QueryPosition");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}
	/* there are still six unique headers, but half of the real entries are under the first
	   header (usually 10, unless we have some other rubbish hanging around), and when we
	   collapse the first header row, that half disappear */
	if (Denominator != origcount/2 + 6) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "QueryPosition", Denominator);
		ret = false;
		goto cleanup;
	}

	/* Save the table collapse state */
	GetCollapseState(&(obj_test_folder), inst_id, inst_num, &collapseState);
	mapitest_print_retval(mt, "GetCollapseState");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}


	/* Expand a category */
	ExpandRow(&(obj_test_folder), inst_id, 20, &SRowSet, &rowcount);
	mapitest_print_retval(mt, "ExpandRow");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Checks the results are as expected */
	QueryPosition(&(obj_test_folder), &Numerator, &Denominator);
	mapitest_print_retval(mt, "QueryPosition");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}
	/* we've expanded the first header row, so we now get all the entries plus the 6 headers */
	if (Denominator != origcount + 6) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "QueryPosition", Denominator);
		ret = false;
		goto cleanup;
	}

	/* Restore the collapse state  */
	SetCollapseState(&(obj_test_folder), &collapseState);
	mapitest_print_retval(mt, "SetCollapseState");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Checks the results are as expected */
	QueryPosition(&(obj_test_folder), &Numerator, &Denominator);
	mapitest_print_retval(mt, "QueryPosition");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}
	/* back to the situation with the first heading collapsed */
	if (Denominator != origcount/2 + 6) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "QueryPosition", Denominator);
		ret = false;
		goto cleanup;
	}

 cleanup:
	/* Release */
	mapi_object_release(&obj_htable);
	mapi_object_release(&(obj_test_folder));
	mapitest_common_cleanup(mt);

	return ret;
}
Пример #29
0
/**
   \details Test the QueryRows (0x15) operation

   This function:
   -# Opens the Inbox folder and gets the hierarchy table
   -# Set the required columns
   -# Calls QueryRows until the end of the table
   -# Open the test folder, and get its contents
   -# Calls QueryRows until the end of the test folder
   -# Checks the results are as expected.
   -# Cleans up

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_oxctable_QueryRows(struct mapitest *mt)
{
	enum MAPISTATUS		retval;
	mapi_object_t		obj_htable;
	mapi_object_t		obj_test_folder;
	struct SRowSet		SRowSet;
	struct SPropTagArray	*SPropTagArray;
	struct SPropValue	lpProp;
	struct mt_common_tf_ctx	*context;
	uint32_t		idx = 0;
	uint32_t		count = 0;
	const char*		data;

	/* Step 1. Logon */
	if (! mapitest_common_setup(mt, &obj_htable, &count)) {
		return false;
	}

	/* Step 2. Set Table Columns */
	SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0x3,
					  PR_DISPLAY_NAME,
					  PR_FID,
					  PR_FOLDER_CHILD_COUNT);
	retval = SetColumns(&obj_htable, SPropTagArray);
	MAPIFreeBuffer(SPropTagArray);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "SetColumns");
		return false;
	}

	/* Step 3. QueryRows */
	do {
		retval = QueryRows(&obj_htable, 0x2, TBL_ADVANCE, &SRowSet);
		if (SRowSet.cRows > 0) {
			idx += SRowSet.cRows;
			if (retval == MAPI_E_SUCCESS) {
				mapitest_print(mt, "* %-35s: %.2d/%.2d [PASSED]\n", 
					       "QueryRows", idx, count);
			} else {
				mapitest_print(mt, "* %-35s: %.2d/%.2d [FAILED]\n", 
					       "QueryRows", idx, count);
			}
		}
	} while (retval == MAPI_E_SUCCESS && SRowSet.cRows > 0);


	/* Step 4. Get the test folder */
	context = mt->priv;
	mapi_object_init(&(obj_test_folder));
	GetContentsTable(&(context->obj_test_folder), &(obj_test_folder), 0, &count);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "GetContentsTable");
		return false;
	}
	if (count != 10) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "GetContentsTable", count);
		/* This isn't a hard error for this test though, because it might be from a 
		   previous test failure. Clean up and try again */
	}

	/* Step 5. Set Table Columns on the test folder */
	SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0x2, PR_BODY, PR_MESSAGE_CLASS);
	retval = SetColumns(&obj_test_folder, SPropTagArray);
	MAPIFreeBuffer(SPropTagArray);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "SetColumns");
		return false;
	}

	/* Step 6. QueryRows on test folder contents */
	idx = 0;
	do {
		retval = QueryRows(&(obj_test_folder), 0x2, TBL_ADVANCE, &SRowSet);
		if (SRowSet.cRows > 0) {
			idx += SRowSet.cRows;
			if (retval == MAPI_E_SUCCESS) {
			  	uint32_t	i;
				mapitest_print(mt, "* %-35s: %.2d/%.2d [PASSED]\n", 
					       "QueryRows", idx, count);
				for (i = 0; i < SRowSet.cRows; ++i) {
					lpProp = SRowSet.aRow[i].lpProps[0];
					if (lpProp.ulPropTag != PR_BODY) {
						mapitest_print(mt, "* %-35s: Bad proptag0 (0x%x)\n", 
							       "QueryRows", lpProp.ulPropTag);
						return false;
					}
					data = get_SPropValue_data(&lpProp);
					if (0 != strncmp(data, "Body of message", 15)) {
						mapitest_print(mt, "* %-35s: Bad propval0 (%s)\n", 
							       "QueryRows", data);
						return false;
					}
					lpProp = SRowSet.aRow[i].lpProps[1];
					if (lpProp.ulPropTag != PR_MESSAGE_CLASS) {
						mapitest_print(mt, "* %-35s: Bad proptag1 (0x%x)\n", 
							       "QueryRows", lpProp.ulPropTag);
						return false;
					}
					data = get_SPropValue_data(&lpProp);
					if (0 != strncmp(data, "IPM.Note", 8)) {
						mapitest_print(mt, "* %-35s: Bad propval1 (%s)\n", 
							       "QueryRows", data);
						return false;
					}
				}
			} else {
				mapitest_print(mt, "* %-35s: %.2d/%.2d [FAILED]\n", 
					       "QueryRows", idx, count);
			}
		}
	} while (retval == MAPI_E_SUCCESS && SRowSet.cRows > 0);

	/* Release */
	mapi_object_release(&obj_htable);
	mapi_object_release(&(obj_test_folder));
	mapitest_common_cleanup(mt);

	return true;
}
Пример #30
0
/**
   \details Test the Restrict (0x14) operation

   This function:
   -# Opens the Inbox folder and creates some test content
   -# Checks that the content is OK
   -# Applies a filter
   -# Checks the results are as expected.
   -# Resets the table
   -# Checks the results are as expected.
   -# Cleans up

   \param mt pointer on the top-level mapitest structure

   \return true on success, otherwise false
 */
_PUBLIC_ bool mapitest_oxctable_Restrict(struct mapitest *mt)
{
	mapi_object_t		obj_htable;
	mapi_object_t		obj_test_folder;
	struct mt_common_tf_ctx	*context;
	uint32_t		count = 0;
	uint32_t		origcount = 0;
	uint32_t		Numerator = 0;
	uint32_t		Denominator = 0;
	struct mapi_SRestriction res;
	bool			ret = true;

	/* Step 1. Logon */
	if (! mapitest_common_setup(mt, &obj_htable, &count)) {
		return false;
	}

	/* Step 2. Get the test folder */
	context = mt->priv;
	mapi_object_init(&(obj_test_folder));
	GetContentsTable(&(context->obj_test_folder), &(obj_test_folder), 0, &origcount);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "GetContentsTable");
		ret = false;
		goto cleanup;
	}
	if (origcount != 10) {
		mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "GetContentsTable", count);
		/* This isn't a hard error for this test though, because it might be from a 
		   previous test failure. Clean up and try again */
	}

	/* Apply a filter */
	res.rt = RES_PROPERTY;
	res.res.resProperty.relop = RES_PROPERTY;
	res.res.resProperty.ulPropTag = PR_SUBJECT;
	res.res.resProperty.lpProp.ulPropTag = PR_SUBJECT;
	res.res.resProperty.lpProp.value.lpszA = MT_MAIL_SUBJECT;

	Restrict(&(obj_test_folder), &res, NULL);
	mapitest_print_retval(mt, "Restrict");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Checks the results are as expected */
	context = mt->priv;
	QueryPosition(&(obj_test_folder), &Numerator, &Denominator);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "QueryPosition");
		ret = false;
		goto cleanup;
	}
	if (Denominator != origcount/2) {
		mapitest_print(mt, "* %-35s: unexpected filtered count (%i)\n", "QueryPosition", Denominator);
		ret = false;
		goto cleanup;
	}

	/* Resets the table */
	Reset(&(obj_test_folder));
	mapitest_print_retval(mt, "Reset");
	if (GetLastError() != MAPI_E_SUCCESS) {
		ret = false;
		goto cleanup;
	}

	/* Checks the results are as expected */
	context = mt->priv;
	QueryPosition(&(obj_test_folder), &Numerator, &Denominator);
	if (GetLastError() != MAPI_E_SUCCESS) {
		mapitest_print_retval(mt, "QueryPosition");
		ret = false;
		goto cleanup;
	}
	if (Denominator != origcount) {
		mapitest_print(mt, "* %-35s: unexpected reset count (%i)\n", "QueryPosition", Denominator);
		ret = false;
		goto cleanup;
	}

 cleanup:
	/* Release */
	mapi_object_release(&obj_htable);
	mapi_object_release(&(obj_test_folder));
	mapitest_common_cleanup(mt);

	return ret;
}