File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,13 @@ function parseServerFirstMessage(data) {
178
178
179
179
function parseServerFinalMessage ( serverData ) {
180
180
const attrPairs = parseAttributePairs ( serverData )
181
+ const error = attrPairs . get ( 'e' )
181
182
const serverSignature = attrPairs . get ( 'v' )
183
+
184
+ if ( error ) {
185
+ throw new Error ( `SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${ error } "` )
186
+ }
187
+
182
188
if ( ! serverSignature ) {
183
189
throw new Error ( 'SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing' )
184
190
} else if ( ! isBase64 ( serverSignature ) ) {
Original file line number Diff line number Diff line change @@ -284,6 +284,23 @@ suite.test('sasl/scram', function () {
284
284
)
285
285
} )
286
286
287
+ suite . test ( 'fails when server returns an error' , function ( ) {
288
+ assert . throws (
289
+ function ( ) {
290
+ sasl . finalizeSession (
291
+ {
292
+ message : 'SASLResponse' ,
293
+ serverSignature : 'abcd' ,
294
+ } ,
295
+ 'e=no-resources'
296
+ )
297
+ } ,
298
+ {
299
+ message : 'SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "no-resources"' ,
300
+ }
301
+ )
302
+ } )
303
+
287
304
suite . test ( 'fails when server signature does not match' , function ( ) {
288
305
assert . throws (
289
306
function ( ) {
You can’t perform that action at this time.
0 commit comments