aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-05-05 17:18:22 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-05-05 17:20:34 +0200
commit99d168a532894cafd6648547c1ac30dff2a62c43 (patch)
tree3a859c58f59ce997a37606105226397d163aab82
parent589051f3ef91ab1bc3029de3952907dea81c1f88 (diff)
downloadlibpam-freerdp2-99d168a532894cafd6648547c1ac30dff2a62c43.tar.gz
libpam-freerdp2-99d168a532894cafd6648547c1ac30dff2a62c43.tar.bz2
libpam-freerdp2-99d168a532894cafd6648547c1ac30dff2a62c43.zip
unit tests: Fix build and re-enable them.
-rwxr-xr-xdebian/rules2
-rw-r--r--src/pam-freerdp2-private.h32
-rw-r--r--tests/Makefile.am154
-rw-r--r--tests/mock_guest.c2
-rw-r--r--tests/mock_pam.c25
-rw-r--r--tests/mock_pam.h11
-rw-r--r--tests/test-freerdp2-auth.c (renamed from tests/test-freerdp-auth.c)0
-rw-r--r--tests/test-freerdp2-wrapper.cc (renamed from tests/test-freerdp-wrapper.cc)2
8 files changed, 158 insertions, 70 deletions
diff --git a/debian/rules b/debian/rules
index 19ce1e8..0969a92 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,7 +9,7 @@ include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/utils.mk
-#DEB_MAKE_CHECK_TARGET = check
+DEB_MAKE_CHECK_TARGET = check
# Remove .a and .la files from /lib/security
remove-cruft::
diff --git a/src/pam-freerdp2-private.h b/src/pam-freerdp2-private.h
new file mode 100644
index 0000000..74663ef
--- /dev/null
+++ b/src/pam-freerdp2-private.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2018 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+ * Author libpam-freerdp (where we forked from): Ted Gould <ted@canonical.com>
+ */
+
+#ifndef _PAM_FREERDP2_PRIVATE_H_
+#define _PAM_FREERDP2_PRIVATE_H_
+
+PAM_EXTERN int
+pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, const char **argv);
+PAM_EXTERN int
+pam_sm_open_session (pam_handle_t *pamh, int flags, int argc, const char ** argv);
+PAM_EXTERN int
+pam_sm_close_session (pam_handle_t *pamh, int flags, int argc, const char **argv);
+PAM_EXTERN int
+pam_sm_setcred (pam_handle_t *pamh, int flags, int argc, const char ** argv);
+
+#endif //_PAM_FREERDP2_PRIVATE_H_
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e69b0ab..29b0a98 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,74 +1,124 @@
+NULL =
+
CLEANFILES =
DISTCLEANFILES =
EXTRA_DIST =
-TESTS = \
- test-freerdpclient-wrapper
+TESTS = \
+ test-freerdp2-wrapper \
+ $(NULL)
+
+check_PROGRAMS = \
+ test-freerdp2-auth \
+ $(TESTS) \
+ $(NULL)
+
+CLEANFILES += \
+ test-freerdp2-auth \
+ $(TESTS) \
+ $(NULL)
-check_PROGRAMS = \
- test-freerdp-auth \
- $(TESTS)
+AM_CPPFLAGS = $(GTEST_CPPFLAGS) \
+ $(REMOTE_APPS_MANAGER_CFLAGS) \
+ -I${top_srcdir}/src -Wall -Werror \
+ $(NULL)
-AM_CPPFLAGS = $(GTEST_CPPFLAGS) \
- $(REMOTE_APPS_MANAGER_CFLAGS) \
- -I${top_srcdir}/src -Wall -Werror
-AM_CXXFLAGS = $(GTEST_CXXFLAGS) \
- $(REMOTE_APPS_MANAGER_CFLAGS)
+AM_CXXFLAGS = $(GTEST_CXXFLAGS) \
+ $(REMOTE_APPS_MANAGER_CFLAGS) \
+ $(NULL)
-AM_CFLAGS = \
- -Wall \
- -g
+AM_CFLAGS = \
+ -Wall \
+ -g \
+ $(NULL)
##########################
# Google Test Test Suite #
##########################
-check_LIBRARIES = libgtest.a
-
-nodist_libgtest_a_SOURCES = \
- $(GTEST_SOURCE)/src/gtest-all.cc \
- $(GTEST_SOURCE)/src/gtest_main.cc
-
-libgtest_a_CPPFLAGS = \
- $(GTEST_CPPFLAGS) -w \
- $(AM_CPPFLAGS)
-libgtest_a_CXXFLAGS = \
- $(AM_CXXFLAGS)
+check_LIBRARIES = libgtest.a libgtest_main.a
+
+gtest-all.cc:
+ cp $(GTEST_SOURCE)/src/gtest-all.cc .
+
+gtest_main.cc:
+ cp $(GTEST_SOURCE)/src/gtest_main.cc .
+
+CLEANFILES += \
+ gtest-all.cc \
+ gtest_main.cc \
+ $(NULL)
+
+nodist_libgtest_a_SOURCES = \
+ gtest-all.cc \
+ $(NULL)
+nodist_libgtest_main_a_SOURCES = \
+ gtest_main.cc \
+ $(NULL)
+
+libgtest_a_CPPFLAGS = \
+ $(GTEST_CPPFLAGS) -w \
+ $(AM_CPPFLAGS) \
+ $(NULL)
+libgtest_main_a_CPPFLAGS = \
+ $(GTEST_CPPFLAGS) -w \
+ $(AM_CPPFLAGS) \
+ $(NULL)
+
+libgtest_a_CXXFLAGS = \
+ $(AM_CXXFLAGS) \
+ $(NULL)
+libgtest_main_a_CXXFLAGS = \
+ $(AM_CXXFLAGS) \
+ $(NULL)
##########################
# Wrapper
##########################
-test_freerdp_wrapper: test-freerdp-auth
-
-test_freerdpclient_wrapper_SOURCES = \
- mock_pam.c mock_pam.h \
- mock_guest.c mock_guest.h \
- test-freerdp-wrapper.cc
-
-test_freerdpclient_wrapper_LDADD = \
- $(top_builddir)/src/libfreerdp2core.la \
- libgtest.a
-
-test_freerdpclient_wrapper_CFLAGS = \
- $(AM_CXXFLAGS) \
- -I${top_srcdir}/src
-
-test_freerdpclient_wrapper_CXXFLAGS = \
- $(AM_CXXFLAGS) \
- -I${top_srcdir}/src
-
-test_freerdpclient_wrapper_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -DAUTH_CHECK="\"$(abs_builddir)/test-freerdp-auth\"" \
- -DLIBPAM_COMPILE
-
-test_freerdpclient_wrapper_LDFLAGS = \
- -pthread
+test_freerdp2_wrapper: test-freerdp2-auth
+
+test_freerdp2_wrapper_SOURCES = \
+ mock_pam.c mock_pam.h \
+ mock_guest.c mock_guest.h \
+ test-freerdp2-wrapper.cc \
+ $(NULL)
+
+test_freerdp2_wrapper_LDADD = \
+ libgtest.a libgtest_main.a \
+ ${top_srcdir}/src/pam_freerdp2.la \
+ $(FREERDP2_LIBS) \
+ $(WINPR2_LIBS) \
+ $(NULL)
+
+test_freerdp2_wrapper_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I${top_srcdir}/include \
+ -I${top_srcdir}/src \
+ $(GTEST_CPPFLAGS) \
+ $(FREERDP2_CPPFLAGS) \
+ $(WINPR2_CPPFLAGS) \
+ $(NULL)
+
+test_freerdp2_wrapper_CXXFLAGS = \
+ $(AM_CXXFLAGS) \
+ -DAUTH_CHECK="\"$(abs_builddir)/test-freerdp2-auth\"" \
+ $(GTEST_CXXFLAGS) \
+ $(FREERDP2_CXXFLAGS) \
+ $(WINPR2_CXXFLAGS) \
+ $(NULL)
+
+test_freerdp2_wrapper_LDFLAGS = \
+ $(GTEST_LDFLAGS) \
+ $(FREERDP2_LDFLAGS) \
+ $(WINPR2_LDFLAGS) \
+ -pthread \
+ $(NULL)
##########################
# Auth tool
##########################
-test_freerdp_auth_SOURCES = \
- test-freerdp-auth.c
+test_freerdp2_auth_SOURCES = \
+ test-freerdp2-auth.c \
+ $(NULL)
diff --git a/tests/mock_guest.c b/tests/mock_guest.c
index f52a2d6..7505eec 100644
--- a/tests/mock_guest.c
+++ b/tests/mock_guest.c
@@ -118,5 +118,3 @@ socket_sucker ()
return -1;
}
}
-
-
diff --git a/tests/mock_pam.c b/tests/mock_pam.c
index 7aef55a..ce57973 100644
--- a/tests/mock_pam.c
+++ b/tests/mock_pam.c
@@ -9,6 +9,7 @@
#include <string.h>
#include "mock_pam.h"
+#include "pam-freerdp2.h"
struct pam_handle {
void *item[PAM_NUM_ITEMS];
@@ -29,15 +30,15 @@ int fake_conv (int num_msg, const struct pam_message **msg,
response->resp_retcode = 0;
- if (strcmp((*msg)->msg, "login:") == 0)
+ if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_GUESTLOGIN) == 0)
response->resp = strdup ("guest"); /* IMPORTANT: this needs to be in /etc/passwd */
- else if (strcmp((*msg)->msg, "remote login:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_USER) == 0)
response->resp = strdup ("ruser");
- else if (strcmp((*msg)->msg, "remote host:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_HOST) == 0)
response->resp = strdup ("protocol://rhost/dummy");
- else if (strcmp((*msg)->msg, "password:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_PASSWORD) == 0)
response->resp = strdup ("password");
- else if (strcmp((*msg)->msg, "domain:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_DOMAIN) == 0)
response->resp = strdup ("domain");
else
return PAM_SYMBOL_ERR; /* leaks... */
@@ -58,15 +59,15 @@ int fake_conv_empty_password (int num_msg, const struct pam_message **msg,
response->resp_retcode = 0;
- if (strcmp((*msg)->msg, "login:") == 0)
+ if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_GUESTLOGIN) == 0)
response->resp = strdup ("guest"); /* IMPORTANT: this needs to be in /etc/passwd */
- else if (strcmp((*msg)->msg, "remote login:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_USER) == 0)
response->resp = strdup ("ruser");
- else if (strcmp((*msg)->msg, "remote host:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_HOST) == 0)
response->resp = strdup ("protocol://rhost/dummy");
- else if (strcmp((*msg)->msg, "password:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_PASSWORD) == 0)
response->resp = strdup ("");
- else if (strcmp((*msg)->msg, "domain:") == 0)
+ else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_DOMAIN) == 0)
response->resp = strdup ("domain");
else
return PAM_SYMBOL_ERR; /* leaks... */
@@ -103,7 +104,7 @@ pam_handle_t *pam_handle_empty_pswd_new (void)
return newh;
}
-int pam_get_item (const pam_handle_t *pamh, int type, const void **value)
+int PAM_NONNULL((1)) pam_get_item (const pam_handle_t *pamh, int type, const void **value)
{
if (pamh == NULL)
return PAM_SYSTEM_ERR;
@@ -118,7 +119,7 @@ int pam_get_item (const pam_handle_t *pamh, int type, const void **value)
return PAM_SUCCESS;
}
-int pam_set_item (pam_handle_t *pamh, int type, const void *value)
+int PAM_NONNULL((1)) pam_set_item (pam_handle_t *pamh, int type, const void *value)
{
if (pamh == NULL)
return PAM_SYSTEM_ERR;
diff --git a/tests/mock_pam.h b/tests/mock_pam.h
index c9c4f36..7fe0467 100644
--- a/tests/mock_pam.h
+++ b/tests/mock_pam.h
@@ -1,13 +1,16 @@
/*
+ * Copyright © 2012-2013 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>.
* Copyright © 2012 Canonical Ltd. All rights reserved.
*
- * Author(s): David Barth <david.barth@canonical.com>
+ * Author(s): Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+ * David Barth <david.barth@canonical.com>
*
*/
#ifndef __MOCK_PAM_H__
#define __MOCK_PAM_H__
+#define LIBPAM_COMPILE
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
#include <security/pam_appl.h>
@@ -18,7 +21,9 @@ typedef struct pam_handle pam_handle_t;
pam_handle_t *pam_handle_new (void);
pam_handle_t *pam_handle_empty_pswd_new (void);
-int pam_get_item (const pam_handle_t *pamh, int type, const void **value);
-int pam_set_item (pam_handle_t *pamh, int type, const void *value);
+int PAM_NONNULL((1))
+pam_get_item (const pam_handle_t *pamh, int type, const void **value);
+int PAM_NONNULL((1))
+pam_set_item (pam_handle_t *pamh, int type, const void *value);
#endif
diff --git a/tests/test-freerdp-auth.c b/tests/test-freerdp2-auth.c
index a83885e..a83885e 100644
--- a/tests/test-freerdp-auth.c
+++ b/tests/test-freerdp2-auth.c
diff --git a/tests/test-freerdp-wrapper.cc b/tests/test-freerdp2-wrapper.cc
index 3ce9ea6..33b4168 100644
--- a/tests/test-freerdp-wrapper.cc
+++ b/tests/test-freerdp2-wrapper.cc
@@ -12,6 +12,8 @@ extern "C" {
#include "mock_pam.h"
#include "mock_guest.h"
+#include "pam-freerdp2-private.h"
+
int freerdpclient_wrapper (int argc, char * argv[]);
const char * auth_check_path = AUTH_CHECK;