Commit 8be0a557 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

secur32/tests: Make GetComputerObjectName() tests pass when computer is part of a domain.

parent 04fd1fc4
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <security.h> #include <security.h>
#include <schannel.h> #include <schannel.h>
#include <wincred.h> #include <wincred.h>
#include <winsock2.h>
#include "wine/test.h" #include "wine/test.h"
...@@ -67,20 +68,40 @@ static void testGetComputerObjectNameA(void) ...@@ -67,20 +68,40 @@ static void testGetComputerObjectNameA(void)
UINT i; UINT i;
for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) { for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
size = 0;
SetLastError(0xdeadbeef);
rc = pGetComputerObjectNameA(formats[i], NULL, &size);
ok(!rc, "GetComputerObjectName(%u) should fail\n", formats[i]);
switch (formats[i])
{
case NameUnknown:
ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError());
break;
default:
ok(GetLastError() == ERROR_NONE_MAPPED ||
GetLastError() == ERROR_NO_SUCH_USER ||
GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO ||
GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"%u: got %u\n", formats[i], GetLastError());
break;
}
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue;
size = sizeof(name); size = sizeof(name);
ZeroMemory(name, sizeof(name)); SetLastError(0xdeadbeef);
rc = pGetComputerObjectNameA(formats[i], name, &size); rc = pGetComputerObjectNameA(formats[i], name, &size);
ok(rc || ((formats[i] == NameUnknown) && switch (formats[i])
(GetLastError() == ERROR_INVALID_PARAMETER)) || {
(GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) || case NameUnknown:
(GetLastError() == ERROR_NO_SUCH_DOMAIN) || ok(!rc, "GetComputerObjectName(%u) should fail\n", formats[i]);
(GetLastError() == ERROR_NO_SUCH_USER) || ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError());
(GetLastError() == ERROR_NONE_MAPPED) || break;
(GetLastError() == ERROR_ACCESS_DENIED), default:
"GetComputerObjectNameA(%d) failed: %d\n", ok(rc, "GetComputerObjectName(%u) error %u\n", formats[i], GetLastError());
formats[i], GetLastError()); trace("GetComputerObjectName(%u) returned %s\n", formats[i], name);
if (rc) break;
trace("GetComputerObjectNameA() returned %s\n", name); }
} }
} }
...@@ -92,22 +113,40 @@ static void testGetComputerObjectNameW(void) ...@@ -92,22 +113,40 @@ static void testGetComputerObjectNameW(void)
UINT i; UINT i;
for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) { for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
size = 0;
SetLastError(0xdeadbeef);
rc = pGetComputerObjectNameW(formats[i], NULL, &size);
ok(!rc || broken(rc) /* win10 */, "GetComputerObjectName(%u) should fail\n", formats[i]);
switch (formats[i])
{
case NameUnknown:
ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError());
break;
default:
ok(GetLastError() == ERROR_NONE_MAPPED ||
GetLastError() == ERROR_NO_SUCH_USER ||
GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO ||
GetLastError() == WSAHOST_NOT_FOUND ||
GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"%u: got %u\n", formats[i], GetLastError());
break;
}
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue;
size = sizeof(nameW)/sizeof(nameW[0]); size = sizeof(nameW)/sizeof(nameW[0]);
ZeroMemory(nameW, sizeof(nameW)); SetLastError(0xdeadbeef);
rc = pGetComputerObjectNameW(formats[i], nameW, &size); rc = pGetComputerObjectNameW(formats[i], nameW, &size);
ok(rc || ((formats[i] == NameUnknown) && switch (formats[i])
(GetLastError() == ERROR_INVALID_PARAMETER)) || {
(GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) || case NameUnknown:
(GetLastError() == ERROR_NO_SUCH_DOMAIN) || ok(!rc, "GetComputerObjectName(%u) should fail\n", formats[i]);
(GetLastError() == ERROR_NO_SUCH_USER) || ok(GetLastError() == ERROR_INVALID_PARAMETER, "%u: got %u\n", formats[i], GetLastError());
(GetLastError() == ERROR_NONE_MAPPED) || break;
(GetLastError() == ERROR_ACCESS_DENIED), default:
"GetComputerObjectNameW(%d) failed: %d\n", ok(rc, "GetComputerObjectName(%u) error %u\n", formats[i], GetLastError());
formats[i], GetLastError()); trace("GetComputerObjectName(%u) returned %s\n", formats[i], wine_dbgstr_w(nameW));
if (rc) { break;
char name[256];
WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, sizeof(name), NULL, NULL );
trace("GetComputerObjectNameW() returned %s\n", name);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment