summaryrefslogtreecommitdiff
path: root/nsswitch/libwbclient
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-04-04 21:38:38 +0200
committerVolker Lendecke <vl@samba.org>2010-04-19 14:27:18 +0200
commitb62e57cec21fd8428ceb66e13a1e9856f8c6d40e (patch)
treeb66de330faa263f8e517d1255df29a6600a48950 /nsswitch/libwbclient
parent77c0b015c7719d3f0e3a97c4d339899857f019ab (diff)
downloadsamba-b62e57cec21fd8428ceb66e13a1e9856f8c6d40e.tar.gz
samba-b62e57cec21fd8428ceb66e13a1e9856f8c6d40e.tar.bz2
samba-b62e57cec21fd8428ceb66e13a1e9856f8c6d40e.zip
libwbclient: Test wbcAuthenticateUser[Ex]
Diffstat (limited to 'nsswitch/libwbclient')
-rw-r--r--nsswitch/libwbclient/tests/wbclient.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index df9e7427ee..67091f724a 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -529,6 +529,45 @@ static bool test_wbc_get_sidaliases(struct torture_context *tctx)
return true;
}
+static bool test_wbc_authenticate_user(struct torture_context *tctx)
+{
+ struct wbcAuthUserParams params;
+ struct wbcAuthUserInfo *info = NULL;
+ struct wbcAuthErrorInfo *error = NULL;
+ wbcErr ret;
+
+ ret = wbcAuthenticateUser(getenv("USERNAME"), getenv("PASSWORD"));
+ torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
+ "wbcAuthenticateUser failed");
+
+ ZERO_STRUCT(params);
+ params.account_name = getenv("USERNAME");
+ params.level = WBC_AUTH_USER_LEVEL_PLAIN;
+ params.password.plaintext = getenv("PASSWORD");
+
+ ret = wbcAuthenticateUserEx(&params, &info, &error);
+ torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
+ "wbcAuthenticateUserEx failed");
+ wbcFreeMemory(info);
+ info = NULL;
+
+ wbcFreeMemory(error);
+ error = NULL;
+
+ params.password.plaintext = "wrong";
+ ret = wbcAuthenticateUserEx(&params, &info, &error);
+ torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR,
+ "wbcAuthenticateUserEx succeeded where it "
+ "should have failed");
+ wbcFreeMemory(info);
+ info = NULL;
+
+ wbcFreeMemory(error);
+ error = NULL;
+
+ return true;
+}
+
struct torture_suite *torture_wbclient(void)
{
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "WBCLIENT");
@@ -554,6 +593,8 @@ struct torture_suite *torture_wbclient(void)
test_wbc_lookup_rids);
torture_suite_add_simple_test(suite, "wbcGetSidAliases",
test_wbc_get_sidaliases);
+ torture_suite_add_simple_test(suite, "wbcAuthenticateUser",
+ test_wbc_authenticate_user);
return suite;
}