aboutsummaryrefslogtreecommitdiff
path: root/tests/test-freerdp2-wrapper.cc
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 /tests/test-freerdp2-wrapper.cc
parent589051f3ef91ab1bc3029de3952907dea81c1f88 (diff)
downloadlibpam-freerdp2-99d168a532894cafd6648547c1ac30dff2a62c43.tar.gz
libpam-freerdp2-99d168a532894cafd6648547c1ac30dff2a62c43.tar.bz2
libpam-freerdp2-99d168a532894cafd6648547c1ac30dff2a62c43.zip
unit tests: Fix build and re-enable them.
Diffstat (limited to 'tests/test-freerdp2-wrapper.cc')
-rw-r--r--tests/test-freerdp2-wrapper.cc90
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/test-freerdp2-wrapper.cc b/tests/test-freerdp2-wrapper.cc
new file mode 100644
index 0000000..33b4168
--- /dev/null
+++ b/tests/test-freerdp2-wrapper.cc
@@ -0,0 +1,90 @@
+/*
+ * Copyright © 2012 Canonical Ltd. All rights reserved.
+ *
+ * Author(s): David Barth <david.barth@canonical.com>
+ *
+ */
+
+#include <gtest/gtest.h>
+
+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));
+ }
+
+}