From a9a228ea6e6d0b8d17c463ad05bbc1b7a9f0c3c5 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 9 Nov 2012 20:41:52 +0100 Subject: fix tests --- tests/test-freerdp-auth.c | 57 ------------------------------- tests/test-freerdp-wrapper.cc | 78 ------------------------------------------- tests/test-x2go-auth.c | 57 +++++++++++++++++++++++++++++++ tests/test-x2go-wrapper.cc | 78 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 135 deletions(-) delete mode 100644 tests/test-freerdp-auth.c delete mode 100644 tests/test-freerdp-wrapper.cc create mode 100644 tests/test-x2go-auth.c create mode 100644 tests/test-x2go-wrapper.cc diff --git a/tests/test-freerdp-auth.c b/tests/test-freerdp-auth.c deleted file mode 100644 index cdb8a31..0000000 --- a/tests/test-freerdp-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: Mike Gabriel - */ - -#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 deleted file mode 100644 index 67aca58..0000000 --- a/tests/test-freerdp-wrapper.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd. All rights reserved. - * - * Author(s): David Barth - * - */ - -#include - -extern "C" { - -#include "mock_pam.h" -#include "mock_guest.h" - - int x2goclient_wrapper (int argc, char * argv[]); - -const char * auth_check_path = AUTH_CHECK; - -} - -namespace { - - // The fixture for testing class Foo. - class PyhocaWrapperTest : public ::testing::Test { - protected: - // You can remove any or all of the following functions if its body - // is empty. - - PyhocaWrapperTest() { - // You can do set-up work for each test here. - setenv("HOME", "/tmp", 1 /* overwrite */); - } - - virtual ~PyhocaWrapperTest() { - // 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/.x2go-socket"); - } - - virtual void TearDown() { - // Code here will be called immediately after each test (right - // before the destructor). - unlink("/tmp/.x2go-socket"); - } - - // Objects declared here can be used by all tests in the test case for Foo. - }; - - TEST_F(PyhocaWrapperTest, 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(PyhocaWrapperTest, 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-x2go-auth.c b/tests/test-x2go-auth.c new file mode 100644 index 0000000..cdb8a31 --- /dev/null +++ b/tests/test-x2go-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: Mike Gabriel + */ + +#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-x2go-wrapper.cc b/tests/test-x2go-wrapper.cc new file mode 100644 index 0000000..67aca58 --- /dev/null +++ b/tests/test-x2go-wrapper.cc @@ -0,0 +1,78 @@ +/* + * Copyright © 2012 Canonical Ltd. All rights reserved. + * + * Author(s): David Barth + * + */ + +#include + +extern "C" { + +#include "mock_pam.h" +#include "mock_guest.h" + + int x2goclient_wrapper (int argc, char * argv[]); + +const char * auth_check_path = AUTH_CHECK; + +} + +namespace { + + // The fixture for testing class Foo. + class PyhocaWrapperTest : public ::testing::Test { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + PyhocaWrapperTest() { + // You can do set-up work for each test here. + setenv("HOME", "/tmp", 1 /* overwrite */); + } + + virtual ~PyhocaWrapperTest() { + // 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/.x2go-socket"); + } + + virtual void TearDown() { + // Code here will be called immediately after each test (right + // before the destructor). + unlink("/tmp/.x2go-socket"); + } + + // Objects declared here can be used by all tests in the test case for Foo. + }; + + TEST_F(PyhocaWrapperTest, 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(PyhocaWrapperTest, 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