Browse code
formatting
Greg Wiley authored on 19/04/2017 17:48:43
Showing 20 changed files
Showing 20 changed files
- argument.cc
- argument_test.cc
- conversation.cc
- conversation.h
- conversation_test.cc
- dual_control.cc
- dual_control_test.cc
- logger.h
- logging.cc
- pam.cc
- pam.h
- test_support.h
- token.cc
- token.h
- token_test.cc
- user.cc
- user.h
- user_test.cc
- validator.h
- validator_test.cc
... | ... |
@@ -7,7 +7,6 @@ |
7 | 7 |
#include "test_util.h" |
8 | 8 |
#include "pam.h" |
9 | 9 |
|
10 |
- |
|
11 | 10 |
class fake_pam_conversation : public pam_conversation |
12 | 11 |
{ |
13 | 12 |
private: |
... | ... |
@@ -133,7 +132,6 @@ public: |
133 | 132 |
} |
134 | 133 |
}; |
135 | 134 |
|
136 |
- |
|
137 | 135 |
int returns_correct_token() |
138 | 136 |
{ |
139 | 137 |
//given |
... | ... |
@@ -158,7 +156,6 @@ int returns_correct_user_name() |
158 | 156 |
fake_pam_conversation ("sally:token"); |
159 | 157 |
pam_p pam = (pam_p)new fake_pam (fake_conversation); |
160 | 158 |
|
161 |
- |
|
162 | 159 |
//when |
163 | 160 |
pam_token_conversation conversation (pamh, pam); |
164 | 161 |
|
... | ... |
@@ -260,7 +257,6 @@ int prompts_user_with_correct_text() |
260 | 257 |
match_prompt_text_conversation ("Dual control token: "); |
261 | 258 |
pam_p pam = (pam_p)new fake_pam (match_conversation); |
262 | 259 |
|
263 |
- |
|
264 | 260 |
// when / then |
265 | 261 |
try { |
266 | 262 |
pam_token_conversation conversation (pamh, pam); |
... | ... |
@@ -279,7 +275,6 @@ int prompts_user_with_correct_style() |
279 | 275 |
match_prompt_style_conversation (PAM_PROMPT_ECHO_OFF); |
280 | 276 |
pam_p pam = (pam_p)new fake_pam (match_conversation); |
281 | 277 |
|
282 |
- |
|
283 | 278 |
// when / then |
284 | 279 |
try { |
285 | 280 |
pam_token_conversation conversation (pamh, pam); |
... | ... |
@@ -347,4 +342,3 @@ int main (int argc, char *args[]) |
347 | 342 |
return !run_tests(); |
348 | 343 |
} |
349 | 344 |
|
350 |
- |
... | ... |
@@ -7,14 +7,12 @@ |
7 | 7 |
#include "logger.h" |
8 | 8 |
#include "test_util.h" |
9 | 9 |
|
10 |
- |
|
11 | 10 |
template<class T> |
12 | 11 |
std::shared_ptr<T> share (T *t) |
13 | 12 |
{ |
14 | 13 |
return std::shared_ptr<T> (t); |
15 | 14 |
} |
16 | 15 |
|
17 |
- |
|
18 | 16 |
void use_validator (dual_control_configuration &config, |
19 | 17 |
validator_ifc *value) |
20 | 18 |
{ |
... | ... |
@@ -88,7 +86,6 @@ public: |
88 | 86 |
} |
89 | 87 |
}; |
90 | 88 |
|
91 |
- |
|
92 | 89 |
int setcred_returns_success() |
93 | 90 |
{ |
94 | 91 |
//given |
... | ... |
@@ -221,7 +218,6 @@ int logs_authentication_failure() |
221 | 218 |
succeed(); |
222 | 219 |
} |
223 | 220 |
|
224 |
- |
|
225 | 221 |
RESET_VARS_START |
226 | 222 |
RESET_VARS_END |
227 | 223 |
|
... | ... |
@@ -241,4 +237,3 @@ int main (int argc, char *argv[]) |
241 | 237 |
return !runtests(); |
242 | 238 |
} |
243 | 239 |
|
244 |
- |
... | ... |
@@ -25,7 +25,6 @@ FILE *fake_fopen (const char *path, const char *mode); |
25 | 25 |
char *fake_fgets (char *buf, int n, FILE *fp); |
26 | 26 |
int fake_fclose (FILE *fp); |
27 | 27 |
|
28 |
- |
|
29 | 28 |
#ifdef UNIT_TEST |
30 | 29 |
// SYSLOG |
31 | 30 |
#define openlog(IDENT, LOGOPT, FACILITY) fake_openlog(IDENT, LOGOPT, FACILITY) |
... | ... |
@@ -21,7 +21,6 @@ int fake_getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, |
21 | 21 |
return !ok; |
22 | 22 |
} |
23 | 23 |
|
24 |
- |
|
25 | 24 |
const char *fake_stat_path = ""; |
26 | 25 |
int fake_stat (const char *path, struct stat *stat) |
27 | 26 |
{ |
... | ... |
@@ -61,11 +60,8 @@ int fake_fclose (FILE *fp) |
61 | 60 |
return 0; |
62 | 61 |
} |
63 | 62 |
|
64 |
- |
|
65 | 63 |
// STDIO |
66 | 64 |
|
67 |
- |
|
68 |
- |
|
69 | 65 |
RESET_VARS_START |
70 | 66 |
fake_user = "msmith"; |
71 | 67 |
fake_user_token = "123456"; |
... | ... |
@@ -75,7 +71,6 @@ fake_fopen_path = fake_stat_path; |
75 | 71 |
fake_fopen_mode = "r"; |
76 | 72 |
RESET_VARS_END |
77 | 73 |
|
78 |
- |
|
79 | 74 |
int validate_compares_to_user_token() |
80 | 75 |
{ |
81 | 76 |
|
... | ... |
@@ -129,4 +124,3 @@ int main (int argc, char **argv) |
129 | 124 |
return rval; |
130 | 125 |
} |
131 | 126 |
|
132 |
- |
... | ... |
@@ -3,7 +3,6 @@ |
3 | 3 |
#include "user.h" |
4 | 4 |
#include "test_util.h" |
5 | 5 |
|
6 |
- |
|
7 | 6 |
bool gets_home_directory() |
8 | 7 |
{ |
9 | 8 |
//given |
... | ... |
@@ -21,7 +20,6 @@ bool gets_home_directory() |
21 | 20 |
return expected_home_directory == actual_home_directory; |
22 | 21 |
} |
23 | 22 |
|
24 |
- |
|
25 | 23 |
std::shared_ptr<struct passwd> fake_passwd; |
26 | 24 |
int fake_getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, |
27 | 25 |
size_t bufsize, struct passwd **result) |
... | ... |
@@ -85,5 +83,3 @@ int main (int argc, char *argv[]) |
85 | 83 |
return !run_tests(); |
86 | 84 |
} |
87 | 85 |
|
88 |
- |
|
89 |
- |
... | ... |
@@ -36,7 +36,6 @@ public: |
36 | 36 |
} |
37 | 37 |
}; |
38 | 38 |
|
39 |
- |
|
40 | 39 |
bool validator_validates() |
41 | 40 |
{ |
42 | 41 |
|
... | ... |
@@ -48,11 +47,9 @@ bool validator_validates() |
48 | 47 |
directory_p directory (new fake_directory (user_name)); |
49 | 48 |
old_validator validator (directory, user_token_supplier); |
50 | 49 |
|
51 |
- |
|
52 | 50 |
// when |
53 | 51 |
bool actual = validator.validate (user_name, "token"); |
54 | 52 |
|
55 |
- |
|
56 | 53 |
// then |
57 | 54 |
check (actual, "should be valid"); |
58 | 55 |
succeed(); |
... | ... |
@@ -68,11 +65,9 @@ bool validator_fails_unknown_user() |
68 | 65 |
directory_p directory (new fake_directory); |
69 | 66 |
old_validator validator (directory, user_token_supplier); |
70 | 67 |
|
71 |
- |
|
72 | 68 |
// when |
73 | 69 |
bool actual = validator.validate ("notuser", token); |
74 | 70 |
|
75 |
- |
|
76 | 71 |
// then |
77 | 72 |
check (!actual, "should not be valid"); |
78 | 73 |
succeed(); |
... | ... |
@@ -87,11 +82,9 @@ bool validator_fails_incorrect_token() |
87 | 82 |
directory_p directory (new fake_directory (user_name)); |
88 | 83 |
old_validator validator (directory, user_token_supplier); |
89 | 84 |
|
90 |
- |
|
91 | 85 |
// when |
92 | 86 |
bool actual = validator.validate (user_name, "token"); |
93 | 87 |
|
94 |
- |
|
95 | 88 |
// then |
96 | 89 |
check (!actual, "should not be valid"); |
97 | 90 |
succeed(); |