예제 #1
0
파일: spoolss.c 프로젝트: endisd/samba
static BOOL test_OnePrinter(struct torture_context *tctx,
			    LPSTR printername,
			    LPSTR architecture,
			    LPPRINTER_DEFAULTS defaults)
{
	HANDLE handle;
	BOOL ret = TRUE;

	torture_comment(tctx, "Testing Printer %s", printername);

	ret &= test_OpenPrinter(tctx, printername, defaults, &handle);
	ret &= test_GetPrinter(tctx, printername, handle);
	ret &= test_GetPrinterDriver(tctx, printername, architecture, handle);
	ret &= test_EnumForms(tctx, printername, handle);
	ret &= test_EnumJobs(tctx, printername, handle);
	ret &= test_EnumPrinterKey(tctx, printername, handle, "");
	ret &= test_EnumPrinterKey(tctx, printername, handle, "PrinterDriverData");
	ret &= test_EnumPrinterDataEx(tctx, printername, "PrinterDriverData", handle, NULL, NULL);
	ret &= test_ClosePrinter(tctx, handle);

	return ret;
}
예제 #2
0
static bool test_WinXP(struct torture_context *tctx, struct dcerpc_pipe *p)
{
	bool ret = true;
	struct test_spoolss_win_context *ctx, *tmp_ctx;
	struct policy_handle handle01, handle02, handle03, handle04;
	/* Sometimes a handle stays unused. In order to make this clear in the
	 * code, the unused_handle structures are used for that. */
	struct policy_handle unused_handle1, unused_handle2;
	char *server_name;
	uint32_t i;
	struct dcerpc_binding_handle *b = p->binding_handle;

	ctx = talloc_zero(tctx, struct test_spoolss_win_context);
	tmp_ctx = talloc_zero(tctx, struct test_spoolss_win_context);

	ret &= test_OpenPrinterSequence(tctx, p, &handle01);
	ret &= test_GetPrinterData(tctx, b, &handle01,"UISingleJobStatusString",
			WERR_INVALID_PARAMETER, 0);
	torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");

	server_name = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p));
	ret &= test_OpenPrinterEx(tctx, b, &unused_handle1, server_name, 0);

	ret &= test_EnumPrinters(tctx, p, ctx, 1024);

	ret &= test_OpenPrinterEx(tctx, b, &handle02, server_name, 0);
	ret &= test_GetPrinterData(tctx, b, &handle02, "MajorVersion", WERR_OK,
			3);
	ret &= test_ClosePrinter(tctx, b, &handle02);

	/* If no printers were found, skip all tests that need a printer */
	if (ctx->printer_count == 0) {
		goto end_testWinXP;
	}

	ret &= test_OpenPrinterEx(tctx, b, &handle02,
			ctx->printer_info[0].info2.printername,
			PRINTER_ACCESS_USE);
	ret &= test_GetPrinter(tctx, b, &handle02, ctx, 2, 0);

	torture_assert_str_equal(tctx, ctx->current_info->info2.printername,
			ctx->printer_info[0].info2.printername,
			"GetPrinter returned unexpected printername");
	/*FIXME: Test more components of the PrinterInfo2 struct */

	ret &= test_OpenPrinterEx(tctx, b, &handle03,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_GetPrinter(tctx, b, &handle03, ctx, 0, 1164);
	ret &= test_GetPrinter(tctx, b, &handle03, ctx, 2, 0);

	ret &= test_OpenPrinterEx(tctx, b, &handle04,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_GetPrinter(tctx, b, &handle04, ctx, 2, 0);
	ret &= test_ClosePrinter(tctx, b, &handle04);

	ret &= test_OpenPrinterEx(tctx, b, &handle04,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_GetPrinter(tctx, b, &handle04, ctx, 2, 4096);
	ret &= test_ClosePrinter(tctx, b, &handle04);

	ret &= test_OpenPrinterAsAdmin(tctx, b,
			ctx->printer_info[0].info2.printername);

	ret &= test_OpenPrinterEx(tctx, b, &handle04,
			ctx->printer_info[0].info2.printername, PRINTER_READ);
	ret &= test_GetPrinterData(tctx, b, &handle04,"UISingleJobStatusString",
			WERR_FILE_NOT_FOUND, 0);
	torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);

	ret &= test_EnumJobs(tctx, b, &handle04);
	ret &= test_GetPrinter(tctx, b, &handle04, ctx, 2, 4096);

	ret &= test_ClosePrinter(tctx, b, &unused_handle2);
	ret &= test_ClosePrinter(tctx, b, &handle04);

	ret &= test_EnumPrinters(tctx, p, ctx, 1556);
	ret &= test_GetPrinterDriver2(tctx, b, ctx, &handle03);
	ret &= test_EnumForms(tctx, b, &handle03, 0);

	ret &= test_EnumPrinterKey(tctx, b, &handle03, "", ctx);

	for (i=0; ctx->printer_keys && ctx->printer_keys[i] != NULL; i++) {

		ret &= test_EnumPrinterKey(tctx, b, &handle03,
					   ctx->printer_keys[i],
					   tmp_ctx);
		ret &= test_EnumPrinterDataEx(tctx, b, &handle03,
					      ctx->printer_keys[i], 0,
					      WERR_OK);
	}

	ret &= test_EnumPrinterDataEx(tctx, b, &handle03, "", 0,
			WERR_INVALID_PARAMETER);

	ret &= test_GetPrinter(tctx, b, &handle03, tmp_ctx, 2, 0);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_GetPrinter(tctx, b, &handle03, tmp_ctx, 2, 2556);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_GetPrinter(tctx, b, &handle03, tmp_ctx, 7, 0);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_ClosePrinter(tctx, b, &handle03);

	ret &= test_OpenPrinterEx(tctx, b, &unused_handle2,
			ctx->printer_info[0].info2.printername, 0);
	ret &= test_ClosePrinter(tctx, b, &unused_handle2);

	ret &= test_OpenPrinterEx(tctx, b, &handle03, server_name, 0);
	ret &= test_GetPrinterData(tctx, b, &handle03, "W3SvcInstalled",
			WERR_OK, 0);
	ret &= test_ClosePrinter(tctx, b, &handle03);

	ret &= test_ClosePrinter(tctx, b, &unused_handle1);
	ret &= test_ClosePrinter(tctx, b, &handle02);

	ret &= test_OpenPrinterEx(tctx, b, &handle02,
			ctx->printer_info[0].info2.sharename, 0);
	ret &= test_GetPrinter(tctx, b, &handle02, tmp_ctx, 2, 0);
	ret &= test_ClosePrinter(tctx, b, &handle02);

end_testWinXP:
	ret &= test_ClosePrinter(tctx, b, &handle01);

	talloc_free(tmp_ctx);
	talloc_free(ctx);
	return ret;
}