[NETAPI32_WINETEST]: Sync with Wine 1.5.19.
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 11 Dec 2012 10:19:54 +0000 (10:19 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 11 Dec 2012 10:19:54 +0000 (10:19 +0000)
svn path=/trunk/; revision=57871

rostests/winetests/netapi32/CMakeLists.txt
rostests/winetests/netapi32/access.c
rostests/winetests/netapi32/wksta.c

index 951664a..a9297e5 100644 (file)
@@ -1,7 +1,5 @@
 
-add_definitions(
-    -D__ROS_LONG64__
-    -D_DLL -D__USE_CRTIMP)
+add_definitions(-D__ROS_LONG64__)
 
 list(APPEND SOURCE
     access.c
index 2f29684..a8c43c3 100644 (file)
@@ -29,8 +29,8 @@
 
 #include "wine/test.h"
 
-WCHAR user_name[UNLEN + 1];
-WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
+static WCHAR user_name[UNLEN + 1];
+static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
 
 static const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ',
                                 'U','s','e','r',0};
@@ -63,6 +63,8 @@ static NET_API_STATUS (WINAPI *pNetUserGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*)=N
 static NET_API_STATUS (WINAPI *pNetUserModalsGet)(LPCWSTR,DWORD,LPBYTE*)=NULL;
 static NET_API_STATUS (WINAPI *pNetUserAdd)(LPCWSTR,DWORD,LPBYTE,LPDWORD)=NULL;
 static NET_API_STATUS (WINAPI *pNetUserDel)(LPCWSTR,LPCWSTR)=NULL;
+static NET_API_STATUS (WINAPI *pNetLocalGroupGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*)=NULL;
+static NET_API_STATUS (WINAPI *pNetLocalGroupGetMembers)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*,DWORD,LPDWORD,LPDWORD,PDWORD_PTR)=NULL;
 
 static int init_access_tests(void)
 {
@@ -158,6 +160,7 @@ static void run_usergetinfo_tests(void)
         ok(rc == ERROR_BAD_NETPATH ||
            rc == ERROR_NETWORK_UNREACHABLE ||
            rc == RPC_S_SERVER_UNAVAILABLE ||
+           rc == NERR_WkstaNotStarted || /* workstation service not running */
            rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */
            "Bad Network Path: rc=%d\n",rc);
     }
@@ -320,6 +323,33 @@ static void run_userhandling_tests(void)
     ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret);
 }
 
+static void run_localgroupgetinfo_tests(void)
+{
+    NET_API_STATUS status;
+    static const WCHAR admins[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r','s',0};
+    PLOCALGROUP_INFO_1 lgi = NULL;
+    PLOCALGROUP_MEMBERS_INFO_3 buffer = NULL;
+    DWORD entries_read = 0, total_entries =0;
+    int i;
+
+    status = pNetLocalGroupGetInfo(NULL, admins, 1, (LPBYTE *)&lgi);
+    ok(status == NERR_Success || broken(status == NERR_GroupNotFound),
+       "NetLocalGroupGetInfo unexpectedly returned %d\n", status);
+    if (status != NERR_Success) return;
+
+    trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name));
+    trace("Comment: %s\n", wine_dbgstr_w( lgi->lgrpi1_comment));
+
+    pNetApiBufferFree(lgi);
+
+    status = pNetLocalGroupGetMembers(NULL, admins, 3, (LPBYTE *)&buffer, MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL);
+    ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status);
+    ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n");
+
+    for(i=0;i<entries_read;i++)
+        trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname));
+}
+
 START_TEST(access)
 {
     HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
@@ -331,6 +361,8 @@ START_TEST(access)
     pNetUserModalsGet=(void*)GetProcAddress(hnetapi32,"NetUserModalsGet");
     pNetUserAdd=(void*)GetProcAddress(hnetapi32, "NetUserAdd");
     pNetUserDel=(void*)GetProcAddress(hnetapi32, "NetUserDel");
+    pNetLocalGroupGetInfo=(void*)GetProcAddress(hnetapi32, "NetLocalGroupGetInfo");
+    pNetLocalGroupGetMembers=(void*)GetProcAddress(hnetapi32, "NetLocalGroupGetMembers");
 
     /* These functions were introduced with NT. It's safe to assume that
      * if one is not available, none are.
@@ -346,6 +378,7 @@ START_TEST(access)
         run_usergetinfo_tests();
         run_querydisplayinformation1_tests();
         run_usermodalsget_tests();
+        run_localgroupgetinfo_tests();
     }
 
     FreeLibrary(hnetapi32);
index c5929de..5d1d8ac 100644 (file)
@@ -31,6 +31,7 @@
 #include "lmerr.h"
 #include "lmwksta.h"
 #include "lmapibuf.h"
+#include "lmjoin.h"
 
 static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)=NULL;
 static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL;
@@ -38,9 +39,10 @@ static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=NULL;
 static NET_API_STATUS (WINAPI *pNetWkstaUserGetInfo)(LPWSTR,DWORD,PBYTE*)=NULL;
 static NET_API_STATUS (WINAPI *pNetWkstaTransportEnum)(LPWSTR,DWORD,LPBYTE*,
  DWORD,LPDWORD,LPDWORD,LPDWORD)=NULL;
+static NET_API_STATUS (WINAPI *pNetGetJoinInformation)(LPCWSTR,LPWSTR*,PNETSETUP_JOIN_STATUS);
 
-WCHAR user_name[UNLEN + 1];
-WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
+static WCHAR user_name[UNLEN + 1];
+static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
 
 static int init_wksta_tests(void)
 {
@@ -77,12 +79,17 @@ static void run_wkstausergetinfo_tests(void)
     LPWKSTA_USER_INFO_1 ui1 = NULL;
     LPWKSTA_USER_INFO_1101 ui1101 = NULL;
     DWORD dwSize;
+    NET_API_STATUS rc;
 
     /* Level 0 */
-    ok(pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success,
-       "NetWkstaUserGetInfo is unsuccessful\n");
+    rc = pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0);
+    if (rc == NERR_WkstaNotStarted)
+    {
+        skip("Workstation service not running\n");
+        return;
+    }
+    ok(!rc && ui0, "got %d and %p (expected NERR_Success and != NULL\n", rc, ui0);
 
