Browse code
handle colon at begin and end
Greg Wiley authored on 17/04/2017 17:42:41
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -63,7 +63,7 @@ int returns_correct_user_name() { |
63 | 63 |
succeed(); |
64 | 64 |
} |
65 | 65 |
|
66 |
-int returns_empty_string_with_bad_input() { |
|
66 |
+int returns_empty_user_and_token_when_no_colon() { |
|
67 | 67 |
//given |
68 | 68 |
pam_handle_t *pamh; |
69 | 69 |
pam_p pam = (pam_p)new fake_pam("sally"); |
... | ... |
@@ -77,13 +77,44 @@ int returns_empty_string_with_bad_input() { |
77 | 77 |
succeed(); |
78 | 78 |
} |
79 | 79 |
|
80 |
+int returns_empty_token_when_colon_end() { |
|
81 |
+ //given |
|
82 |
+ pam_handle_t *pamh; |
|
83 |
+ pam_p pam = (pam_p)new fake_pam("sally:"); |
|
84 |
+ |
|
85 |
+ //when |
|
86 |
+ pam_token_conversation conversation(pamh, pam); |
|
87 |
+ |
|
88 |
+ //then |
|
89 |
+ check(conversation.user_name() == "sally", "did not return empty user name"); |
|
90 |
+ check(conversation.token() == "", "did not return empty token"); |
|
91 |
+ succeed(); |
|
92 |
+} |
|
93 |
+ |
|
94 |
+int returns_empty_user_when_colon_begin() { |
|
95 |
+ //given |
|
96 |
+ pam_handle_t *pamh; |
|
97 |
+ pam_p pam = (pam_p)new fake_pam(":token"); |
|
98 |
+ |
|
99 |
+ //when |
|
100 |
+ pam_token_conversation conversation(pamh, pam); |
|
101 |
+ |
|
102 |
+ //then |
|
103 |
+ check(conversation.user_name() == "", "did not return empty user name"); |
|
104 |
+ check(conversation.token() == "token", "did not return empty token"); |
|
105 |
+ succeed(); |
|
106 |
+} |
|
107 |
+ |
|
108 |
+ |
|
80 | 109 |
RESET_VARS_START |
81 | 110 |
RESET_VARS_END |
82 | 111 |
|
83 | 112 |
int run_tests() { |
84 | 113 |
test(returns_correct_token); |
85 | 114 |
test(returns_correct_user_name); |
86 |
- test(returns_empty_string_with_bad_input); |
|
115 |
+ test(returns_empty_user_and_token_when_no_colon); |
|
116 |
+ test(returns_empty_token_when_colon_end); |
|
117 |
+ test(returns_empty_user_when_colon_begin); |
|
87 | 118 |
succeed(); |
88 | 119 |
} |
89 | 120 |
|