msi: Make msi_dialog_dup_property return a copy of the property if the property is...
[wine] / dlls / secur32 / tests / secur32.c
1 /*
2  * tests
3  *
4  * Copyright 2006 Robert Reif
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 #include <stdio.h>
21 #include <stdarg.h>
22 #include <windef.h>
23 #include <winbase.h>
24 #define SECURITY_WIN32
25 #include <security.h>
26 #include <schannel.h>
27
28 #include "wine/test.h"
29
30 static HMODULE secdll;
31
32 static BOOLEAN (WINAPI * pGetComputerObjectNameA)(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG lpnSize);
33 static BOOLEAN (WINAPI * pGetComputerObjectNameW)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG lpnSize);
34
35 static EXTENDED_NAME_FORMAT formats[] = {
36     NameUnknown, NameFullyQualifiedDN, NameSamCompatible, NameDisplay,
37     NameUniqueId, NameCanonical, NameUserPrincipal, NameCanonicalEx,
38     NameServicePrincipal, NameDnsDomain
39 };
40
41 static void testGetComputerObjectNameA(void)
42 {
43     char name[256];
44     ULONG size;
45     BOOLEAN rc;
46     int i;
47
48     for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
49         size = sizeof(name);
50         ZeroMemory(name, sizeof(name));
51         rc = pGetComputerObjectNameA(formats[i], name, &size);
52         ok(rc || ((formats[i] == NameUnknown) &&
53            (GetLastError() == ERROR_INVALID_PARAMETER)) ||
54            (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
55            (GetLastError() == ERROR_NO_SUCH_DOMAIN),
56            "GetComputerObjectNameA(%d) failed: %ld\n",
57            formats[i], GetLastError());
58         if (rc)
59             trace("GetComputerObjectNameA() returned %s\n", name);
60     }
61 }
62
63 static void testGetComputerObjectNameW(void)
64 {
65     WCHAR nameW[256];
66     ULONG size;
67     BOOLEAN rc;
68     int i;
69
70     for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
71         size = sizeof(nameW)/sizeof(nameW[0]);
72         ZeroMemory(nameW, sizeof(nameW));
73         rc = pGetComputerObjectNameW(formats[i], nameW, &size);
74         ok(rc || ((formats[i] == NameUnknown) &&
75            (GetLastError() == ERROR_INVALID_PARAMETER)) ||
76            (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
77            (GetLastError() == ERROR_NO_SUCH_DOMAIN),
78            "GetComputerObjectNameW(%d) failed: %ld\n",
79            formats[i], GetLastError());
80         if (rc) {
81             char name[256];
82             WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, sizeof(name), NULL, NULL );
83             trace("GetComputerObjectNameW() returned %s\n", name);
84         }
85     }
86 }
87
88 START_TEST(secur32)
89 {
90     secdll = LoadLibraryA("secur32.dll");
91
92     if (!secdll)
93         secdll = LoadLibraryA("security.dll");
94
95     if (secdll)
96     {
97         pGetComputerObjectNameA = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameA");
98         pGetComputerObjectNameW = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameW");
99  
100         if (pGetComputerObjectNameA)
101             testGetComputerObjectNameA();
102
103         if (pGetComputerObjectNameW)
104             testGetComputerObjectNameW();
105
106         FreeLibrary(secdll);
107     }
108 }