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
/* 2003 + */ || ret
== ERROR_NOT_FOUND
/* XP */,
45 "CredUIConfirmCredentials should have returned ERROR_INVALID_PARAMETER or ERROR_NOT_FOUND instead of %d\n", ret
);
47 ret
= CredUIConfirmCredentialsW(wszServerName
, TRUE
);
48 ok(ret
== ERROR_NOT_FOUND
, "CredUIConfirmCredentials should have returned ERROR_NOT_FOUND instead of %d\n", ret
);
52 ret
= CredUIPromptForCredentialsW(NULL
, NULL
, NULL
, 0, username
,
53 sizeof(username
)/sizeof(username
[0]),
54 password
, sizeof(password
)/sizeof(password
[0]),
55 NULL
, CREDUI_FLAGS_ALWAYS_SHOW_UI
);
56 ok(ret
== ERROR_INVALID_FLAGS
, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret
);
58 ret
= CredUIPromptForCredentialsW(NULL
, NULL
, NULL
, 0, username
,
59 sizeof(username
)/sizeof(username
[0]),
60 password
, sizeof(password
)/sizeof(password
[0]),
61 NULL
, CREDUI_FLAGS_ALWAYS_SHOW_UI
| CREDUI_FLAGS_GENERIC_CREDENTIALS
);
62 ok(ret
== ERROR_INVALID_PARAMETER
, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret
);
64 ret
= CredUIPromptForCredentialsW(NULL
, wszServerName
, NULL
, 0, username
,
65 sizeof(username
)/sizeof(username
[0]),
66 password
, sizeof(password
)/sizeof(password
[0]),
67 NULL
, CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX
);
68 ok(ret
== ERROR_INVALID_PARAMETER
, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret
);
70 if (winetest_interactive
)
72 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};
73 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','|',
74 '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};
75 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','|',
76 '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};
77 static const WCHAR wszCaption4
[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','P','E','R','S','I','S','T','|',
78 '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};
80 ret
= CredUIPromptForCredentialsW(NULL
, wszServerName
, NULL
, 0, username
,
81 sizeof(username
)/sizeof(username
[0]),
82 password
, sizeof(password
)/sizeof(password
[0]),
83 &save
, CREDUI_FLAGS_EXPECT_CONFIRMATION
);
84 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_CANCELLED
, "CredUIPromptForCredentials failed with error %d\n", ret
);
85 if (ret
== ERROR_SUCCESS
)
87 ret
= CredUIConfirmCredentialsW(wszServerName
, FALSE
);
88 ok(ret
== ERROR_SUCCESS
, "CredUIConfirmCredentials failed with error %d\n", ret
);
91 credui_info
.pszCaptionText
= wszCaption1
;
92 ret
= CredUIPromptForCredentialsW(&credui_info
, wszServerName
, NULL
,
94 username
, sizeof(username
)/sizeof(username
[0]),
95 password
, sizeof(password
)/sizeof(password
[0]),
96 &save
, CREDUI_FLAGS_EXPECT_CONFIRMATION
);
97 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_CANCELLED
, "CredUIPromptForCredentials failed with error %d\n", ret
);
98 if (ret
== ERROR_SUCCESS
)
100 ret
= CredUIConfirmCredentialsW(wszServerName
, FALSE
);
101 ok(ret
== ERROR_SUCCESS
, "CredUIConfirmCredentials failed with error %d\n", ret
);
104 credui_info
.pszCaptionText
= wszCaption2
;
105 ret
= CredUIPromptForCredentialsW(&credui_info
, wszServerName
, NULL
, 0,
106 username
, sizeof(username
)/sizeof(username
[0]),
107 password
, sizeof(password
)/sizeof(password
[0]),
108 NULL
, CREDUI_FLAGS_INCORRECT_PASSWORD
|CREDUI_FLAGS_EXPECT_CONFIRMATION
);
109 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_CANCELLED
, "CredUIPromptForCredentials failed with error %d\n", ret
);
110 if (ret
== ERROR_SUCCESS
)
112 ret
= CredUIConfirmCredentialsW(wszServerName
, FALSE
);
113 ok(ret
== ERROR_SUCCESS
, "CredUIConfirmCredentials failed with error %d\n", ret
);
118 credui_info
.pszCaptionText
= wszCaption3
;
119 ret
= CredUIPromptForCredentialsW(&credui_info
, wszServerName
, NULL
, 0,
120 username
, sizeof(username
)/sizeof(username
[0]),
121 password
, sizeof(password
)/sizeof(password
[0]),
122 &save
, CREDUI_FLAGS_DO_NOT_PERSIST
|CREDUI_FLAGS_EXPECT_CONFIRMATION
);
123 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_CANCELLED
, "CredUIPromptForCredentials failed with error %d\n", ret
);
124 ok(save
, "save flag should have been untouched\n");
127 credui_info
.pszCaptionText
= wszCaption4
;
128 ret
= CredUIPromptForCredentialsW(&credui_info
, wszServerName
, NULL
, 0,
129 username
, sizeof(username
)/sizeof(username
[0]),
130 password
, sizeof(password
)/sizeof(password
[0]),
131 &save
, CREDUI_FLAGS_PERSIST
|CREDUI_FLAGS_EXPECT_CONFIRMATION
);
132 ok(ret
== ERROR_SUCCESS
|| ret
== ERROR_CANCELLED
, "CredUIPromptForCredentials failed with error %d\n", ret
);
133 ok(!save
, "save flag should have been untouched\n");
134 if (ret
== ERROR_SUCCESS
)
136 ret
= CredUIConfirmCredentialsW(wszServerName
, FALSE
);
137 ok(ret
== ERROR_SUCCESS
, "CredUIConfirmCredentials failed with error %d\n", ret
);
145 test_CredUIPromptForCredentials();