@@ -16,7 +16,7 @@ describe('the video-token-server', () => {
1616 it ( 'should return an "unauthorized" error when the passcode is incorrect' , ( ) => {
1717 Date . now = ( ) => 5 ;
1818
19- handler ( mockContext , { passcode : '9876543210' } , callback ) ;
19+ handler ( mockContext , { passcode : '9876543210' , user_identity : 'test identity' } , callback ) ;
2020
2121 expect ( callback ) . toHaveBeenCalledWith ( null , {
2222 body : {
@@ -33,7 +33,7 @@ describe('the video-token-server', () => {
3333 it ( 'should return an "expired" error when the current time is past the API_PASSCODE_EXPIRY time' , ( ) => {
3434 Date . now = ( ) => 15 ;
3535
36- handler ( mockContext , { passcode : '1234566789' } , callback ) ;
36+ handler ( mockContext , { passcode : '1234566789' , user_identity : 'test identity' } , callback ) ;
3737
3838 expect ( callback ) . toHaveBeenCalledWith ( null , {
3939 body : {
@@ -48,11 +48,29 @@ describe('the video-token-server', () => {
4848 } ) ;
4949 } ) ;
5050
51- it ( 'should return a token when only the passcode is supplied' , ( ) => {
51+ it ( 'should return a "missing user_identity" error when the "user_identity" parameter is not supplied' , ( ) => {
5252 Date . now = ( ) => 5 ;
5353
5454 handler ( mockContext , { passcode : '1234566789' } , callback ) ;
5555
56+ expect ( callback ) . toHaveBeenCalledWith ( null , {
57+ body : {
58+ error : {
59+ message : 'missing user_identity' ,
60+ explanation :
61+ 'The user_identity parameter is missing.' ,
62+ } ,
63+ } ,
64+ headers : { 'Content-Type' : 'application/json' } ,
65+ statusCode : 400 ,
66+ } ) ;
67+ } ) ;
68+
69+ it ( 'should return a token when no room_name is supplied' , ( ) => {
70+ Date . now = ( ) => 5 ;
71+
72+ handler ( mockContext , { passcode : '1234566789' , user_identity : 'test identity' } , callback ) ;
73+
5674 expect ( callback ) . toHaveBeenCalledWith ( null , {
5775 body : { token : expect . any ( String ) } ,
5876 headers : { 'Content-Type' : 'application/json' } ,
@@ -62,6 +80,7 @@ describe('the video-token-server', () => {
6280 expect ( jwt . decode ( callback . mock . calls [ 0 ] [ 1 ] . body . token ) ) . toEqual ( {
6381 exp : 14400 ,
6482 grants : {
83+ identity : "test identity" ,
6584 video : { } ,
6685 } ,
6786 iat : 0 ,
0 commit comments