@@ -99,6 +99,105 @@ fn test_table_name_too_long() -> TestResult {
99
99
Ok ( ( ) )
100
100
}
101
101
102
+ #[ test]
103
+ fn test_auth_inconsistent_keys ( ) -> TestResult {
104
+ test_bad_key ( "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" , // d
105
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" , // x
106
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" ,
107
+ "Misconfigured ILP authentication keys: InconsistentComponents. Hint: Check the keys for a possible typo."
108
+ )
109
+ }
110
+
111
+ #[ test]
112
+ fn test_auth_bad_base64_private_key ( ) -> TestResult {
113
+ test_bad_key (
114
+ "bad key" , // d
115
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" , // x
116
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" , // y
117
+ "Misconfigured ILP authentication keys. Could not decode private authentication key: invalid Base64 encoding. Hint: Check the keys for a possible typo."
118
+ )
119
+ }
120
+
121
+ #[ test]
122
+ fn test_auth_private_key_too_long ( ) -> TestResult {
123
+ test_bad_key (
124
+ "ZkxLWUVhb0ViOWxybjNua3dMREEtTV94bnVGT2RTdDl5MFo3X3ZXU0hMVWZMS1lFYW9FYjlscm4zbmt3TERBLU1feG51Rk9kU3Q5eTBaN192V1NITFU" ,
125
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" , // x
126
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" , // y
127
+ "Misconfigured ILP authentication keys: InvalidComponent. Hint: Check the keys for a possible typo."
128
+ )
129
+ }
130
+
131
+ #[ test]
132
+ fn test_auth_public_key_x_too_long ( ) -> TestResult {
133
+ test_bad_key (
134
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" ,
135
+ "ZkxLWUVhb0ViOWxybjNua3dMREEtTV94bnVGT2RTdDl5MFo3X3ZXU0hMVWZMS1lFYW9FYjlscm4zbmt3TERBLU1feG51Rk9kU3Q5eTBaN192V1NITFU" , // x
136
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" , // y
137
+ "Misconfigured ILP authentication keys. Public key x is too long. Hint: Check the keys for a possible typo."
138
+ )
139
+ }
140
+
141
+ #[ test]
142
+ fn test_auth_public_key_y_too_long ( ) -> TestResult {
143
+ test_bad_key (
144
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" ,
145
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" , // x
146
+ "ZkxLWUVhb0ViOWxybjNua3dMREEtTV94bnVGT2RTdDl5MFo3X3ZXU0hMVWZMS1lFYW9FYjlscm4zbmt3TERBLU1feG51Rk9kU3Q5eTBaN192V1NITFU" , // y
147
+ "Misconfigured ILP authentication keys. Public key y is too long. Hint: Check the keys for a possible typo."
148
+ )
149
+ }
150
+
151
+ #[ test]
152
+ fn test_auth_bad_base64_public_key_x ( ) -> TestResult {
153
+ test_bad_key (
154
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" , // d
155
+ "bad base64 encoding" , // x
156
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" , // y
157
+ "Misconfigured ILP authentication keys. Could not decode public key x: invalid Base64 encoding. Hint: Check the keys for a possible typo."
158
+ )
159
+ }
160
+
161
+ #[ test]
162
+ fn test_auth_bad_base64_public_key_y ( ) -> TestResult {
163
+ test_bad_key (
164
+ "fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU" , // d
165
+ "Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac" , // x
166
+ "bad base64 encoding" , // y
167
+ "Misconfigured ILP authentication keys. Could not decode public key y: invalid Base64 encoding. Hint: Check the keys for a possible typo."
168
+ )
169
+ }
170
+
171
+ fn test_bad_key (
172
+ priv_key : & str ,
173
+ pub_key_x : & str ,
174
+ pub_key_y : & str ,
175
+ expected_error_msg : & str ,
176
+ ) -> TestResult {
177
+ let server = MockServer :: new ( ) ?;
178
+ let lsb = server
179
+ . lsb ( )
180
+ . auth ( "testUser1" , priv_key, pub_key_x, pub_key_y) ;
181
+ let sender = lsb. connect ( ) ;
182
+
183
+ match sender {
184
+ Ok ( _) => panic ! ( "Expected an error due to bad key, but connect succeeded." ) ,
185
+ Err ( err) => {
186
+ assert_eq ! (
187
+ err. code( ) ,
188
+ ErrorCode :: AuthError ,
189
+ "Expected an ErrorCode::AuthError"
190
+ ) ;
191
+ assert_eq ! (
192
+ err. msg( ) ,
193
+ expected_error_msg,
194
+ "Error message did not match expected message."
195
+ ) ;
196
+ }
197
+ }
198
+ Ok ( ( ) )
199
+ }
200
+
102
201
#[ test]
103
202
fn test_timestamp_overloads ( ) -> TestResult {
104
203
let tbl_name = TableName :: new ( "tbl_name" ) ?;
0 commit comments