2 * Credentials User Interface Tests
4 * Copyright 2007 Robert Shearman for CodeWeavers
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.
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.
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
27 #include "wine/test.h"
29 static void test_CredUIPromptForCredentials(void)
31 static const WCHAR wszServerName[] = {'W','i','n','e','T','e','s','t',0};
35 CREDUI_INFOW credui_info;
38 credui_info.cbSize = sizeof(credui_info);
39 credui_info.hwndParent = NULL;
40 credui_info.pszMessageText = NULL;
41 credui_info.hbmBanner = NULL;
43 ret = CredUIConfirmCredentialsW(NULL, TRUE);
44 ok(ret == ERROR_INVALID_PARAMETER, "CredUIConfirmCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret);
46 ret = CredUIConfirmCredentialsW(wszServerName, TRUE);
47 ok(ret == ERROR_NOT_FOUND, "CredUIConfirmCredentials should have returned ERROR_NOT_FOUND instead of %d\n", ret);
51 ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username,
52 sizeof(username)/sizeof(username[0]),
53 password, sizeof(password)/sizeof(password[0]),
54 NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI);
55 ok(ret == ERROR_INVALID_FLAGS, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret);
57 ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username,
58 sizeof(username)/sizeof(username[0]),
59 password, sizeof(password)/sizeof(password[0]),
60 NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_GENERIC_CREDENTIALS);
61 ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret);
63 ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
64 sizeof(username)/sizeof(username[0]),
65 password, sizeof(password)/sizeof(password[0]),
66 NULL, CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX);
67 ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret);
69 if (winetest_interactive)
71 static const WCHAR wszCaption1[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
72 static const WCHAR wszCaption2[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','I','N','C','O','R','R','E','C','T','_','P','A','S','S','W','O','R','D','|',
73 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
74 static const WCHAR wszCaption3[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','D','O','_','N','O','T','_','P','E','R','S','I','S','T','|',
75 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
76 static const WCHAR wszCaption4[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','P','E','R','S','I','S','T','|',
77 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
79 ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
80 sizeof(username)/sizeof(username[0]),
81 password, sizeof(password)/sizeof(password[0]),
82 &save, CREDUI_FLAGS_EXPECT_CONFIRMATION);
83 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
84 if (ret == ERROR_SUCCESS)
85 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
87 credui_info.pszCaptionText = wszCaption1;
88 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL,
90 username, sizeof(username)/sizeof(username[0]),
91 password, sizeof(password)/sizeof(password[0]),
92 &save, CREDUI_FLAGS_EXPECT_CONFIRMATION);
93 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
94 if (ret == ERROR_SUCCESS)
95 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
97 credui_info.pszCaptionText = wszCaption2;
98 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
99 username, sizeof(username)/sizeof(username[0]),
100 password, sizeof(password)/sizeof(password[0]),
101 NULL, CREDUI_FLAGS_INCORRECT_PASSWORD|CREDUI_FLAGS_EXPECT_CONFIRMATION);
102 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
103 if (ret == ERROR_SUCCESS)
104 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
107 credui_info.pszCaptionText = wszCaption3;
108 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
109 username, sizeof(username)/sizeof(username[0]),
110 password, sizeof(password)/sizeof(password[0]),
111 &save, CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION);
112 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
113 ok(save, "save flag should have been untouched\n");
116 credui_info.pszCaptionText = wszCaption4;
117 ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
118 username, sizeof(username)/sizeof(username[0]),
119 password, sizeof(password)/sizeof(password[0]),
120 &save, CREDUI_FLAGS_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION);
121 ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
122 ok(!save, "save flag should have been untouched\n");
123 if (ret == ERROR_SUCCESS)
124 ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
130 test_CredUIPromptForCredentials();