From 1afda7bdde90948027e3230c19753280afb16e96 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 2 Mar 2007 14:53:09 +0000 Subject: r21656: Move tests a bit closer to the things they test, should make syncing with samba3 easier. (This used to be commit 4d755fb5d7adedd1dd8bad917b921324411bfd59) --- source4/librpc/tests/binding_string.c | 111 ++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 source4/librpc/tests/binding_string.c (limited to 'source4/librpc/tests/binding_string.c') diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c new file mode 100644 index 0000000000..f6bf35671e --- /dev/null +++ b/source4/librpc/tests/binding_string.c @@ -0,0 +1,111 @@ +/* + Unix SMB/CIFS implementation. + + local testing of RPC binding string parsing + + Copyright (C) Jelmer Vernooij 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "librpc/gen_ndr/epmapper.h" +#include "librpc/rpc/dcerpc.h" +#include "torture/torture.h" + +static bool test_BindingString(struct torture_context *tctx, + const void *test_data) +{ + const char *binding = test_data; + struct dcerpc_binding *b, *b2; + const char *s, *s2; + struct epm_tower tower; + TALLOC_CTX *mem_ctx = tctx; + + /* Parse */ + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(mem_ctx, binding, &b), + "Error parsing binding string"); + + s = dcerpc_binding_string(mem_ctx, b); + torture_assert(tctx, s != NULL, "Error converting binding back to string"); + + torture_assert_casestr_equal(tctx, binding, s, + "Mismatch while comparing original and regenerated binding strings"); + + /* Generate protocol towers */ + torture_assert_ntstatus_ok(tctx, dcerpc_binding_build_tower(mem_ctx, b, &tower), + "Error generating protocol tower"); + + /* Convert back to binding and then back to string and compare */ + + torture_assert_ntstatus_ok(tctx, dcerpc_binding_from_tower(mem_ctx, &tower, &b2), + "Error generating binding from tower for original binding"); + + /* Compare to a stripped down version of the binding string because + * the protocol tower doesn't contain the extra option data */ + b->options = NULL; + + b->flags = 0; + + s = dcerpc_binding_string(mem_ctx, b); + torture_assert(tctx, s != NULL, "Error converting binding back to string for (stripped down)"); + + s2 = dcerpc_binding_string(mem_ctx, b2); + torture_assert(tctx, s != NULL, "Error converting binding back to string"); + + if (is_ipaddress(b->host)) + torture_assert_casestr_equal(tctx, s, s2, "Mismatch while comparing original and from protocol tower generated binding strings"); + + return true; +} + +static const char *test_strings[] = { + "ncacn_np:", + "ncalrpc:", + "ncalrpc:[,Security=Sane]", + "ncacn_np:[rpcecho]", + "ncacn_np:127.0.0.1[rpcecho]", + "ncacn_ip_tcp:127.0.0.1", + "ncacn_ip_tcp:127.0.0.1[20]", + "ncacn_ip_tcp:127.0.0.1[20,sign]", + "ncacn_ip_tcp:127.0.0.1[20,Security=Foobar,sign]", + "ncacn_http:127.0.0.1", + "ncacn_http:127.0.0.1[78]", + "ncacn_http:127.0.0.1[78,ProxyServer=myproxy:3128]", + "ncacn_np:localhost[rpcecho]", + "ncacn_np:[/pipe/rpcecho]", + "ncacn_np:localhost[/pipe/rpcecho,sign,seal]", + "ncacn_np:[,sign]", + "ncadg_ip_udp:", + "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:localhost", + "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:127.0.0.1", + "ncacn_unix_stream:[/tmp/epmapper]", + "ncalrpc:[IDENTIFIER]", + "ncacn_unix_stream:[/tmp/epmapper,sign]", +}; + +struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx) +{ + int i; + struct torture_suite *suite = torture_suite_create(mem_ctx, + "BINDING"); + + for (i = 0; i < ARRAY_SIZE(test_strings); i++) { + torture_suite_add_simple_tcase(suite, test_strings[i], + test_BindingString, test_strings[i]); + } + + return suite; +} -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/librpc/tests/binding_string.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/librpc/tests/binding_string.c') diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c index f6bf35671e..c4ffe19e6b 100644 --- a/source4/librpc/tests/binding_string.c +++ b/source4/librpc/tests/binding_string.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 53d10b44faa77293e380bd1cda6168acc05a5493 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 28 Aug 2007 17:45:57 +0000 Subject: r24753: Allow host name in binding string without transport. (This used to be commit f7051d3a84486ed9d0a1689c10a693521ec63528) --- source4/librpc/tests/binding_string.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/librpc/tests/binding_string.c') diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c index c4ffe19e6b..18cf4dfb46 100644 --- a/source4/librpc/tests/binding_string.c +++ b/source4/librpc/tests/binding_string.c @@ -95,6 +95,27 @@ static const char *test_strings[] = { "ncacn_unix_stream:[/tmp/epmapper,sign]", }; +static bool test_no_transport(struct torture_context *tctx) +{ + const char *binding = "somehost"; + struct dcerpc_binding *b; + const char *s; + + /* Parse */ + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, binding, &b), + "Error parsing binding string"); + + torture_assert(tctx, b->transport == NCA_UNKNOWN, "invalid transport"); + + s = dcerpc_binding_string(tctx, b); + torture_assert(tctx, s != NULL, "Error converting binding back to string"); + + torture_assert_casestr_equal(tctx, binding, s, + "Mismatch while comparing original and regenerated binding strings"); + + return true; +} + struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx) { int i; @@ -106,5 +127,7 @@ struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx) test_BindingString, test_strings[i]); } + torture_suite_add_simple_test(suite, "no transport", test_no_transport); + return suite; } -- cgit From 26ed05364d3172f17a0d4e1159e39a830f8a7217 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 1 Sep 2007 19:16:22 +0000 Subject: r24866: Put remainder of binding string tests in librpc/ directory. (This used to be commit 5b78d845a4d107e6a0e77a6e57e2b0e22fc0db95) --- source4/librpc/tests/binding_string.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source4/librpc/tests/binding_string.c') diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c index 18cf4dfb46..362848049b 100644 --- a/source4/librpc/tests/binding_string.c +++ b/source4/librpc/tests/binding_string.c @@ -95,6 +95,41 @@ static const char *test_strings[] = { "ncacn_unix_stream:[/tmp/epmapper,sign]", }; +static bool test_parse_check_results(struct torture_context *tctx) +{ + struct dcerpc_binding *b; + struct GUID uuid; + + torture_assert_ntstatus_ok(tctx, + GUID_from_string("308FB580-1EB2-11CA-923B-08002B1075A7", &uuid), + "parsing uuid"); + + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER", &b), "parse"); + torture_assert(tctx, b->transport == NCACN_NP, "ncacn_np expected"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_ip_tcp:$SERVER", &b), "parse"); + torture_assert(tctx, b->transport == NCACN_IP_TCP, "ncacn_ip_tcp expected"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[rpcecho]", &b), "parse"); + torture_assert_str_equal(tctx, b->endpoint, "rpcecho", "endpoint"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[/pipe/rpcecho]", &b), "parse"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[/pipe/rpcecho,sign,seal]", &b), "parse"); + torture_assert(tctx, b->flags == DCERPC_SIGN+DCERPC_SEAL, "sign+seal flags"); + torture_assert_str_equal(tctx, b->endpoint, "/pipe/rpcecho", "endpoint"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_np:$SERVER[,sign]", &b), "parse"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_ip_tcp:$SERVER[,sign]", &b), "parse"); + torture_assert(tctx, b->endpoint == NULL, "endpoint"); + torture_assert(tctx, b->flags == DCERPC_SIGN, "sign flag"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncalrpc:", &b), "parse"); + torture_assert(tctx, b->transport == NCALRPC, "ncalrpc expected"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, + "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:$SERVER", &b), "parse"); + torture_assert(tctx, GUID_equal(&b->object.uuid, &uuid), "object uuid"); + torture_assert_int_equal(tctx, b->object.if_version, 0, "object version"); + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, + "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:$SERVER", &b), "parse"); + + return true; +} + static bool test_no_transport(struct torture_context *tctx) { const char *binding = "somehost"; @@ -129,5 +164,7 @@ struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx) torture_suite_add_simple_test(suite, "no transport", test_no_transport); + torture_suite_add_simple_test(suite, "parsing results", test_parse_check_results); + return suite; } -- cgit From 3c744ddd2c33a9a06013f357261b8ea86804e8e8 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 24 Dec 2007 13:04:56 -0600 Subject: r26588: Janitorial: Rename torture_*_add_*test to torture_*_add_*test_const. Also rename the corresponding wrap_ functions. (This used to be commit e59c2eaf681f076d175b9779d1c27b5f74a57c96) --- source4/librpc/tests/binding_string.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/librpc/tests/binding_string.c') diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c index 362848049b..5e6fb04515 100644 --- a/source4/librpc/tests/binding_string.c +++ b/source4/librpc/tests/binding_string.c @@ -154,17 +154,18 @@ static bool test_no_transport(struct torture_context *tctx) struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx) { int i; - struct torture_suite *suite = torture_suite_create(mem_ctx, - "BINDING"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "BINDING"); for (i = 0; i < ARRAY_SIZE(test_strings); i++) { - torture_suite_add_simple_tcase(suite, test_strings[i], - test_BindingString, test_strings[i]); + torture_suite_add_simple_tcase_const(suite, test_strings[i], + test_BindingString, + test_strings[i]); } - torture_suite_add_simple_test(suite, "no transport", test_no_transport); + torture_suite_add_simple_test(suite, "no transport",test_no_transport); - torture_suite_add_simple_test(suite, "parsing results", test_parse_check_results); + torture_suite_add_simple_test(suite, "parsing results", + test_parse_check_results); return suite; } -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/librpc/tests/binding_string.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/tests/binding_string.c') diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c index 5e6fb04515..01cdfae80d 100644 --- a/source4/librpc/tests/binding_string.c +++ b/source4/librpc/tests/binding_string.c @@ -22,6 +22,7 @@ #include "includes.h" #include "librpc/gen_ndr/epmapper.h" #include "librpc/rpc/dcerpc.h" +#include "librpc/rpc/dcerpc_proto.h" #include "torture/torture.h" static bool test_BindingString(struct torture_context *tctx, -- cgit