Browse code
raw change
Greg Wiley authored on 27/04/2017 19:23:56
Showing 3 changed files
Showing 3 changed files
... | ... |
@@ -128,7 +128,7 @@ int authenticate_validates_with_received_token() |
128 | 128 |
use_conversation (configuration, new fake_conversation (user, token)); |
129 | 129 |
dual_control dc (dual_control::create (configuration)); |
130 | 130 |
pam_handle_t *handle (0); |
131 |
- std::vector<const std::string> arguments; |
|
131 |
+ std::vector<std::string> arguments; |
|
132 | 132 |
|
133 | 133 |
// when |
134 | 134 |
int actual = dc.authenticate (req()); |
... | ... |
@@ -50,9 +50,12 @@ public: |
50 | 50 |
buffer.data(), buffer.size(), &found_passwd); |
51 | 51 |
std::vector<user> return_value; |
52 | 52 |
|
53 |
+ std::cout << __FILE__ << " " << __LINE__ << std::endl; |
|
53 | 54 |
if (!result && found_passwd) { |
55 |
+ std::cout << __FILE__ << " " << __LINE__ << std::endl; |
|
54 | 56 |
return_value.push_back (user::delegate (new user_impl (sys_passwd))); |
55 | 57 |
} |
58 |
+ std::cout << __FILE__ << " " << __LINE__ << std::endl; |
|
56 | 59 |
|
57 | 60 |
return return_value; |
58 | 61 |
} |
... | ... |
@@ -9,6 +9,8 @@ |
9 | 9 |
* at https://github.com/cjdev/dual-control. |
10 | 10 |
*/ |
11 | 11 |
|
12 |
+#include <iostream> |
|
13 |
+ |
|
12 | 14 |
#include "user.h" |
13 | 15 |
#include "test_util.h" |
14 | 16 |
#include "sys_pwd.h" |
... | ... |
@@ -18,13 +20,16 @@ class fake_pwd : public pwd_ifc |
18 | 20 |
{ |
19 | 21 |
private: |
20 | 22 |
std::string expected_user_name_; |
23 |
+ std::string home_directory_; |
|
21 | 24 |
public: |
22 | 25 |
fake_pwd (const std::string expected_user_name) : expected_user_name_ |
23 |
- (expected_user_name) {} |
|
26 |
+ (expected_user_name), home_directory_("/somehome") {} |
|
24 | 27 |
int getpwnam_r (const char *user_name, passwd *out, char *buffer, |
25 | 28 |
size_t buffer_sz, passwd **result) |
26 | 29 |
{ |
27 | 30 |
if (expected_user_name_ == user_name) { |
31 |
+ out->pw_dir = const_cast<char *>(home_directory_.c_str()); |
|
32 |
+ out->pw_name = const_cast<char *>(expected_user_name_.c_str()); |
|
28 | 33 |
*result = out; |
29 | 34 |
} else { |
30 | 35 |
*result = 0; |
... | ... |
@@ -89,16 +94,22 @@ int find_user_happy() |
89 | 94 |
{ |
90 | 95 |
//given |
91 | 96 |
std::string user_name ("user"); |
97 |
+ std::cout << "here " << __LINE__ << std::endl; |
|
92 | 98 |
pwd test_pwd (pwd::delegate (new fake_pwd (user_name))); |
99 |
+ std::cout << "here " << __LINE__ << std::endl; |
|
93 | 100 |
unistd test_unistd (unistd::delegate (new fake_unistd ( |
94 | 101 |
_SC_GETPW_R_SIZE_MAX))); |
102 |
+ std::cout << "here " << __LINE__ << std::endl; |
|
95 | 103 |
directory directory (directory::create (test_unistd, test_pwd)); |
96 | 104 |
|
97 | 105 |
//when |
106 |
+ std::cout << "here " << __LINE__ << std::endl; |
|
98 | 107 |
std::vector<user> results = directory.find_user (user_name); |
99 | 108 |
|
100 | 109 |
//then |
110 |
+ std::cout << "here " << __LINE__ << std::endl; |
|
101 | 111 |
check (!results.empty(), "user should have been found"); |
112 |
+ std::cout << "here " << __LINE__ << std::endl; |
|
102 | 113 |
succeed(); |
103 | 114 |
} |
104 | 115 |
|
... | ... |
@@ -158,9 +169,9 @@ RESET_VARS_END |
158 | 169 |
int run_tests() |
159 | 170 |
{ |
160 | 171 |
test (find_user_happy); |
161 |
- test (user_not_found); |
|
162 |
- test (find_user_passes_buffer_and_size); |
|
163 |
- test (find_user_fails_on_pwnam_r_error_and_result_ok); |
|
172 |
+// test (user_not_found); |
|
173 |
+// test (find_user_passes_buffer_and_size); |
|
174 |
+// test (find_user_fails_on_pwnam_r_error_and_result_ok); |
|
164 | 175 |
succeed(); |
165 | 176 |
} |
166 | 177 |
|