mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
libwbclient-tests: No longer hardcoded password and test domain
The password is made more complex, and the test domain is made to use the command line options. Andrew Bartlett Change-Id: Ia1ec24a9fc393e7f7b210f845bcf32dbc933d48f Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
a1c7aa0b34
commit
4688cf77c4
@ -31,6 +31,8 @@
|
|||||||
#include "lib/param/param.h"
|
#include "lib/param/param.h"
|
||||||
#include "lib/util/samba_util.h"
|
#include "lib/util/samba_util.h"
|
||||||
#include "lib/crypto/arcfour.h"
|
#include "lib/crypto/arcfour.h"
|
||||||
|
#include "auth/credentials/credentials.h"
|
||||||
|
#include "lib/cmdline/popt_common.h"
|
||||||
|
|
||||||
#define WBC_ERROR_EQUAL(x,y) (x == y)
|
#define WBC_ERROR_EQUAL(x,y) (x == y)
|
||||||
|
|
||||||
@ -464,12 +466,13 @@ static bool test_wbc_authenticate_user_int(struct torture_context *tctx,
|
|||||||
struct wbcAuthErrorInfo *error = NULL;
|
struct wbcAuthErrorInfo *error = NULL;
|
||||||
wbcErr ret;
|
wbcErr ret;
|
||||||
|
|
||||||
ret = wbcAuthenticateUser(getenv("USERNAME"), correct_password);
|
ret = wbcAuthenticateUser(cli_credentials_get_username(cmdline_credentials), correct_password);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"wbcAuthenticateUser of %s failed", getenv("USERNAME"));
|
"wbcAuthenticateUser of %s failed",
|
||||||
|
cli_credentials_get_username(cmdline_credentials));
|
||||||
|
|
||||||
ZERO_STRUCT(params);
|
ZERO_STRUCT(params);
|
||||||
params.account_name = getenv("USERNAME");
|
params.account_name = cli_credentials_get_username(cmdline_credentials);
|
||||||
params.level = WBC_AUTH_USER_LEVEL_PLAIN;
|
params.level = WBC_AUTH_USER_LEVEL_PLAIN;
|
||||||
params.password.plaintext = correct_password;
|
params.password.plaintext = correct_password;
|
||||||
|
|
||||||
@ -498,14 +501,14 @@ static bool test_wbc_authenticate_user_int(struct torture_context *tctx,
|
|||||||
|
|
||||||
static bool test_wbc_authenticate_user(struct torture_context *tctx)
|
static bool test_wbc_authenticate_user(struct torture_context *tctx)
|
||||||
{
|
{
|
||||||
return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD"));
|
return test_wbc_authenticate_user_int(tctx, cli_credentials_get_password(cmdline_credentials));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool test_wbc_change_password(struct torture_context *tctx)
|
static bool test_wbc_change_password(struct torture_context *tctx)
|
||||||
{
|
{
|
||||||
wbcErr ret;
|
wbcErr ret;
|
||||||
const char *oldpass = getenv("PASSWORD");
|
const char *oldpass = cli_credentials_get_password(cmdline_credentials);
|
||||||
const char *newpass = "Koo8irei";
|
const char *newpass = "Koo8irei%$";
|
||||||
|
|
||||||
struct samr_CryptPassword new_nt_password;
|
struct samr_CryptPassword new_nt_password;
|
||||||
struct samr_CryptPassword new_lm_password;
|
struct samr_CryptPassword new_lm_password;
|
||||||
@ -569,23 +572,23 @@ static bool test_wbc_change_password(struct torture_context *tctx)
|
|||||||
params.new_password.response.nt_data = new_nt_password.data;
|
params.new_password.response.nt_data = new_nt_password.data;
|
||||||
|
|
||||||
params.level = WBC_CHANGE_PASSWORD_LEVEL_RESPONSE;
|
params.level = WBC_CHANGE_PASSWORD_LEVEL_RESPONSE;
|
||||||
params.account_name = getenv("USERNAME");
|
params.account_name = cli_credentials_get_username(cmdline_credentials);
|
||||||
params.domain_name = "SAMBA-TEST";
|
params.domain_name = cli_credentials_get_domain(cmdline_credentials);
|
||||||
|
|
||||||
ret = wbcChangeUserPasswordEx(¶ms, NULL, NULL, NULL);
|
ret = wbcChangeUserPasswordEx(¶ms, NULL, NULL, NULL);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"wbcChangeUserPassword for %s failed", params.account_name);
|
"wbcChangeUserPassword for %s failed", params.account_name);
|
||||||
|
|
||||||
if (!test_wbc_authenticate_user_int(tctx, "Koo8irei")) {
|
if (!test_wbc_authenticate_user_int(tctx, newpass)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = wbcChangeUserPassword(getenv("USERNAME"), "Koo8irei",
|
ret = wbcChangeUserPassword(cli_credentials_get_username(cmdline_credentials), newpass,
|
||||||
getenv("PASSWORD"));
|
cli_credentials_get_password(cmdline_credentials));
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"wbcChangeUserPassword for %s failed", params.account_name);
|
"wbcChangeUserPassword for %s failed", params.account_name);
|
||||||
|
|
||||||
return test_wbc_authenticate_user_int(tctx, getenv("PASSWORD"));
|
return test_wbc_authenticate_user_int(tctx, cli_credentials_get_password(cmdline_credentials));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool test_wbc_logon_user(struct torture_context *tctx)
|
static bool test_wbc_logon_user(struct torture_context *tctx)
|
||||||
@ -607,8 +610,8 @@ static bool test_wbc_logon_user(struct torture_context *tctx)
|
|||||||
"%s", "wbcLogonUser succeeded for NULL where it should "
|
"%s", "wbcLogonUser succeeded for NULL where it should "
|
||||||
"have failed");
|
"have failed");
|
||||||
|
|
||||||
params.username = getenv("USERNAME");
|
params.username = cli_credentials_get_username(cmdline_credentials);
|
||||||
params.password = getenv("PASSWORD");
|
params.password = cli_credentials_get_password(cmdline_credentials);
|
||||||
|
|
||||||
ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs,
|
ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs,
|
||||||
"foo", 0, discard_const_p(uint8_t, "bar"), 4);
|
"foo", 0, discard_const_p(uint8_t, "bar"), 4);
|
||||||
@ -638,7 +641,7 @@ static bool test_wbc_logon_user(struct torture_context *tctx)
|
|||||||
strlen("S-1-2-3-4")+1);
|
strlen("S-1-2-3-4")+1);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"%s", "wbcAddNamedBlob failed");
|
"%s", "wbcAddNamedBlob failed");
|
||||||
params.password = getenv("PASSWORD");
|
params.password = cli_credentials_get_password(cmdline_credentials);
|
||||||
ret = wbcLogonUser(¶ms, &info, &error, &policy);
|
ret = wbcLogonUser(¶ms, &info, &error, &policy);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR,
|
||||||
"wbcLogonUser for %s should have failed with "
|
"wbcLogonUser for %s should have failed with "
|
||||||
@ -653,11 +656,11 @@ static bool test_wbc_logon_user(struct torture_context *tctx)
|
|||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"%s", "wbcInterfaceDetails failed");
|
"%s", "wbcInterfaceDetails failed");
|
||||||
|
|
||||||
ret = wbcLookupName(iface->netbios_domain, getenv("USERNAME"), &sid,
|
ret = wbcLookupName(iface->netbios_domain, cli_credentials_get_username(cmdline_credentials), &sid,
|
||||||
&sidtype);
|
&sidtype);
|
||||||
wbcFreeMemory(iface);
|
wbcFreeMemory(iface);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"wbcLookupName for %s failed", getenv("USERNAME"));
|
"wbcLookupName for %s failed", cli_credentials_get_username(cmdline_credentials));
|
||||||
|
|
||||||
ret = wbcSidToString(&sid, &sidstr);
|
ret = wbcSidToString(&sid, &sidstr);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
@ -669,7 +672,7 @@ static bool test_wbc_logon_user(struct torture_context *tctx)
|
|||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"%s", "wbcAddNamedBlob failed");
|
"%s", "wbcAddNamedBlob failed");
|
||||||
wbcFreeMemory(sidstr);
|
wbcFreeMemory(sidstr);
|
||||||
params.password = getenv("PASSWORD");
|
params.password = cli_credentials_get_password(cmdline_credentials);
|
||||||
ret = wbcLogonUser(¶ms, &info, &error, &policy);
|
ret = wbcLogonUser(¶ms, &info, &error, &policy);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"wbcLogonUser for %s failed", params.username);
|
"wbcLogonUser for %s failed", params.username);
|
||||||
@ -688,9 +691,9 @@ static bool test_wbc_getgroups(struct torture_context *tctx)
|
|||||||
uint32_t num_groups;
|
uint32_t num_groups;
|
||||||
gid_t *groups;
|
gid_t *groups;
|
||||||
|
|
||||||
ret = wbcGetGroups(getenv("USERNAME"), &num_groups, &groups);
|
ret = wbcGetGroups(cli_credentials_get_username(cmdline_credentials), &num_groups, &groups);
|
||||||
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
|
||||||
"wbcGetGroups for %s failed", getenv("USERNAME"));
|
"wbcGetGroups for %s failed", cli_credentials_get_username(cmdline_credentials));
|
||||||
wbcFreeMemory(groups);
|
wbcFreeMemory(groups);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user