aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
authorMandy Wu <mandy.wu@intel.com>2011-07-18 23:39:52 +0200
committerDaniel Stenberg <daniel@haxx.se>2011-07-18 23:48:53 +0200
commitaa26c2751a9edc8129ae2cff1c82ddfd0e5b1446 (patch)
treec2230508553e32bf9b6c7dba76e3f78309afddaa /tests/server
parenta6d4807d028eb82f4a99587b0a8851727ca88566 (diff)
test2005: verify ntlm single-signon
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/Makefile.inc7
-rw-r--r--tests/server/fake_ntlm.c141
2 files changed, 147 insertions, 1 deletions
diff --git a/tests/server/Makefile.inc b/tests/server/Makefile.inc
index be3f06808..6b0ee72f0 100644
--- a/tests/server/Makefile.inc
+++ b/tests/server/Makefile.inc
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd
+noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd fake_ntlm
CURLX_SRCS = \
$(top_srcdir)/lib/mprintf.c \
@@ -63,3 +63,8 @@ tftpd_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) $(UTIL) \
tftp.h
tftpd_LDADD = @TEST_SERVER_LIBS@
tftpd_CFLAGS = $(AM_CFLAGS)
+
+fake_ntlm_SOURCES = $(CURLX_SRCS) $(CURLX_HDRS) $(USEFUL) $(UTIL) \
+ fake_ntlm.c
+fake_ntlm_LDADD = @TEST_SERVER_LIBS@
+fake_ntlm_CFLAGS = $(AM_CFLAGS)
diff --git a/tests/server/fake_ntlm.c b/tests/server/fake_ntlm.c
new file mode 100644
index 000000000..624ec6b1c
--- /dev/null
+++ b/tests/server/fake_ntlm.c
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2010, Mandy Wu, <mandy.wu@intel.com>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/*
+ * This is a fake ntlm_auth, which is used for testing NTLM single-sign-on.
+ * When DEBUGBUILD is defined, libcurl invoke this tool instead of real winbind
+ * daemon helper /usr/bin/ntlm_auth. This tool will accept commands and
+ * responses with a pre-written string saved in test case test2005.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "curlx.h" /* from the private lib dir */
+#include "getpart.h"
+#include "util.h"
+
+#ifndef DEFAULT_LOGFILE
+#define DEFAULT_LOGFILE "log/fake_ntlm.log"
+#endif
+
+const char *serverlogfile = DEFAULT_LOGFILE;
+
+int main(void)
+{
+ char buf[1024];
+ FILE *stream;
+ char *filename;
+ int error;
+ char *type1_input = NULL, *type3_input = NULL;
+ char *type1_output = NULL, *type3_output = NULL;
+ size_t size = 0;
+
+ filename = test2file(2005);
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", 2005);
+ exit(1);
+ }
+ else {
+ /* get the ntlm_auth input/output */
+ error = getpart(&type1_input, &size, "ntlm_auth_type1", "input", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 1 input failed with error: %d", error);
+ exit(1);
+ }
+ }
+
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", 2005);
+ exit(1);
+ }
+ else {
+ size = 0;
+ error = getpart(&type3_input, &size, "ntlm_auth_type3", "input", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 3 input failed with error: %d", error);
+ exit(1);
+ }
+ }
+
+ while(fgets(buf, 1024, stdin)) {
+ if(strcmp(buf, type1_input) == 0) {
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", 2005);
+ exit(1);
+ }
+ else {
+ size = 0;
+ error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 1 output failed with error: %d", error);
+ exit(1);
+ }
+ }
+ printf("%s", type1_output);
+ fflush(stdout);
+ }
+ else if(strncmp(buf, type3_input, strlen(type3_input)) == 0) {
+ stream=fopen(filename, "rb");
+ if(!stream) {
+ error = ERRNO;
+ logmsg("fopen() failed with error: %d %s", error, strerror(error));
+ logmsg("Error opening file: %s", filename);
+ logmsg("Couldn't open test file %ld", 2005);
+ exit(1);
+ }
+ else {
+ size = 0;
+ error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream);
+ fclose(stream);
+ if(error || size == 0) {
+ logmsg("getpart() type 3 output failed with error: %d", error);
+ exit(1);
+ }
+ }
+ printf("%s", type3_output);
+ fflush(stdout);
+ }
+ else {
+ printf("Unknown request\n");
+ logmsg("invalid input: %s\n", buf);
+ exit(1);
+ }
+ }
+ return 1;
+}