From 96b2f26c68e621f8605b87da01030de02b90c18d Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 25 Jan 2025 12:04:05 +0100 Subject: namespacing: Add FreeRDPv3 support and drop the FreeRDP version number from project name and project files. --- tests/Makefile.am | 44 ++++++++++----------- tests/mock_guest.c | 2 +- tests/mock_pam.c | 22 +++++------ tests/test-freerdp-auth.c | 57 ++++++++++++++++++++++++++ tests/test-freerdp-wrapper.cc | 90 ++++++++++++++++++++++++++++++++++++++++++ tests/test-freerdp2-auth.c | 57 -------------------------- tests/test-freerdp2-wrapper.cc | 90 ------------------------------------------ 7 files changed, 181 insertions(+), 181 deletions(-) create mode 100644 tests/test-freerdp-auth.c create mode 100644 tests/test-freerdp-wrapper.cc delete mode 100644 tests/test-freerdp2-auth.c delete mode 100644 tests/test-freerdp2-wrapper.cc (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 29b0a98..9aac03c 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,42 @@ 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 \ + $(FREERDP_LIBS) \ + $(WINPR_LIBS) \ $(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) \ + $(FREERDP_CPPFLAGS) \ + $(WINPR_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) \ + $(FREERDP_CXXFLAGS) \ + $(WINPR_CXXFLAGS) \ $(NULL) -test_freerdp2_wrapper_LDFLAGS = \ +test_freerdp_wrapper_LDFLAGS = \ $(GTEST_LDFLAGS) \ - $(FREERDP2_LDFLAGS) \ - $(WINPR2_LDFLAGS) \ + $(FREERDP_LDFLAGS) \ + $(WINPR_LDFLAGS) \ -pthread \ $(NULL) @@ -119,6 +119,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 4d10bfb..dad9d5d 100644 --- a/tests/mock_guest.c +++ b/tests/mock_guest.c @@ -89,7 +89,7 @@ socket_sucker () serv_addr.sun_family = AF_UNIX; - unsigned long int printsize = (unsigned long int)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 f32d95f..ca222ba 100644 --- a/tests/mock_pam.c +++ b/tests/mock_pam.c @@ -9,7 +9,7 @@ #include #include "mock_pam.h" -#include "pam-freerdp2.h" +#include "pam-freerdp.h" struct pam_handle { void *item[PAM_NUM_ITEMS]; @@ -33,15 +33,15 @@ int fake_conv (int __attribute__((unused)) num_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 ("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 { free(response); @@ -66,15 +66,15 @@ int fake_conv_empty_password (int __attribute__((unused)) num_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 { free(response); diff --git a/tests/test-freerdp-auth.c b/tests/test-freerdp-auth.c new file mode 100644 index 0000000..a83885e --- /dev/null +++ b/tests/test-freerdp-auth.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2012 Canonical Ltd. + * + * 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 . + * + * Author: Ted Gould + */ + +#include +#include +#include + +int +main (int argc, char * argv[]) +{ + char password[512]; + if (argc != 4) { + printf("Not enough params"); + return -1; + } + + if (scanf("%511s", password) != 1) { + return -1; + } + + /* Check username */ + if (strcmp(argv[2], "ruser")) { + return -1; + } + + /* Check password */ + if (strcmp(password, "password")) { + return -1; + } + + /* Check domain */ + if (strcmp(argv[3], "domain")) { + return -1; + } + + /* Check hostname */ + if (strcmp(argv[1], "rhost")) { + return -1; + } + + return 0; +} diff --git a/tests/test-freerdp-wrapper.cc b/tests/test-freerdp-wrapper.cc new file mode 100644 index 0000000..7555cb1 --- /dev/null +++ b/tests/test-freerdp-wrapper.cc @@ -0,0 +1,90 @@ +/* + * Copyright © 2012 Canonical Ltd. All rights reserved. + * + * Author(s): David Barth + * + */ + +#include + +extern "C" { + +#include "mock_pam.h" +#include "mock_guest.h" + +#include "pam-freerdp-private.h" + + int freerdpclient_wrapper (int argc, char * argv[]); + +const char * auth_check_path = AUTH_CHECK; + +} + +namespace { + + // The fixture for testing class Foo. + class FreerdpclientWrapperTest : public ::testing::Test { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + FreerdpclientWrapperTest() { + // You can do set-up work for each test here. + setenv("HOME", "/tmp", 1 /* overwrite */); + } + + virtual ~FreerdpclientWrapperTest() { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() { + // Code here will be called immediately after the constructor (right + // before each test). + unlink("/tmp/.freerdp-socket"); + } + + virtual void TearDown() { + // Code here will be called immediately after each test (right + // before the destructor). + unlink("/tmp/.freerdp-socket"); + } + + // Objects declared here can be used by all tests in the test case for Foo. + }; + + TEST_F(FreerdpclientWrapperTest, canLinkTheWholeGang) { + EXPECT_EQ (1, 1); // right, that's trivial, but that means + // that I got all of the wrapper and pam to link there + } + + TEST_F(FreerdpclientWrapperTest, canHandleEmptyPassword) { + const char *argv[] = { NULL }; + + pam_handle_t *pamh = pam_handle_empty_pswd_new (); + + EXPECT_EQ (PAM_AUTH_ERR, + pam_sm_authenticate (pamh, 0, 0, argv)); + + } + + TEST_F(FreerdpclientWrapperTest, canCallPamOpenSession) { + const char *argv[] = { NULL }; + + pam_handle_t *pamh = pam_handle_new (); + + EXPECT_EQ (PAM_SUCCESS, + pam_sm_authenticate (pamh, 0, 0, argv)); + EXPECT_EQ (PAM_SUCCESS, + pam_sm_setcred (pamh, 0, 0, argv)); + + EXPECT_EQ (PAM_SUCCESS, + pam_sm_open_session (pamh, 0, 0, argv)); + EXPECT_EQ(0, socket_sucker()); + EXPECT_EQ (PAM_SUCCESS, + pam_sm_close_session (pamh, 0, 0, argv)); + } + +} diff --git a/tests/test-freerdp2-auth.c b/tests/test-freerdp2-auth.c deleted file mode 100644 index a83885e..0000000 --- a/tests/test-freerdp2-auth.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd. - * - * 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 . - * - * Author: Ted Gould - */ - -#include -#include -#include - -int -main (int argc, char * argv[]) -{ - char password[512]; - if (argc != 4) { - printf("Not enough params"); - return -1; - } - - if (scanf("%511s", password) != 1) { - return -1; - } - - /* Check username */ - if (strcmp(argv[2], "ruser")) { - return -1; - } - - /* Check password */ - if (strcmp(password, "password")) { - return -1; - } - - /* Check domain */ - if (strcmp(argv[3], "domain")) { - return -1; - } - - /* Check hostname */ - if (strcmp(argv[1], "rhost")) { - return -1; - } - - return 0; -} diff --git a/tests/test-freerdp2-wrapper.cc b/tests/test-freerdp2-wrapper.cc deleted file mode 100644 index 33b4168..0000000 --- a/tests/test-freerdp2-wrapper.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd. All rights reserved. - * - * Author(s): David Barth - * - */ - -#include - -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; - -} - -namespace { - - // The fixture for testing class Foo. - class FreerdpclientWrapperTest : public ::testing::Test { - protected: - // You can remove any or all of the following functions if its body - // is empty. - - FreerdpclientWrapperTest() { - // You can do set-up work for each test here. - setenv("HOME", "/tmp", 1 /* overwrite */); - } - - virtual ~FreerdpclientWrapperTest() { - // You can do clean-up work that doesn't throw exceptions here. - } - - // If the constructor and destructor are not enough for setting up - // and cleaning up each test, you can define the following methods: - - virtual void SetUp() { - // Code here will be called immediately after the constructor (right - // before each test). - unlink("/tmp/.freerdp2-socket"); - } - - virtual void TearDown() { - // Code here will be called immediately after each test (right - // before the destructor). - unlink("/tmp/.freerdp2-socket"); - } - - // Objects declared here can be used by all tests in the test case for Foo. - }; - - TEST_F(FreerdpclientWrapperTest, canLinkTheWholeGang) { - EXPECT_EQ (1, 1); // right, that's trivial, but that means - // that I got all of the wrapper and pam to link there - } - - TEST_F(FreerdpclientWrapperTest, canHandleEmptyPassword) { - const char *argv[] = { NULL }; - - pam_handle_t *pamh = pam_handle_empty_pswd_new (); - - EXPECT_EQ (PAM_AUTH_ERR, - pam_sm_authenticate (pamh, 0, 0, argv)); - - } - - TEST_F(FreerdpclientWrapperTest, canCallPamOpenSession) { - const char *argv[] = { NULL }; - - pam_handle_t *pamh = pam_handle_new (); - - EXPECT_EQ (PAM_SUCCESS, - pam_sm_authenticate (pamh, 0, 0, argv)); - EXPECT_EQ (PAM_SUCCESS, - pam_sm_setcred (pamh, 0, 0, argv)); - - EXPECT_EQ (PAM_SUCCESS, - pam_sm_open_session (pamh, 0, 0, argv)); - EXPECT_EQ(0, socket_sucker()); - EXPECT_EQ (PAM_SUCCESS, - pam_sm_close_session (pamh, 0, 0, argv)); - } - -} -- cgit v1.2.3