diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 154 | ||||
-rw-r--r-- | tests/mock_guest.c | 2 | ||||
-rw-r--r-- | tests/mock_pam.c | 25 | ||||
-rw-r--r-- | tests/mock_pam.h | 11 | ||||
-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 |
6 files changed, 125 insertions, 69 deletions
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; |