From f7229d61ede14f6fd14b9e5dcb365ec772216e08 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 19 Mar 2024 10:24:44 +0100 Subject: [PATCH] s4:torture: Add new LSA test_query_forest_trust_info() Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Thu Jul 18 12:36:25 UTC 2024 on atb-devel-224 --- source4/torture/rpc/forest_trust.c | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/source4/torture/rpc/forest_trust.c b/source4/torture/rpc/forest_trust.c index 815ca9ba2ae..284d5e4441c 100644 --- a/source4/torture/rpc/forest_trust.c +++ b/source4/torture/rpc/forest_trust.c @@ -30,6 +30,7 @@ #include "libcli/auth/libcli_auth.h" #include "torture/rpc/torture_rpc.h" #include "param/param.h" +#include "source3/rpc_client/init_lsa.h" #include #include @@ -164,6 +165,61 @@ static bool test_set_forest_trust_info(struct dcerpc_pipe *p, return true; } +static bool test_query_forest_trust_info(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle, + const char *trust_name_dns) +{ + struct lsa_String trusted_domain_name = { + .size = 0, + }; + struct lsa_ForestTrustInformation *fti = NULL; + struct lsa_lsaRQueryForestTrustInformation r = { + .in = { + .handle = handle, + .highest_record_type = 2, + .trusted_domain_name = &trusted_domain_name, + }, + .out = { + .forest_trust_info = &fti, + } + }; + struct lsa_ForestTrustRecord *rec = NULL; + + init_lsa_String(&trusted_domain_name, trust_name_dns); + + torture_comment(tctx, "\nTesting lsaRQueryForestTrustInformation\n"); + + + torture_assert_ntstatus_ok(tctx, + dcerpc_lsa_lsaRQueryForestTrustInformation_r( + p->binding_handle, tctx, &r), + "lsaRQueryForestTrustInformation failed"); + torture_assert_ntstatus_ok(tctx, + r.out.result, + "lsaRQueryForestTrustInformation failed"); + + torture_assert_not_null(tctx, + r.out.forest_trust_info, + "forest_trust_info is not set"); + torture_assert_int_equal(tctx, + fti->count, + 2, + "Unexpected forest_trust_info count"); + + rec = fti->entries[0]; + torture_assert_int_equal(tctx, + rec->type, + LSA_FOREST_TRUST_TOP_LEVEL_NAME, + "Unexpedted type"); + torture_assert_str_equal(tctx, + rec->forest_trust_data.top_level_name.string, + trust_name_dns, + "Unexpected top level name"); + + return true; +} + static bool test_create_trust_and_set_info(struct dcerpc_pipe *p, struct torture_context *tctx, const char *trust_name, @@ -249,6 +305,11 @@ static bool test_create_trust_and_set_info(struct dcerpc_pipe *p, return false; } + ok = test_query_forest_trust_info(p, tctx, handle, trust_name_dns); + if (!ok) { + return false; + } + cr.in.handle = handle; cr.out.handle = &closed_handle; torture_assert_ntstatus_ok(tctx,