From: Owen Rudge orudge@codeweavers.com
--- dlls/secur32/tests/Makefile.in | 1 + dlls/secur32/tests/lsa.c | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 dlls/secur32/tests/lsa.c
diff --git a/dlls/secur32/tests/Makefile.in b/dlls/secur32/tests/Makefile.in index 089d1c3117b..d9f140a5069 100644 --- a/dlls/secur32/tests/Makefile.in +++ b/dlls/secur32/tests/Makefile.in @@ -2,6 +2,7 @@ TESTDLL = secur32.dll IMPORTS = secur32 crypt32 advapi32 ws2_32
C_SRCS = \ + lsa.c \ main.c \ negotiate.c \ ntlm.c \ diff --git a/dlls/secur32/tests/lsa.c b/dlls/secur32/tests/lsa.c new file mode 100644 index 00000000000..3c3203c9fb6 --- /dev/null +++ b/dlls/secur32/tests/lsa.c @@ -0,0 +1,68 @@ +/* + * LSA tests + * + * Copyright 2022 Owen Rudge for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdio.h> +#include <stdarg.h> +#include <windef.h> +#define SECURITY_WIN32 +#include <ntsecapi.h> + +#include "wine/test.h" + +static void test_get_logon_session_data(void) +{ + SECURITY_LOGON_SESSION_DATA *data = NULL; + TOKEN_STATISTICS ts; + HANDLE thread_hdl; + NTSTATUS status; + DWORD ret_len; + BOOL ret; + + ret = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &thread_hdl); + ok(ret, "got %ld\n", GetLastError()); + + if (!ret) return; + + ret_len = sizeof(TOKEN_STATISTICS); + ret = GetTokenInformation(thread_hdl, TokenStatistics, &ts, sizeof(TOKEN_STATISTICS), &ret_len); + ok(ret, "got %ld\n", GetLastError()); + + if (!ret) goto cleanup; + + status = LsaGetLogonSessionData(&ts.AuthenticationId, &data); + todo_wine ok(!status, "got %08lx\n", status); + + if (status) goto cleanup; + + ok(data->Size >= sizeof(SECURITY_LOGON_SESSION_DATA), "Size == %ld\n", data->Size); + ok(!memcmp(&data->LogonId, &ts.AuthenticationId, sizeof(LUID)), "LogonId mismatch\n"); + + /* We can't easily verify the content of the various logon parameters, so just ensure data is present */ + ok(data->AuthenticationPackage.Length > 0, "AuthenticationPackage missing\n"); + +cleanup: + CloseHandle(thread_hdl); + if (data != NULL) LsaFreeReturnBuffer(data); +} + +START_TEST(lsa) +{ + test_get_logon_session_data(); +}