summaryrefslogtreecommitdiff
path: root/source4/torture/auth/ntlmssp.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/auth/ntlmssp.c')
-rw-r--r--source4/torture/auth/ntlmssp.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 978610ec51..ff111faf85 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -24,16 +24,16 @@
#include "lib/cmdline/popt_common.h"
#include "torture/torture.h"
-static BOOL torture_ntlmssp_self_check(struct torture_context *test,
- const void *_data)
+static bool torture_ntlmssp_self_check(struct torture_context *tctx)
{
struct gensec_security *gensec_security;
struct gensec_ntlmssp_state *gensec_ntlmssp_state;
DATA_BLOB data;
DATA_BLOB sig, expected_sig;
+ TALLOC_CTX *mem_ctx = tctx;
- torture_assert_ntstatus_ok(test,
- gensec_client_start(test, &gensec_security, NULL),
+ torture_assert_ntstatus_ok(tctx,
+ gensec_client_start(mem_ctx, &gensec_security, NULL),
"gensec client start");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -41,7 +41,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
gensec_want_feature(gensec_security, GENSEC_FEATURE_SIGN);
gensec_want_feature(gensec_security, GENSEC_FEATURE_SEAL);
- torture_assert_ntstatus_ok(test,
+ torture_assert_ntstatus_ok(tctx,
gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP),
"Failed to start GENSEC for NTLMSSP");
@@ -54,7 +54,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
gensec_ntlmssp_state->neg_flags = NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_KEY_EXCH | NTLMSSP_NEGOTIATE_NTLM2;
- torture_assert_ntstatus_ok(test,
+ torture_assert_ntstatus_ok(tctx,
ntlmssp_sign_init(gensec_ntlmssp_state),
"Failed to sign_init");
@@ -67,19 +67,15 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length);
dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length);
- if (sig.length != expected_sig.length) {
- torture_fail(test, "Wrong sig length: %d != %d",
- (int)sig.length, (int)expected_sig.length);
- return False;
- }
+ torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length");
- torture_assert(test, 0 == memcmp(sig.data, expected_sig.data, sig.length),
+ torture_assert(tctx, 0 == memcmp(sig.data, expected_sig.data, sig.length),
"data mismatch");
talloc_free(gensec_security);
- torture_assert_ntstatus_ok(test,
- gensec_client_start(test, &gensec_security, NULL),
+ torture_assert_ntstatus_ok(tctx,
+ gensec_client_start(mem_ctx, &gensec_security, NULL),
"Failed to start GENSEC for NTLMSSP");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -87,7 +83,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
gensec_want_feature(gensec_security, GENSEC_FEATURE_SIGN);
gensec_want_feature(gensec_security, GENSEC_FEATURE_SEAL);
- torture_assert_ntstatus_ok(test,
+ torture_assert_ntstatus_ok(tctx,
gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP),
"GENSEC start mech by oid");
@@ -100,7 +96,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
gensec_ntlmssp_state->neg_flags = NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_KEY_EXCH;
- torture_assert_ntstatus_ok(test,
+ torture_assert_ntstatus_ok(tctx,
ntlmssp_sign_init(gensec_ntlmssp_state),
"Failed to sign_init");
@@ -113,28 +109,22 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test,
dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length);
dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length);
- if (sig.length != expected_sig.length) {
- torture_fail(test, "Wrong sig length: %d != %d",
- (int)sig.length, (int)expected_sig.length);
- return False;
- }
+ torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length");
- torture_assert(test,
- 0 == memcmp(sig.data+8, expected_sig.data+8, sig.length-8),
+ torture_assert(tctx, 0 == memcmp(sig.data+8, expected_sig.data+8, sig.length-8),
"data mismatch");
talloc_free(gensec_security);
-
- return True;
+ return true;
}
struct torture_suite *torture_ntlmssp(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx,
- "LOCAL-NTLMSSP");
+ "NTLMSSP");
- torture_suite_add_simple_tcase(suite, "NTLMSSP self check",
- torture_ntlmssp_self_check, NULL);
+ torture_suite_add_simple_test(suite, "NTLMSSP self check",
+ torture_ntlmssp_self_check);
return suite;
}