aboutsummaryrefslogtreecommitdiff
path: root/tests/test-freerdp-wrapper.cc
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-09-20 08:39:53 +0000
committerTarmac <Unknown>2012-09-20 08:39:53 +0000
commit126edd829bbf88c1a2a186a874acb4a307f3b5a9 (patch)
tree877c48d3bef1123accafba2caa953d73bc2002c5 /tests/test-freerdp-wrapper.cc
parentaa87c8fac598ef6e79a65d6f2eec93d8a4693063 (diff)
parent19c01abdd2c3a3d772cf8b7f54b819231ac4dcba (diff)
downloadlibpam-freerdp2-126edd829bbf88c1a2a186a874acb4a307f3b5a9.tar.gz
libpam-freerdp2-126edd829bbf88c1a2a186a874acb4a307f3b5a9.tar.bz2
libpam-freerdp2-126edd829bbf88c1a2a186a874acb4a307f3b5a9.zip
Adding a testing framework. Approved by Albert Astals Cid, jenkins.
Diffstat (limited to 'tests/test-freerdp-wrapper.cc')
-rw-r--r--tests/test-freerdp-wrapper.cc76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/test-freerdp-wrapper.cc b/tests/test-freerdp-wrapper.cc
new file mode 100644
index 0000000..cfe86de
--- /dev/null
+++ b/tests/test-freerdp-wrapper.cc
@@ -0,0 +1,76 @@
+/*
+ * 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"
+
+ 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, 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 (PAM_SUCCESS,
+ pam_sm_close_session (pamh, 0, 0, argv));
+ }
+
+}