#include "librpc/rpc/dcerpc.h"
#include "librpc/rpc/dcerpc_proto.h"
#include "torture/torture.h"
+#include "lib/util/util_net.h"
static bool test_BindingString(struct torture_context *tctx,
const void *test_data)
s2 = dcerpc_binding_string(mem_ctx, b2);
torture_assert(tctx, s != NULL, "Error converting binding back to string");
- if (is_ipaddress(b->host))
+ if (b->host && is_ipaddress(b->host)) {
torture_assert_casestr_equal(tctx, s, s2, "Mismatch while comparing original and from protocol tower generated binding strings");
+ }
return true;
}
"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_ip_tcp:127.0.0.1[20,sign,Security=Foobar]",
"ncacn_http:127.0.0.1",
"ncacn_http:127.0.0.1[78]",
"ncacn_http:127.0.0.1[78,ProxyServer=myproxy:3128]",
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");
+ torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_ip_tcp:$SERVER[,sign,localaddress=192.168.1.1]", &b), "parse");
+ torture_assert(tctx, b->transport == NCACN_IP_TCP, "ncacn_ip_tcp expected");
+ torture_assert(tctx, b->flags == DCERPC_SIGN, "sign flag");
+ torture_assert_str_equal(tctx, dcerpc_binding_get_string_option(b, "localaddress"),
+ "192.168.1.1", "localaddress");
+ torture_assert_str_equal(tctx, "ncacn_ip_tcp:$SERVER[,sign,localaddress=192.168.1.1]",
+ dcerpc_binding_string(tctx, b), "back to string");
return true;
}
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_const(suite, test_strings[i],