diff --git a/.gitignore b/.gitignore
index 8244db690a962a4d767bd3bb58547fcfc1d0c78f..108a21c3e7c8a7edf2cdad864569a05978f6b9ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile.in b/Makefile.in
index 1de6a53ee768dd8f6fbaee49e12bf91ba763d4d4..96d395b775c7db64c8adab4c87a06ec4c7b3386f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -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
diff --git a/configure b/configure
index 568c5e9b3b0a16ca10a51406749de1da3c920f2e..3616c2a88ee9d9efde435778c66dd7cf87d59ce3 100755
--- a/configure
+++ b/configure
@@ -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" ;;
diff --git a/configure.ac b/configure.ac
index f8265d7507a0962734058ad8ef4ea14f8e212bdf..65d129abd18305f3e5c1022cf692b04c7dab2d4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index f5819c21d78e8d5e2a7b8b19a82cc7bc6ee9a883..39b6c7b92b8ead8df159cf1a77c443a3edacd2c1 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -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)
 
diff --git a/dlls/credui/tests/Makefile.in b/dlls/credui/tests/Makefile.in
new file mode 100644
index 0000000000000000000000000000000000000000..6a61271f223d220754943a833e0906ea9dcde6ed
--- /dev/null
+++ b/dlls/credui/tests/Makefile.in
@@ -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
diff --git a/dlls/credui/tests/credui.c b/dlls/credui/tests/credui.c
new file mode 100644
index 0000000000000000000000000000000000000000..692e586b57f03f2001da27de58f1b50684cf5b0e
--- /dev/null
+++ b/dlls/credui/tests/credui.c
@@ -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();
+}
diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in
index 56197e4c1601b0c33a4b63c06e01416bc60e40a0..d640848d2e81f5f3ae04f22139eb5d1f250cde0e 100644
--- a/programs/winetest/Makefile.in
+++ b/programs/winetest/Makefile.in
@@ -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)
diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc
index b34931a78ae1ead9a9381a8dfc4a7c8dabec85cd..de1f7e9579d4714220675cc31953373be3b78309 100644
--- a/programs/winetest/winetest.rc
+++ b/programs/winetest/winetest.rc
@@ -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"