@@ -40,6 +40,7 @@ describe("Client _getPass1", function () {
4040 client . _getPass1 ( { } , "1234" , [ "oidc" ] , [ ] , [ ] , function ( err , data ) {
4141 expect ( err ) . to . exist ;
4242 expect ( err . message ) . to . equal ( "Cryptography error: -14" ) ;
43+ expect ( data ) . to . be . null ;
4344 done ( ) ;
4445 } ) ;
4546 } ) ;
@@ -49,6 +50,8 @@ describe("Client _getPass1", function () {
4950 sinon . stub ( client . crypto , "calculatePass1" ) . returns ( { U : "" , UT : "" } ) ;
5051
5152 client . _getPass1 ( { } , "1234" , [ "dvs-auth" ] , [ ] , [ ] , function ( err , data ) {
53+ expect ( err ) . to . be . null ;
54+ expect ( data ) . to . deep . equal ( { success : true } ) ;
5255 expect ( requestStub . firstCall . args [ 0 ] . data . scope ) . to . deep . equal ( [ "dvs-auth" ] ) ;
5356 done ( ) ;
5457 } ) ;
@@ -97,6 +100,7 @@ describe("Client _getPass2", function () {
97100 client . _getPass2 ( { } , [ "oidc" ] , "yHex" , [ ] , [ ] , function ( err , data ) {
98101 expect ( err ) . to . exist ;
99102 expect ( err . message ) . to . equal ( "Cryptography error" ) ;
103+ expect ( data ) . to . be . null ;
100104 done ( ) ;
101105 } ) ;
102106 } ) ;
@@ -119,6 +123,7 @@ describe("Client _finishAuthentication", function () {
119123
120124 client . _finishAuthentication ( "test@example.com" , 1234 , [ "oidc" ] , "authOTT" , function ( err , data ) {
121125 expect ( err ) . to . exist ;
126+ expect ( data ) . to . deep . equal ( { status : 400 } ) ;
122127 done ( ) ;
123128 } ) ;
124129 } ) ;
@@ -268,10 +273,11 @@ describe("Client _authentication", function () {
268273 it ( "should go through the authentication flow" , function ( done ) {
269274 var getPass1Stub = sinon . stub ( client , "_getPass1" ) . yields ( null , { } ) ;
270275 var getPass2Stub = sinon . stub ( client , "_getPass2" ) . yields ( null , { } ) ;
271- var finishAuthenticationStub = sinon . stub ( client , "_finishAuthentication" ) . yields ( null , true ) ;
276+ var finishAuthenticationStub = sinon . stub ( client , "_finishAuthentication" ) . yields ( null , { success : true } ) ;
272277
273278 client . _authentication ( "test@example.com" , "1234" , [ 'oidc' ] , function ( err , data ) {
274279 expect ( err ) . to . be . null ;
280+ expect ( data ) . to . deep . equal ( { success : true } ) ;
275281 expect ( getPass1Stub . calledOnce ) . to . be . true ;
276282 expect ( getPass2Stub . calledOnce ) . to . be . true ;
277283 expect ( finishAuthenticationStub . calledOnce ) . to . be . true ;
@@ -284,6 +290,7 @@ describe("Client _authentication", function () {
284290
285291 client . _authentication ( "test@example.com" , "1234" , [ 'oidc' ] , function ( err , data ) {
286292 expect ( err ) . to . exist ;
293+ expect ( data ) . to . be . null ;
287294 done ( ) ;
288295 } ) ;
289296 } ) ;
@@ -294,6 +301,7 @@ describe("Client _authentication", function () {
294301 client . _authentication ( "test@example.com" , "1234" , [ 'oidc' ] , function ( err , data ) {
295302 expect ( err ) . to . exist ;
296303 expect ( err . message ) . to . equal ( "Revoked" ) ;
304+ expect ( data ) . to . be . null ;
297305 done ( ) ;
298306 } ) ;
299307 } ) ;
@@ -303,6 +311,7 @@ describe("Client _authentication", function () {
303311
304312 client . _authentication ( "test@example.com" , "1234" , [ 'oidc' ] , function ( err , data ) {
305313 expect ( err ) . to . exist ;
314+ expect ( data ) . to . be . null ;
306315 done ( ) ;
307316 } ) ;
308317 } ) ;
@@ -313,6 +322,7 @@ describe("Client _authentication", function () {
313322
314323 client . _authentication ( "test@example.com" , "1234" , [ 'oidc' ] , function ( err , data ) {
315324 expect ( err ) . to . exist ;
325+ expect ( data ) . to . be . null ;
316326 done ( ) ;
317327 } ) ;
318328 } ) ;
@@ -340,6 +350,7 @@ describe("Client _authentication", function () {
340350 client . _authentication ( "test@example.com" , "1234" , [ "jwt" ] , function ( err , data ) {
341351 expect ( err ) . to . exist ;
342352 expect ( err . message ) . to . equal ( "Authentication fail" ) ;
353+ expect ( data ) . to . be . null ;
343354 done ( ) ;
344355 } ) ;
345356 } ) ;
@@ -354,6 +365,7 @@ describe("Client _authentication", function () {
354365 client . _authentication ( "test@example.com" , "1234" , [ "jwt" ] , function ( err , data ) {
355366 expect ( err ) . to . exist ;
356367 expect ( err . message ) . to . equal ( "Unsuccessful authentication" ) ;
368+ expect ( data ) . to . be . null ;
357369 done ( ) ;
358370 } ) ;
359371 } ) ;
@@ -370,6 +382,7 @@ describe("Client _authentication", function () {
370382 client . _authentication ( "test@example.com" , "1234" , [ "jwt" ] , function ( err , data ) {
371383 expect ( err ) . to . exist ;
372384 expect ( err . message ) . to . equal ( "Revoked" ) ;
385+ expect ( data ) . to . be . null ;
373386 expect ( userWriteSpy . calledOnce ) . to . be . true ;
374387 expect ( userWriteSpy . firstCall . args [ 0 ] ) . to . equal ( "test@example.com" ) ;
375388 expect ( userWriteSpy . firstCall . args [ 1 ] . state ) . to . equal ( "REVOKED" ) ;
@@ -504,6 +517,7 @@ describe("Client authenticateWithNotificationPayload", function () {
504517 client . authenticateWithNotificationPayload ( { qrURL : "https://example.com/mobile/auth#accessID" } , "1234" , function ( err , data ) {
505518 expect ( err ) . to . exist ;
506519 expect ( err . message ) . to . equal ( "Invalid push notification payload" ) ;
520+ expect ( data ) . to . be . null ;
507521 done ( ) ;
508522 } ) ;
509523 } ) ;
@@ -512,6 +526,7 @@ describe("Client authenticateWithNotificationPayload", function () {
512526 client . authenticateWithNotificationPayload ( { userID : "test@example.com" } , "1234" , function ( err , data ) {
513527 expect ( err ) . to . exist ;
514528 expect ( err . message ) . to . equal ( "Invalid push notification payload" ) ;
529+ expect ( data ) . to . be . null ;
515530 done ( ) ;
516531 } ) ;
517532 } ) ;
@@ -554,6 +569,7 @@ describe("Client generateQuickCode", function () {
554569 client . generateQuickCode ( "test@example.com" , "1234" , function ( err , data ) {
555570 expect ( err ) . to . exist ;
556571 expect ( err . message ) . to . equal ( "Authentication fail" ) ;
572+ expect ( data ) . to . be . null ;
557573 done ( ) ;
558574 } ) ;
559575 } ) ;
@@ -565,6 +581,7 @@ describe("Client generateQuickCode", function () {
565581 client . generateQuickCode ( "test@example.com" , "1234" , function ( err , data ) {
566582 expect ( err ) . to . exist ;
567583 expect ( err . message ) . to . equal ( "Request error" ) ;
584+ expect ( data ) . to . be . null ;
568585 done ( ) ;
569586 } ) ;
570587 } ) ;
0 commit comments