diff options
author | Andrew Bartlett <abartlet@samba.org> | 2014-05-12 14:29:27 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-06-04 03:22:26 +0200 |
commit | 4688cf77c425eb52f9765a94b0479a2327d2e354 (patch) | |
tree | 51d2a428c9f6aab854534142b1459b169b3a9146 /nsswitch | |
parent | a1c7aa0b348527be5e798030771690937fddf350 (diff) | |
download | samba-4688cf77c425eb52f9765a94b0479a2327d2e354.tar.gz |
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>
Diffstat (limited to 'nsswitch')
-rw-r--r-- | nsswitch/libwbclient/tests/wbclient.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index cd44d692628..771b848533c 100644 --- a/nsswitch/libwbclient/tests/wbclient.c +++ b/nsswitch/libwbclient/tests/wbclient.c @@ -31,6 +31,8 @@ #include "lib/param/param.h" #include "lib/util/samba_util.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) @@ -464,12 +466,13 @@ static bool test_wbc_authenticate_user_int(struct torture_context *tctx, struct wbcAuthErrorInfo *error = NULL; 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, - "wbcAuthenticateUser of %s failed", getenv("USERNAME")); + "wbcAuthenticateUser of %s failed", + cli_credentials_get_username(cmdline_credentials)); 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.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) { - 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) { wbcErr ret; - const char *oldpass = getenv("PASSWORD"); - const char *newpass = "Koo8irei"; + const char *oldpass = cli_credentials_get_password(cmdline_credentials); + const char *newpass = "Koo8irei%$"; struct samr_CryptPassword new_nt_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.level = WBC_CHANGE_PASSWORD_LEVEL_RESPONSE; - params.account_name = getenv("USERNAME"); - params.domain_name = "SAMBA-TEST"; + params.account_name = cli_credentials_get_username(cmdline_credentials); + params.domain_name = cli_credentials_get_domain(cmdline_credentials); ret = wbcChangeUserPasswordEx(¶ms, NULL, NULL, NULL); torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, "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; } - ret = wbcChangeUserPassword(getenv("USERNAME"), "Koo8irei", - getenv("PASSWORD")); + ret = wbcChangeUserPassword(cli_credentials_get_username(cmdline_credentials), newpass, + cli_credentials_get_password(cmdline_credentials)); torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, "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) @@ -607,8 +610,8 @@ static bool test_wbc_logon_user(struct torture_context *tctx) "%s", "wbcLogonUser succeeded for NULL where it should " "have failed"); - params.username = getenv("USERNAME"); - params.password = getenv("PASSWORD"); + params.username = cli_credentials_get_username(cmdline_credentials); + params.password = cli_credentials_get_password(cmdline_credentials); ret = wbcAddNamedBlob(¶ms.num_blobs, ¶ms.blobs, "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); torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, "%s", "wbcAddNamedBlob failed"); - params.password = getenv("PASSWORD"); + params.password = cli_credentials_get_password(cmdline_credentials); ret = wbcLogonUser(¶ms, &info, &error, &policy); torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR, "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, "%s", "wbcInterfaceDetails failed"); - ret = wbcLookupName(iface->netbios_domain, getenv("USERNAME"), &sid, + ret = wbcLookupName(iface->netbios_domain, cli_credentials_get_username(cmdline_credentials), &sid, &sidtype); wbcFreeMemory(iface); 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); 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, "%s", "wbcAddNamedBlob failed"); wbcFreeMemory(sidstr); - params.password = getenv("PASSWORD"); + params.password = cli_credentials_get_password(cmdline_credentials); ret = wbcLogonUser(¶ms, &info, &error, &policy); torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS, "wbcLogonUser for %s failed", params.username); @@ -688,9 +691,9 @@ static bool test_wbc_getgroups(struct torture_context *tctx) uint32_t num_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, - "wbcGetGroups for %s failed", getenv("USERNAME")); + "wbcGetGroups for %s failed", cli_credentials_get_username(cmdline_credentials)); wbcFreeMemory(groups); return true; } |