aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am36
-rw-r--r--tests/mock_guest.c25
-rw-r--r--tests/mock_pam.c64
-rw-r--r--tests/mock_pam.h1
-rw-r--r--tests/test-freerdp-auth.c (renamed from tests/test-freerdp2-auth.c)0
-rw-r--r--tests/test-freerdp-wrapper.cc (renamed from tests/test-freerdp2-wrapper.cc)6
6 files changed, 72 insertions, 60 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 29b0a98..e945201 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,16 +5,16 @@ DISTCLEANFILES =
EXTRA_DIST =
TESTS = \
- test-freerdp2-wrapper \
+ test-freerdp-wrapper \
$(NULL)
check_PROGRAMS = \
- test-freerdp2-auth \
+ test-freerdp-auth \
$(TESTS) \
$(NULL)
CLEANFILES += \
- test-freerdp2-auth \
+ test-freerdp-auth \
$(TESTS) \
$(NULL)
@@ -76,42 +76,34 @@ libgtest_main_a_CXXFLAGS = \
# Wrapper
##########################
-test_freerdp2_wrapper: test-freerdp2-auth
+test_freerdp_wrapper: test-freerdp-auth
-test_freerdp2_wrapper_SOURCES = \
+test_freerdp_wrapper_SOURCES = \
mock_pam.c mock_pam.h \
mock_guest.c mock_guest.h \
- test-freerdp2-wrapper.cc \
+ test-freerdp-wrapper.cc \
$(NULL)
-test_freerdp2_wrapper_LDADD = \
+test_freerdp_wrapper_LDADD = \
libgtest.a libgtest_main.a \
- ${top_srcdir}/src/pam_freerdp2.la \
- $(FREERDP2_LIBS) \
- $(WINPR2_LIBS) \
+ ${top_srcdir}/src/pam_freerdp.la \
$(NULL)
-test_freerdp2_wrapper_CPPFLAGS = \
+test_freerdp_wrapper_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I${top_srcdir}/include \
-I${top_srcdir}/src \
$(GTEST_CPPFLAGS) \
- $(FREERDP2_CPPFLAGS) \
- $(WINPR2_CPPFLAGS) \
$(NULL)
-test_freerdp2_wrapper_CXXFLAGS = \
+test_freerdp_wrapper_CXXFLAGS = \
$(AM_CXXFLAGS) \
- -DAUTH_CHECK="\"$(abs_builddir)/test-freerdp2-auth\"" \
+ -DAUTH_CHECK="\"$(abs_builddir)/test-freerdp-auth\"" \
$(GTEST_CXXFLAGS) \
- $(FREERDP2_CXXFLAGS) \
- $(WINPR2_CXXFLAGS) \
$(NULL)
-test_freerdp2_wrapper_LDFLAGS = \
+test_freerdp_wrapper_LDFLAGS = \
$(GTEST_LDFLAGS) \
- $(FREERDP2_LDFLAGS) \
- $(WINPR2_LDFLAGS) \
-pthread \
$(NULL)
@@ -119,6 +111,6 @@ test_freerdp2_wrapper_LDFLAGS = \
# Auth tool
##########################
-test_freerdp2_auth_SOURCES = \
- test-freerdp2-auth.c \
+test_freerdp_auth_SOURCES = \
+ test-freerdp-auth.c \
$(NULL)
diff --git a/tests/mock_guest.c b/tests/mock_guest.c
index 7673995..dad9d5d 100644
--- a/tests/mock_guest.c
+++ b/tests/mock_guest.c
@@ -22,39 +22,44 @@ static struct passwd guest = { "guest",
"/tmp",
"/bin/true" };
struct passwd *
-getpwnam (const char *username)
+getpwnam (const char __attribute__((unused)) *username)
{ return &guest; }
int
-setgroups(size_t size, const gid_t *list)
+setgroups(size_t __attribute__((unused)) size,
+ const gid_t __attribute__((unused)) *list)
{
errno = EPERM;
return -1;
}
int
-setgid(gid_t gid)
+setgid(gid_t __attribute__((unused)) gid)
{ return 0; }
int
-setuid(uid_t uid)
+setuid(uid_t __attribute__((unused)) uid)
{ return 0; }
int
-setegid(gid_t gid)
+setegid(gid_t __attribute__((unused)) gid)
{ return 0; }
int
-seteuid(uid_t uid)
+seteuid(uid_t __attribute__((unused)) uid)
{ return 0; }
-int chmod(const char *path, mode_t mode)
+int chmod(const char __attribute__((unused)) *path,
+ mode_t __attribute__((unused)) mode)
{ return 0; }
-int chown(const char *path, uid_t owner, gid_t group)
+int chown(const char __attribute__((unused)) *path,
+ uid_t __attribute__((unused)) owner,
+ gid_t __attribute__((unused)) group)
{ return 0; }
-int execvp(const char *file, char *const argv[])
+int execvp(const char __attribute__((unused)) *file,
+ char __attribute__((unused)) *const argv[])
{
return 0;
}
@@ -84,7 +89,7 @@ socket_sucker ()
serv_addr.sun_family = AF_UNIX;
- int printsize = snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path) - 1, "%s/%s", home, ".freerdp2-socket");
+ unsigned long int printsize = (unsigned long int)snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path) - 1, "%s/%s", home, ".freerdp-socket");
if (printsize > sizeof(serv_addr.sun_path) - 1 || printsize < 0) {
return -1;
}
diff --git a/tests/mock_pam.c b/tests/mock_pam.c
index ce57973..ca222ba 100644
--- a/tests/mock_pam.c
+++ b/tests/mock_pam.c
@@ -9,7 +9,7 @@
#include <string.h>
#include "mock_pam.h"
-#include "pam-freerdp2.h"
+#include "pam-freerdp.h"
struct pam_handle {
void *item[PAM_NUM_ITEMS];
@@ -19,37 +19,44 @@ struct pam_handle {
/* note: the other fields have been omitted */
};
-int fake_conv (int num_msg, const struct pam_message **msg,
- struct pam_response **resp, void *appdata_ptr)
+int fake_conv (int __attribute__((unused)) num_msg,
+ const struct pam_message **msg,
+ struct pam_response **resp,
+ void __attribute__((unused)) *appdata_ptr)
{
struct pam_response *response = NULL;
response = malloc (sizeof (struct pam_response));
- if (response == NULL)
+ if (response == NULL) {
return PAM_BUF_ERR;
+ }
response->resp_retcode = 0;
- if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_GUESTLOGIN) == 0)
+ if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_GUESTLOGIN) == 0) {
response->resp = strdup ("guest"); /* IMPORTANT: this needs to be in /etc/passwd */
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_USER) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_USER) == 0) {
response->resp = strdup ("ruser");
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_HOST) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_HOST) == 0) {
response->resp = strdup ("protocol://rhost/dummy");
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_PASSWORD) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_PASSWORD) == 0) {
response->resp = strdup ("password");
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_DOMAIN) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_DOMAIN) == 0) {
response->resp = strdup ("domain");
- else
+ } else {
+ free(response);
return PAM_SYMBOL_ERR; /* leaks... */
+ }
*resp = response;
return PAM_SUCCESS;
}
-int fake_conv_empty_password (int num_msg, const struct pam_message **msg,
- struct pam_response **resp, void *appdata_ptr)
+int fake_conv_empty_password (int __attribute__((unused)) num_msg,
+ const struct pam_message **msg,
+ struct pam_response **resp,
+ void __attribute__((unused)) *appdata_ptr)
{
struct pam_response *response = NULL;
response = malloc (sizeof (struct pam_response));
@@ -59,18 +66,20 @@ int fake_conv_empty_password (int num_msg, const struct pam_message **msg,
response->resp_retcode = 0;
- if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_GUESTLOGIN) == 0)
+ if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_GUESTLOGIN) == 0) {
response->resp = strdup ("guest"); /* IMPORTANT: this needs to be in /etc/passwd */
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_USER) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_USER) == 0) {
response->resp = strdup ("ruser");
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_HOST) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_HOST) == 0) {
response->resp = strdup ("protocol://rhost/dummy");
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_PASSWORD) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_PASSWORD) == 0) {
response->resp = strdup ("");
- else if (strcmp((*msg)->msg, PAM_FREERDP2_PROMPT_DOMAIN) == 0)
+ } else if (strcmp((*msg)->msg, PAM_FREERDP_PROMPT_DOMAIN) == 0) {
response->resp = strdup ("domain");
- else
+ } else {
+ free(response);
return PAM_SYMBOL_ERR; /* leaks... */
+ }
*resp = response;
@@ -109,20 +118,22 @@ int PAM_NONNULL((1)) pam_get_item (const pam_handle_t *pamh, int type, const voi
if (pamh == NULL)
return PAM_SYSTEM_ERR;
- if (type == PAM_CONV)
+ if (type == PAM_CONV) {
*value = pamh->conv;
- else if (pamh->item[type] != NULL)
+ } else if (pamh->item[type] != NULL) {
*value = pamh->item[type];
- else
+ } else {
*value = NULL; /* will result in a prompt conversation */
+ }
return PAM_SUCCESS;
}
int PAM_NONNULL((1)) pam_set_item (pam_handle_t *pamh, int type, const void *value)
{
- if (pamh == NULL)
+ if (pamh == NULL) {
return PAM_SYSTEM_ERR;
+ }
void **slot, *tmp;
size_t nsize, osize;
@@ -130,10 +141,12 @@ int PAM_NONNULL((1)) pam_set_item (pam_handle_t *pamh, int type, const void *val
slot = &pamh->item[type];
osize = nsize = 0;
- if (*slot != NULL)
+ if (*slot != NULL) {
osize = strlen((const char *)*slot) + 1;
- if (value != NULL)
+ }
+ if (value != NULL) {
nsize = strlen((const char *)value) + 1;
+ }
if (*slot != NULL) {
memset(*slot, 0xd0, osize);
@@ -141,8 +154,9 @@ int PAM_NONNULL((1)) pam_set_item (pam_handle_t *pamh, int type, const void *val
}
if (value != NULL) {
- if ((tmp = malloc(nsize)) == NULL)
+ if ((tmp = malloc(nsize)) == NULL) {
return PAM_BUF_ERR;
+ }
memcpy(tmp, value, nsize);
} else {
tmp = NULL;
diff --git a/tests/mock_pam.h b/tests/mock_pam.h
index 7fe0467..df837df 100644
--- a/tests/mock_pam.h
+++ b/tests/mock_pam.h
@@ -11,6 +11,7 @@
#define __MOCK_PAM_H__
#define LIBPAM_COMPILE
+#include <security/_pam_types.h>
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
#include <security/pam_appl.h>
diff --git a/tests/test-freerdp2-auth.c b/tests/test-freerdp-auth.c
index a83885e..a83885e 100644
--- a/tests/test-freerdp2-auth.c
+++ b/tests/test-freerdp-auth.c
diff --git a/tests/test-freerdp2-wrapper.cc b/tests/test-freerdp-wrapper.cc
index 33b4168..7555cb1 100644
--- a/tests/test-freerdp2-wrapper.cc
+++ b/tests/test-freerdp-wrapper.cc
@@ -12,7 +12,7 @@ extern "C" {
#include "mock_pam.h"
#include "mock_guest.h"
-#include "pam-freerdp2-private.h"
+#include "pam-freerdp-private.h"
int freerdpclient_wrapper (int argc, char * argv[]);
@@ -43,13 +43,13 @@ namespace {
virtual void SetUp() {
// Code here will be called immediately after the constructor (right
// before each test).
- unlink("/tmp/.freerdp2-socket");
+ unlink("/tmp/.freerdp-socket");
}
virtual void TearDown() {
// Code here will be called immediately after each test (right
// before the destructor).
- unlink("/tmp/.freerdp2-socket");
+ unlink("/tmp/.freerdp-socket");
}
// Objects declared here can be used by all tests in the test case for Foo.