-    ok(ui0 != NULL, "ui0 is NULL\n");
     /* This failure occurred when I ran sshd as service and didn't authenticate
      * Since the test dereferences ui0, the rest of this test is worthless
      */
@@ -166,7 +173,7 @@ static void run_wkstatransportenum_tests(void)
     /* final check: valid return, actually get data back */
     apiReturn = pNetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH,
         &entriesRead, &totalEntries, NULL);
-    ok(apiReturn == NERR_Success || apiReturn == ERROR_NETWORK_UNREACHABLE,
+    ok(apiReturn == NERR_Success || apiReturn == ERROR_NETWORK_UNREACHABLE || apiReturn == NERR_WkstaNotStarted,
        "NetWkstaTransportEnum returned %d\n", apiReturn);
     if (apiReturn == NERR_Success) {
         /* WKSTA_TRANSPORT_INFO_0 *transports = (WKSTA_TRANSPORT_INFO_0 *)bufPtr; */
@@ -179,6 +186,28 @@ static void run_wkstatransportenum_tests(void)
     }
 }
 
+static void run_wkstajoininfo_tests(void)
+{
+    NET_API_STATUS ret;
+    LPWSTR buffer = NULL;
+    NETSETUP_JOIN_STATUS buffertype = 0xdada;
+    /* NT4 doesn't have this function */
+    if (!pNetGetJoinInformation) {
+        win_skip("NetGetJoinInformation not available\n");
+        return;
+    }
+
+    ret = pNetGetJoinInformation(NULL, NULL, NULL);
+    ok(ret == ERROR_INVALID_PARAMETER, "NetJoinGetInformation returned unexpected 0x%08x\n", ret);
+    ok(buffertype == 0xdada, "buffertype set to unexpected value %d\n", buffertype);
+
+    ret = pNetGetJoinInformation(NULL, &buffer, &buffertype);
+    ok(ret == NERR_Success, "NetJoinGetInformation returned unexpected 0x%08x\n", ret);
+    ok(buffertype != 0xdada && buffertype != NetSetupUnknownStatus, "buffertype set to unexpected value %d\n", buffertype);
+    trace("workstation joined to %s with status %d\n", wine_dbgstr_w(buffer), buffertype);
+    pNetApiBufferFree(buffer);
+}
+
 START_TEST(wksta)
 {
     HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
@@ -188,6 +217,7 @@ START_TEST(wksta)
     pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName");
     pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo");
     pNetWkstaTransportEnum=(void*)GetProcAddress(hnetapi32,"NetWkstaTransportEnum");
+    pNetGetJoinInformation=(void*)GetProcAddress(hnetapi32,"NetGetJoinInformation");
 
     /* These functions were introduced with NT. It's safe to assume that
      * if one is not available, none are.
@@ -205,6 +235,7 @@ START_TEST(wksta)
             win_skip("Function NetpGetComputerName not available\n");
         run_wkstausergetinfo_tests();
         run_wkstatransportenum_tests();
+        run_wkstajoininfo_tests();
     }
 
     FreeLibrary(hnetapi32);