summaryrefslogtreecommitdiff
path: root/source4/torture/auth
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-06-16 22:06:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:09 -0500
commit582d46ec42144bddccddacadd52a0256f58cb453 (patch)
tree0545454b21f1ef986117f7c2e72fe957d2b662e2 /source4/torture/auth
parentcc9d70bbba4e326ba89dec8cdc58b64b89f33091 (diff)
downloadsamba-582d46ec42144bddccddacadd52a0256f58cb453.tar.gz
samba-582d46ec42144bddccddacadd52a0256f58cb453.tar.bz2
samba-582d46ec42144bddccddacadd52a0256f58cb453.zip
r16304: Improve testing UI API. This now allows registering the full
test suite tree, looks a bit more like other unit testing API's, fixes some memory responsibility issues, introduces testcases, and removes the need for tests to call torture_ok(). (This used to be commit 0445b1a56a02552f895f400960b9ced39244a144)
Diffstat (limited to 'source4/torture/auth')
-rw-r--r--source4/torture/auth/ntlmssp.c24
-rw-r--r--source4/torture/auth/pac.c56
2 files changed, 27 insertions, 53 deletions
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 072d9a3b27..5c75a5b028 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -25,18 +25,16 @@
#include "torture/torture.h"
#include "torture/ui.h"
-BOOL torture_ntlmssp_self_check(struct torture_context *torture)
+static BOOL torture_ntlmssp_self_check(struct torture_context *test,
+ const void *_data)
{
struct gensec_security *gensec_security;
struct gensec_ntlmssp_state *gensec_ntlmssp_state;
DATA_BLOB data;
DATA_BLOB sig, expected_sig;
- NTSTATUS status;
- struct torture_test *test = torture_test(torture, "ntlmssp_self_check",
- "NTLMSSP Self Check");
torture_assert_ntstatus_ok(test,
- gensec_client_start(torture, &gensec_security, NULL),
+ gensec_client_start(test, &gensec_security, NULL),
"gensec client start");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -73,7 +71,6 @@ BOOL torture_ntlmssp_self_check(struct torture_context *torture)
if (sig.length != expected_sig.length) {
torture_fail(test, "Wrong sig length: %d != %d",
(int)sig.length, (int)expected_sig.length);
- talloc_free(test);
return False;
}
@@ -83,7 +80,7 @@ BOOL torture_ntlmssp_self_check(struct torture_context *torture)
talloc_free(gensec_security);
torture_assert_ntstatus_ok(test,
- gensec_client_start(torture, &gensec_security, NULL),
+ gensec_client_start(test, &gensec_security, NULL),
"Failed to start GENSEC for NTLMSSP");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -120,7 +117,6 @@ BOOL torture_ntlmssp_self_check(struct torture_context *torture)
if (sig.length != expected_sig.length) {
torture_fail(test, "Wrong sig length: %d != %d",
(int)sig.length, (int)expected_sig.length);
- talloc_free(test);
return False;
}
@@ -129,8 +125,16 @@ BOOL torture_ntlmssp_self_check(struct torture_context *torture)
"data mismatch");
talloc_free(gensec_security);
- torture_ok(test);
- talloc_free(test);
return True;
}
+
+BOOL torture_ntlmssp(struct torture_context *torture)
+{
+ struct torture_suite *suite = torture_suite_create(torture, "AUTH-NTLMSSP");
+
+ torture_suite_add_simple_tcase(suite, "NTLMSSP self check",
+ torture_ntlmssp_self_check, NULL);
+
+ return torture_run_suite(torture, suite);
+}
diff --git a/source4/torture/auth/pac.c b/source4/torture/auth/pac.c
index 313e0f0d3d..316a67acb0 100644
--- a/source4/torture/auth/pac.c
+++ b/source4/torture/auth/pac.c
@@ -31,7 +31,8 @@
#include "torture/torture.h"
#include "torture/ui.h"
-static BOOL torture_pac_self_check(struct torture_context *torture)
+static BOOL torture_pac_self_check(struct torture_context *test,
+ const void *_data)
{
NTSTATUS nt_status;
DATA_BLOB tmp_blob;
@@ -52,9 +53,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
struct auth_serversupplied_info *server_info;
struct auth_serversupplied_info *server_info_out;
- struct torture_test *test = torture_test(torture, "pac-selfcheck",
- "PAC Selfcheck");
-
krb5_principal client_principal;
time_t logon_time = time(NULL);
@@ -73,7 +71,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
smb_get_krb5_error_message(smb_krb5_context->krb5_context,
ret, test));
- talloc_free(test);
return False;
}
@@ -88,7 +85,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- talloc_free(test);
return False;
}
@@ -100,7 +96,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
&server_keyblock);
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&krbtgt_keyblock);
- talloc_free(test);
return False;
}
@@ -112,7 +107,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
&server_keyblock);
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&krbtgt_keyblock);
- talloc_free(test);
return False;
}
@@ -136,7 +130,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
&server_keyblock);
krb5_free_principal(smb_krb5_context->krb5_context,
client_principal);
- talloc_free(test);
return False;
}
@@ -162,7 +155,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
krb5_free_principal(smb_krb5_context->krb5_context,
client_principal);
- talloc_free(test);
return False;
}
@@ -188,7 +180,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
krb5_free_principal(smb_krb5_context->krb5_context,
client_principal);
- talloc_free(test);
return False;
}
@@ -209,7 +200,6 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
"(self test) PAC decoding (make server info) failed: %s",
nt_errstr(nt_status));
- talloc_free(test);
return False;
}
@@ -219,12 +209,9 @@ static BOOL torture_pac_self_check(struct torture_context *torture)
"(self test) PAC Decode resulted in *different* domain SID: %s != %s",
dom_sid_string(test, server_info->account_sid),
dom_sid_string(test, server_info_out->account_sid));
- talloc_free(test);
return False;
}
- torture_ok(test);
- talloc_free(test);
return True;
}
@@ -276,11 +263,10 @@ static const uint8_t saved_pac[] = {
};
/* Check with a known 'well formed' PAC, from my test server */
-static BOOL torture_pac_saved_check(struct torture_context *torture)
+static BOOL torture_pac_saved_check(struct torture_context *test,
+ const void *_data)
{
NTSTATUS nt_status;
- struct torture_test *test = torture_test(torture, "pac-saved-check",
- "PAC saved check");
DATA_BLOB tmp_blob, validate_blob;
struct PAC_DATA *pac_data, pac_data2;
struct PAC_LOGON_INFO *logon_info;
@@ -322,14 +308,12 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
krbtgt_bytes = smbpasswd_gethexpwd(test, pac_kdc_key);
if (!krbtgt_bytes) {
torture_fail(test, "(saved test) Could not interpret krbtgt key");
- talloc_free(test);
return False;
}
krbsrv_bytes = smbpasswd_gethexpwd(test, pac_member_key);
if (!krbsrv_bytes) {
torture_fail(test, "(saved test) Could not interpret krbsrv key");
- talloc_free(test);
return False;
}
@@ -343,7 +327,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
smb_get_krb5_error_message(smb_krb5_context->krb5_context,
ret, test));
- talloc_free(test);
return False;
}
@@ -359,7 +342,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- talloc_free(test);
return False;
}
@@ -397,7 +379,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
&krbtgt_keyblock);
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- talloc_free(test);
return False;
}
@@ -418,7 +399,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
&server_keyblock);
krb5_free_principal(smb_krb5_context->krb5_context, client_principal);
- talloc_free(test);
return False;
}
@@ -441,7 +421,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
"(saved test) PAC decoding (for logon info) failed: %s",
nt_errstr(nt_status));
- talloc_free(test);
return False;
}
@@ -461,7 +440,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
"(saved test) PAC decoding (make server info) failed: %s",
nt_errstr(nt_status));
- talloc_free(test);
return False;
}
@@ -479,7 +457,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
"(saved test) PAC Decode resulted in *different* domain SID: %s != %s",
"S-1-5-21-3048156945-3961193616-3706469200-1005",
dom_sid_string(test, server_info_out->account_sid));
- talloc_free(test);
return False;
}
@@ -498,7 +475,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
krb5_free_principal(smb_krb5_context->krb5_context, client_principal);
torture_fail(test, "(saved test) PAC push failed");
- talloc_free(test);
return False;
}
@@ -518,7 +494,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
torture_fail(test,
"(saved test) PAC push failed: original buffer length[%u] != created buffer length[%u]",
(unsigned)tmp_blob.length, (unsigned)validate_blob.length);
- talloc_free(test);
return False;
}
@@ -535,7 +510,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
DEBUG(0, ("validate_blob:\n"));
dump_data(0, validate_blob.data, validate_blob.length);
- talloc_free(test);
return False;
}
@@ -555,7 +529,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
krb5_free_principal(smb_krb5_context->krb5_context, client_principal);
torture_fail(test, "(saved test) regnerated PAC create failed");
- talloc_free(test);
return False;
}
@@ -582,7 +555,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
torture_fail(test, "(saved test) PAC regenerate failed: original buffer length[%u] != created buffer length[%u]",
(unsigned)tmp_blob.length, (unsigned)validate_blob.length);
- talloc_free(test);
return False;
}
@@ -607,7 +579,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
DEBUG(0, ("validate_blob:\n"));
dump_data(0, validate_blob.data, validate_blob.length);
- talloc_free(test);
return False;
}
@@ -627,7 +598,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
krb5_free_principal(smb_krb5_context->krb5_context, client_principal);
- talloc_free(test);
return False;
}
@@ -644,7 +614,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
&krbtgt_keyblock);
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- talloc_free(test);
return False;
}
@@ -662,7 +631,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
&krbtgt_keyblock);
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- talloc_free(test);
return False;
}
@@ -683,7 +651,6 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
&krbtgt_keyblock);
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- talloc_free(test);
return False;
}
@@ -692,15 +659,18 @@ static BOOL torture_pac_saved_check(struct torture_context *torture)
krb5_free_keyblock_contents(smb_krb5_context->krb5_context,
&server_keyblock);
- torture_ok(test);
- talloc_free(test);
return True;
}
BOOL torture_pac(struct torture_context *torture)
{
- BOOL ret = True;
- ret &= torture_pac_self_check(torture);
- ret &= torture_pac_saved_check(torture);
- return ret;
+ struct torture_suite *suite = torture_suite_create(torture, "AUTH-PAC");
+
+ torture_suite_add_simple_tcase(suite, "self check",
+ torture_pac_self_check, NULL);
+
+ torture_suite_add_simple_tcase(suite, "saved check",
+ torture_pac_saved_check, NULL);
+
+ return torture_run_suite(torture, suite);
}