credui: Add tests for CredUIPromptForCredentialsW and CredUIConfirmCredentialsW.

This commit is contained in:
Rob Shearman 2007-10-24 16:17:36 +01:00 committed by Alexandre Julliard
parent 1d150b8920
commit e146591cd6
9 changed files with 164 additions and 0 deletions

5
.gitignore vendored
View File

@ -65,6 +65,10 @@ dlls/commdlg.dll16
dlls/compobj.dll16
dlls/compstui/libcompstui.def
dlls/credui/credui.res
dlls/credui/libcredui.def
dlls/credui/tests/*.ok
dlls/credui/tests/credui_crosstest.exe
dlls/credui/tests/testlist.c
dlls/crtdll/libcrtdll.def
dlls/crypt32/crypt32.res
dlls/crypt32/libcrypt32.def
@ -694,6 +698,7 @@ programs/winetest/cabinet_test.exe
programs/winetest/comcat_test.exe
programs/winetest/comctl32_test.exe
programs/winetest/comdlg32_test.exe
programs/winetest/credui_test.exe
programs/winetest/crypt32_test.exe
programs/winetest/cryptnet_test.exe
programs/winetest/d3d8_test.exe

View File

@ -183,6 +183,7 @@ ALL_MAKEFILES = \
dlls/comdlg32/tests/Makefile \
dlls/compstui/Makefile \
dlls/credui/Makefile \
dlls/credui/tests/Makefile \
dlls/crtdll/Makefile \
dlls/crypt32/Makefile \
dlls/crypt32/tests/Makefile \
@ -558,6 +559,7 @@ dlls/comdlg32/Makefile: dlls/comdlg32/Makefile.in dlls/Makedll.rules
dlls/comdlg32/tests/Makefile: dlls/comdlg32/tests/Makefile.in dlls/Maketest.rules
dlls/compstui/Makefile: dlls/compstui/Makefile.in dlls/Makedll.rules
dlls/credui/Makefile: dlls/credui/Makefile.in dlls/Makedll.rules
dlls/credui/tests/Makefile: dlls/credui/tests/Makefile.in dlls/Maketest.rules
dlls/crtdll/Makefile: dlls/crtdll/Makefile.in dlls/Makedll.rules
dlls/crypt32/Makefile: dlls/crypt32/Makefile.in dlls/Makedll.rules
dlls/crypt32/tests/Makefile: dlls/crypt32/tests/Makefile.in dlls/Maketest.rules

3
configure vendored
View File

@ -20564,6 +20564,8 @@ ac_config_files="$ac_config_files dlls/compstui/Makefile"
ac_config_files="$ac_config_files dlls/credui/Makefile"
ac_config_files="$ac_config_files dlls/credui/tests/Makefile"
ac_config_files="$ac_config_files dlls/crtdll/Makefile"
ac_config_files="$ac_config_files dlls/crypt32/Makefile"
@ -21825,6 +21827,7 @@ do
"dlls/comdlg32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/comdlg32/tests/Makefile" ;;
"dlls/compstui/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/compstui/Makefile" ;;
"dlls/credui/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/credui/Makefile" ;;
"dlls/credui/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/credui/tests/Makefile" ;;
"dlls/crtdll/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/crtdll/Makefile" ;;
"dlls/crypt32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/crypt32/Makefile" ;;
"dlls/crypt32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/crypt32/tests/Makefile" ;;

View File

@ -1599,6 +1599,7 @@ AC_CONFIG_FILES([dlls/comdlg32/Makefile])
AC_CONFIG_FILES([dlls/comdlg32/tests/Makefile])
AC_CONFIG_FILES([dlls/compstui/Makefile])
AC_CONFIG_FILES([dlls/credui/Makefile])
AC_CONFIG_FILES([dlls/credui/tests/Makefile])
AC_CONFIG_FILES([dlls/crtdll/Makefile])
AC_CONFIG_FILES([dlls/crypt32/Makefile])
AC_CONFIG_FILES([dlls/crypt32/tests/Makefile])

View File

@ -251,6 +251,7 @@ TESTSUBDIRS = \
comcat/tests \
comctl32/tests \
comdlg32/tests \
credui/tests \
crypt32/tests \
cryptnet/tests \
d3d8/tests \
@ -500,6 +501,7 @@ IMPORT_LIBS = \
comctl32/libcomctl32.$(IMPLIBEXT) \
comdlg32/libcomdlg32.$(IMPLIBEXT) \
compstui/libcompstui.$(IMPLIBEXT) \
credui/libcredui.$(IMPLIBEXT) \
crtdll/libcrtdll.$(IMPLIBEXT) \
crypt32/libcrypt32.$(IMPLIBEXT) \
cryptdll/libcryptdll.$(IMPLIBEXT) \
@ -660,6 +662,9 @@ comdlg32/libcomdlg32.$(IMPLIBEXT): comdlg32/comdlg32.spec $(WINEBUILD)
compstui/libcompstui.$(IMPLIBEXT): compstui/compstui.spec $(WINEBUILD)
@cd compstui && $(MAKE) libcompstui.$(IMPLIBEXT)
credui/libcredui.$(IMPLIBEXT): credui/credui.spec $(WINEBUILD)
@cd credui && $(MAKE) libcredui.$(IMPLIBEXT)
crtdll/libcrtdll.$(IMPLIBEXT): crtdll/crtdll.spec $(WINEBUILD)
@cd crtdll && $(MAKE) libcrtdll.$(IMPLIBEXT)

View File

@ -0,0 +1,13 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = credui.dll
IMPORTS = credui kernel32
CTESTS = \
credui.c
@MAKE_TEST_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend

131
dlls/credui/tests/credui.c Normal file
View File

@ -0,0 +1,131 @@
/*
* Credentials User Interface Tests
*
* Copyright 2007 Robert Shearman for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wincred.h"
#include "wine/test.h"
static void test_CredUIPromptForCredentials(void)
{
static const WCHAR wszServerName[] = {'W','i','n','e','T','e','s','t',0};
DWORD ret;
WCHAR username[256];
WCHAR password[256];
CREDUI_INFOW credui_info;
BOOL save = FALSE;
credui_info.cbSize = sizeof(credui_info);
credui_info.hwndParent = NULL;
credui_info.pszMessageText = NULL;
credui_info.hbmBanner = NULL;
ret = CredUIConfirmCredentialsW(NULL, TRUE);
ok(ret == ERROR_INVALID_PARAMETER, "CredUIConfirmCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret);
ret = CredUIConfirmCredentialsW(wszServerName, TRUE);
ok(ret == ERROR_NOT_FOUND, "CredUIConfirmCredentials should have returned ERROR_NOT_FOUND instead of %d\n", ret);
username[0] = '\0';
password[0] = '\0';
ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username,
sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI);
ok(ret == ERROR_INVALID_FLAGS, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret);
ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username,
sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_GENERIC_CREDENTIALS);
ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret);
ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
NULL, CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX);
ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret);
if (winetest_interactive)
{
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};
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','|',
'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};
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','|',
'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};
static const WCHAR wszCaption4[] = {'C','R','E','D','U','I','_','F','L','A','G','S','_','P','E','R','S','I','S','T','|',
'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};
ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
&save, CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
if (ret == ERROR_SUCCESS)
ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
credui_info.pszCaptionText = wszCaption1;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL,
ERROR_ACCESS_DENIED,
username, sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
&save, CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
if (ret == ERROR_SUCCESS)
ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
credui_info.pszCaptionText = wszCaption2;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
username, sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
NULL, CREDUI_FLAGS_INCORRECT_PASSWORD|CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
if (ret == ERROR_SUCCESS)
ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
save = TRUE;
credui_info.pszCaptionText = wszCaption3;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
username, sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
&save, CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
ok(save, "save flag should have been untouched\n");
save = FALSE;
credui_info.pszCaptionText = wszCaption4;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
username, sizeof(username)/sizeof(username[0]),
password, sizeof(password)/sizeof(password[0]),
&save, CREDUI_FLAGS_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
ok(!save, "save flag should have been untouched\n");
if (ret == ERROR_SUCCESS)
ret = CredUIConfirmCredentialsW(wszServerName, FALSE);
}
}
START_TEST(credui)
{
test_CredUIPromptForCredentials();
}

View File

@ -27,6 +27,7 @@ TESTBINS = \
comcat_test.exe \
comctl32_test.exe \
comdlg32_test.exe \
credui_test.exe \
crypt32_test.exe \
cryptnet_test.exe \
d3d8_test.exe \
@ -106,6 +107,8 @@ comctl32_test.exe: $(DLLDIR)/comctl32/tests/comctl32_test.exe$(DLLEXT)
cp $(DLLDIR)/comctl32/tests/comctl32_test.exe$(DLLEXT) $@ && $(STRIP) $@
comdlg32_test.exe: $(DLLDIR)/comdlg32/tests/comdlg32_test.exe$(DLLEXT)
cp $(DLLDIR)/comdlg32/tests/comdlg32_test.exe$(DLLEXT) $@ && $(STRIP) $@
credui_test.exe: $(DLLDIR)/credui/tests/credui_test.exe$(DLLEXT)
cp $(DLLDIR)/credui/tests/credui_test.exe$(DLLEXT) $@ && $(STRIP) $@
crypt32_test.exe: $(DLLDIR)/crypt32/tests/crypt32_test.exe$(DLLEXT)
cp $(DLLDIR)/crypt32/tests/crypt32_test.exe$(DLLEXT) $@ && $(STRIP) $@
cryptnet_test.exe: $(DLLDIR)/cryptnet/tests/cryptnet_test.exe$(DLLEXT)

View File

@ -85,6 +85,7 @@ cabinet_test.exe TESTRES "cabinet_test.exe"
comcat_test.exe TESTRES "comcat_test.exe"
comctl32_test.exe TESTRES "comctl32_test.exe"
comdlg32_test.exe TESTRES "comdlg32_test.exe"
credui_test.exe TESTRES "credui_test.exe"
crypt32_test.exe TESTRES "crypt32_test.exe"
cryptnet_test.exe TESTRES "cryptnet_test.exe"
d3d8_test.exe TESTRES "d3d8_test.exe"