diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-10-21 21:02:51 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:02:23 -0500 |
commit | 77b691e670b6372f74451f1cf87ccf8a6d7804e2 (patch) | |
tree | 08ae4f607367091ee9335a64481210667d6110b1 /source4/torture | |
parent | a8d4d3c9f6e9a6726c9df5794646b2528eab703e (diff) | |
download | samba-77b691e670b6372f74451f1cf87ccf8a6d7804e2.tar.gz samba-77b691e670b6372f74451f1cf87ccf8a6d7804e2.tar.bz2 samba-77b691e670b6372f74451f1cf87ccf8a6d7804e2.zip |
r3124: Add dcerpc_binding_from_tower()
Add tests for dcerpc_binding_from_tower()
(This used to be commit 88c6d34bba1a409127b26f86bd963bfab30a804c)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/local/binding_string.c | 76 |
1 files changed, 59 insertions, 17 deletions
diff --git a/source4/torture/local/binding_string.c b/source4/torture/local/binding_string.c index 26fe67dd5c..7ec9a30d24 100644 --- a/source4/torture/local/binding_string.c +++ b/source4/torture/local/binding_string.c @@ -22,11 +22,10 @@ #include "includes.h" -static BOOL test_BindingString(const char *binding) +static BOOL test_BindingString(TALLOC_CTX *mem_ctx, const char *binding) { - TALLOC_CTX *mem_ctx = talloc_init("test_BindingString"); - struct dcerpc_binding b; - const char *s; + struct dcerpc_binding b, b2; + const char *s, *s2; struct epm_tower *tower; NTSTATUS status; @@ -55,27 +54,70 @@ static BOOL test_BindingString(const char *binding) return False; } - /* FIXME: Convert back to binding and then back to string and compare */ + /* Convert back to binding and then back to string and compare */ + + status = dcerpc_binding_from_tower(mem_ctx, tower, &b2); + if (NT_STATUS_IS_ERR(status)) { + DEBUG(0, ("Error generating binding from tower for original binding '%s': %s\n", binding, nt_errstr(status))); + return False; + } + + /* Compare to a stripped down version of the binding string because + * the protocol tower doesn't contain the extra option data */ + if (b.options && b.options[0]) { + b.options[1] = NULL; + } + + b.flags = 0; + + s = dcerpc_binding_string(mem_ctx, &b); + if (!s) { + DEBUG(0, ("Error converting binding back to string for (stripped down) '%s'\n", binding)); + return False; + } + + + s2 = dcerpc_binding_string(mem_ctx, &b2); + if (!s) { + DEBUG(0, ("Error converting binding back to string for '%s'\n", binding)); + return False; + } + + if (strcasecmp(s, s2) != 0) { + DEBUG(0, ("Mismatch while comparing original and from protocol tower generated binding strings: '%s' <> '%s'\n", s, s2)); + return False; + } 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_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", +}; + BOOL torture_local_binding_string(int dummy) { BOOL ret = True; + TALLOC_CTX *mem_ctx = talloc_init("test_BindingString"); + int i; + + for (i = 0; i < ARRAY_SIZE(test_strings); i++) { + ret &= test_BindingString(mem_ctx, test_strings[i]); + } - ret &= test_BindingString("ncacn_np:"); - ret &= test_BindingString("ncalrpc:"); - ret &= test_BindingString("ncalrpc:"); - ret &= test_BindingString("ncacn_np:[rpcecho]"); - ret &= test_BindingString("ncacn_np:127.0.0.1[rpcecho]"); - ret &= test_BindingString("ncacn_np:localhost[rpcecho]"); - ret &= test_BindingString("ncacn_np:[/pipe/rpcecho]"); - ret &= test_BindingString("ncacn_np:localhost[/pipe/rpcecho,sign,seal]"); - ret &= test_BindingString("ncacn_np:[,sign]"); - ret &= test_BindingString("ncadg_ip_udp:"); - ret &= test_BindingString("308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:localhost"); - ret &= test_BindingString("308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:localhost"); + talloc_destroy(mem_ctx); return ret; } |