#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)
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;
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;
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)
"%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);
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 "
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,
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);
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;
}