| 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 | #include <winnls.h>
|
|---|
| 25 | #define SECURITY_WIN32
|
|---|
| 26 | #include <security.h>
|
|---|
| 27 | #include <schannel.h>
|
|---|
| 28 |
|
|---|
| 29 | #include "wine/test.h"
|
|---|
| 30 |
|
|---|
| 31 | static HMODULE secdll;
|
|---|
| 32 |
|
|---|
| 33 | static BOOLEAN (WINAPI * pGetComputerObjectNameA)(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, PULONG lpnSize);
|
|---|
| 34 | static BOOLEAN (WINAPI * pGetComputerObjectNameW)(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG lpnSize);
|
|---|
| 35 | static PSecurityFunctionTableA (SEC_ENTRY * pInitSecurityInterfaceA)(void);
|
|---|
| 36 | static PSecurityFunctionTableW (SEC_ENTRY * pInitSecurityInterfaceW)(void);
|
|---|
| 37 |
|
|---|
| 38 | static EXTENDED_NAME_FORMAT formats[] = {
|
|---|
| 39 | NameUnknown, NameFullyQualifiedDN, NameSamCompatible, NameDisplay,
|
|---|
| 40 | NameUniqueId, NameCanonical, NameUserPrincipal, NameCanonicalEx,
|
|---|
| 41 | NameServicePrincipal, NameDnsDomain
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | static void testGetComputerObjectNameA(void)
|
|---|
| 45 | {
|
|---|
| 46 | char name[256];
|
|---|
| 47 | ULONG size;
|
|---|
| 48 | BOOLEAN rc;
|
|---|
| 49 | int i;
|
|---|
| 50 |
|
|---|
| 51 | for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
|
|---|
| 52 | size = sizeof(name);
|
|---|
| 53 | ZeroMemory(name, sizeof(name));
|
|---|
| 54 | rc = pGetComputerObjectNameA(formats[i], name, &size);
|
|---|
| 55 | ok(rc || ((formats[i] == NameUnknown) &&
|
|---|
| 56 | (GetLastError() == ERROR_INVALID_PARAMETER)) ||
|
|---|
| 57 | (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
|
|---|
| 58 | (GetLastError() == ERROR_NO_SUCH_DOMAIN) ||
|
|---|
| 59 | (GetLastError() == ERROR_NO_SUCH_USER) ||
|
|---|
| 60 | (GetLastError() == ERROR_NONE_MAPPED) ||
|
|---|
| 61 | (GetLastError() == ERROR_ACCESS_DENIED),
|
|---|
| 62 | "GetComputerObjectNameA(%d) failed: %d\n",
|
|---|
| 63 | formats[i], GetLastError());
|
|---|
| 64 | if (rc)
|
|---|
| 65 | trace("GetComputerObjectNameA() returned %s\n", name);
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | static void testGetComputerObjectNameW(void)
|
|---|
| 70 | {
|
|---|
| 71 | WCHAR nameW[256];
|
|---|
| 72 | ULONG size;
|
|---|
| 73 | BOOLEAN rc;
|
|---|
| 74 | int i;
|
|---|
| 75 |
|
|---|
| 76 | for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
|
|---|
| 77 | size = sizeof(nameW)/sizeof(nameW[0]);
|
|---|
| 78 | ZeroMemory(nameW, sizeof(nameW));
|
|---|
| 79 | rc = pGetComputerObjectNameW(formats[i], nameW, &size);
|
|---|
| 80 | ok(rc || ((formats[i] == NameUnknown) &&
|
|---|
| 81 | (GetLastError() == ERROR_INVALID_PARAMETER)) ||
|
|---|
| 82 | (GetLastError() == ERROR_CANT_ACCESS_DOMAIN_INFO) ||
|
|---|
| 83 | (GetLastError() == ERROR_NO_SUCH_DOMAIN) ||
|
|---|
| 84 | (GetLastError() == ERROR_NO_SUCH_USER) ||
|
|---|
| 85 | (GetLastError() == ERROR_NONE_MAPPED) ||
|
|---|
| 86 | (GetLastError() == ERROR_ACCESS_DENIED),
|
|---|
| 87 | "GetComputerObjectNameW(%d) failed: %d\n",
|
|---|
| 88 | formats[i], GetLastError());
|
|---|
| 89 | if (rc) {
|
|---|
| 90 | char name[256];
|
|---|
| 91 | WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, sizeof(name), NULL, NULL );
|
|---|
| 92 | trace("GetComputerObjectNameW() returned %s\n", name);
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | static void test_InitSecurityInterface(void)
|
|---|
| 98 | {
|
|---|
| 99 | PSecurityFunctionTableA sftA;
|
|---|
| 100 | PSecurityFunctionTableW sftW;
|
|---|
| 101 |
|
|---|
| 102 | sftA = pInitSecurityInterfaceA();
|
|---|
| 103 | ok(sftA != NULL, "pInitSecurityInterfaceA failed\n");
|
|---|
| 104 | ok(sftA->dwVersion == SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION, "wrong dwVersion %ld in security function table\n", sftA->dwVersion);
|
|---|
| 105 | ok(!sftA->Reserved2, "Reserved2 should be NULL instead of %p in security function table\n", sftA->Reserved2);
|
|---|
| 106 | ok(sftA->Reserved3 == sftA->EncryptMessage, "Reserved3 should be equal to EncryptMessage in the security function table\n");
|
|---|
| 107 | ok(sftA->Reserved4 == sftA->DecryptMessage, "Reserved4 should be equal to DecryptMessage in the security function table\n");
|
|---|
| 108 |
|
|---|
| 109 | if (!pInitSecurityInterfaceW)
|
|---|
| 110 | {
|
|---|
| 111 | skip("InitSecurityInterfaceW not exported by secur32.dll\n");
|
|---|
| 112 | return;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | sftW = pInitSecurityInterfaceW();
|
|---|
| 116 | ok(sftW != NULL, "pInitSecurityInterfaceW failed\n");
|
|---|
| 117 | ok(sftW->dwVersion == SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION, "wrong dwVersion %ld in security function table\n", sftW->dwVersion);
|
|---|
| 118 | ok(!sftW->Reserved2, "Reserved2 should be NULL instead of %p in security function table\n", sftW->Reserved2);
|
|---|
| 119 | ok(sftW->Reserved3 == sftW->EncryptMessage, "Reserved3 should be equal to EncryptMessage in the security function table\n");
|
|---|
| 120 | ok(sftW->Reserved4 == sftW->DecryptMessage, "Reserved4 should be equal to DecryptMessage in the security function table\n");
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | START_TEST(secur32)
|
|---|
| 124 | {
|
|---|
| 125 | secdll = LoadLibraryA("secur32.dll");
|
|---|
| 126 |
|
|---|
| 127 | if (!secdll)
|
|---|
| 128 | secdll = LoadLibraryA("security.dll");
|
|---|
| 129 |
|
|---|
| 130 | if (secdll)
|
|---|
| 131 | {
|
|---|
| 132 | pGetComputerObjectNameA = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameA");
|
|---|
| 133 | pGetComputerObjectNameW = (PVOID)GetProcAddress(secdll, "GetComputerObjectNameW");
|
|---|
| 134 | pInitSecurityInterfaceA = (PVOID)GetProcAddress(secdll, "InitSecurityInterfaceA");
|
|---|
| 135 | pInitSecurityInterfaceW = (PVOID)GetProcAddress(secdll, "InitSecurityInterfaceW");
|
|---|
| 136 |
|
|---|
| 137 | if (pGetComputerObjectNameA)
|
|---|
| 138 | testGetComputerObjectNameA();
|
|---|
| 139 |
|
|---|
| 140 | if (pGetComputerObjectNameW)
|
|---|
| 141 | testGetComputerObjectNameW();
|
|---|
| 142 |
|
|---|
| 143 | test_InitSecurityInterface();
|
|---|
| 144 |
|
|---|
| 145 | FreeLibrary(secdll);
|
|---|
| 146 | }
|
|---|
| 147 | }
|
|---|