Skip to content

Commit

Permalink
s4-torture: add test for spoolss_GetPrinterDriverPackagePath().
Browse files Browse the repository at this point in the history
Signed-off-by: Guenther Deschner <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
gd authored and jrasamba committed Aug 22, 2016
1 parent 2d4107f commit e99c8b3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions selftest/knownfail
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
^samba3.rpc.spoolss.printer.*.publish_toggle\(.*\)$ # needs spoolss AD member env
^samba3.rpc.spoolss.printserver.*.add_processor\(.*\)$
^samba3.rpc.spoolss.printserver.*.get_core_printer_drivers\(.*\)$
^samba3.rpc.spoolss.printserver.*.get_printer_driver_package_path\(.*\)$
^samba4.rpc.fsrvp # fsrvp server only provided by smbd
#
# The following tests fail against ad_dc (aka s3fs) currently.
Expand Down
77 changes: 77 additions & 0 deletions source4/torture/rpc/spoolss.c
Original file line number Diff line number Diff line change
Expand Up @@ -7984,6 +7984,82 @@ static bool test_get_core_printer_drivers(struct torture_context *tctx,
return true;
}

static bool test_get_printer_driver_package_path(struct torture_context *tctx,
void *private_data)
{
struct test_spoolss_context *ctx =
talloc_get_type_abort(private_data, struct test_spoolss_context);

const char *architectures[] = {
SPOOLSS_ARCHITECTURE_NT_X86,
SPOOLSS_ARCHITECTURE_x64
};
int i;
struct dcerpc_pipe *p = ctx->spoolss_pipe;
struct dcerpc_binding_handle *b = p->binding_handle;

for (i=0; i < ARRAY_SIZE(architectures); i++) {
struct spoolss_GetPrinterDriverPackagePath r;
uint32_t required = 0;
const char *package_id = NULL;

test_get_core_printer_drivers_arch_guid(tctx, p,
architectures[i],
SPOOLSS_CORE_PRINT_PACKAGE_FILES_XPSDRV,
&package_id),

torture_comment(tctx, "Testing GetPrinterDriverPackagePath(\"%s\",\"%s\")\n",
architectures[i], package_id);

r.in.servername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.architecture = "foobar";
r.in.language = NULL;
r.in.package_id = "";
r.in.driver_package_cab_size = 0;
r.in.driver_package_cab = NULL;

r.out.required = &required;
r.out.driver_package_cab = NULL;

torture_assert_ntstatus_ok(tctx,
dcerpc_spoolss_GetPrinterDriverPackagePath_r(b, tctx, &r),
"spoolss_GetPrinterDriverPackagePath failed");
torture_assert_werr_equal(tctx,
W_ERROR(WIN32_FROM_HRESULT(r.out.result)), WERR_INVALID_ENVIRONMENT,
"spoolss_GetPrinterDriverPackagePath failed");

r.in.architecture = architectures[i];

torture_assert_ntstatus_ok(tctx,
dcerpc_spoolss_GetPrinterDriverPackagePath_r(b, tctx, &r),
"spoolss_GetPrinterDriverPackagePath failed");
torture_assert_werr_equal(tctx,
W_ERROR(WIN32_FROM_HRESULT(r.out.result)), WERR_FILE_NOT_FOUND,
"spoolss_GetPrinterDriverPackagePath failed");

r.in.package_id = package_id;

torture_assert_ntstatus_ok(tctx,
dcerpc_spoolss_GetPrinterDriverPackagePath_r(b, tctx, &r),
"spoolss_GetPrinterDriverPackagePath failed");
torture_assert_hresult_ok(tctx, r.out.result,
"spoolss_GetPrinterDriverPackagePath failed");

r.in.driver_package_cab_size = required;
r.in.driver_package_cab = talloc_zero_array(tctx, char, required);
r.out.driver_package_cab = talloc_zero_array(tctx, char, required);

torture_assert_ntstatus_ok(tctx,
dcerpc_spoolss_GetPrinterDriverPackagePath_r(b, tctx, &r),
"spoolss_GetPrinterDriverPackagePath failed");
torture_assert_hresult_ok(tctx, r.out.result,
"spoolss_GetPrinterDriverPackagePath failed");

}

return true;
}

static bool test_PrintServer_Forms_Winreg(struct torture_context *tctx,
void *private_data)
{
Expand Down Expand Up @@ -9160,6 +9236,7 @@ struct torture_suite *torture_rpc_spoolss(TALLOC_CTX *mem_ctx)
torture_tcase_add_simple_test(tcase, "enum_printer_drivers_old", test_EnumPrinterDrivers_old);
torture_tcase_add_simple_test(tcase, "architecture_buffer", test_architecture_buffer);
torture_tcase_add_simple_test(tcase, "get_core_printer_drivers", test_get_core_printer_drivers);
torture_tcase_add_simple_test(tcase, "get_printer_driver_package_path", test_get_printer_driver_package_path);

torture_suite_add_suite(suite, torture_rpc_spoolss_printer(suite));

Expand Down

0 comments on commit e99c8b3

Please sign in to comment.