@@ -31,6 +31,8 @@ var DEBUGGEE_ID = 'bar';
3131var API = 'https://clouddebugger.googleapis.com' ;
3232var REGISTER_PATH = '/v2/controller/debuggees/register' ;
3333var BPS_PATH = '/v2/controller/debuggees/' + DEBUGGEE_ID + '/breakpoints' ;
34+ var EXPRESSIONS_REGEX =
35+ / E x p r e s s i o n s a n d c o n d i t i o n s a r e n o t a l l o w e d .* h t t p s : \/ \/ g o o \. g l \/ S h S m 6 r / ;
3436
3537var fakeCredentials = require ( './fixtures/gcloud-credentials.json' ) ;
3638
@@ -53,6 +55,12 @@ var errorBp = {
5355 location : { path : 'fixtures/foo.js' , line : 2 }
5456} ;
5557
58+ function verifyBreakpointRejection ( re , body ) {
59+ var status = body . breakpoint . status ;
60+ var hasCorrectDescription = status . description . format . match ( re ) ;
61+ return status . isError && hasCorrectDescription ;
62+ }
63+
5664describe ( 'Debuglet' , function ( ) {
5765 describe ( 'setup' , function ( ) {
5866 before ( function ( ) { oldGP = process . env . GCLOUD_PROJECT ; } ) ;
@@ -529,23 +537,20 @@ describe('Debuglet', function() {
529537 debuglet . config_ . allowExpressions = false ;
530538
531539 var scope = nock ( API )
532- . post ( REGISTER_PATH )
533- . reply ( 200 , { debuggee : { id : DEBUGGEE_ID } } )
534- . get ( BPS_PATH + '?success_on_timeout=true' )
535- . reply ( 200 , { breakpoints : [ {
536- id : 'test' ,
537- action : 'CAPTURE' ,
538- condition : 'x === 5' ,
539- location : { path : 'fixtures/foo.js' , line : 2 }
540- } ] } )
541- . put ( BPS_PATH + '/test' ,
542- function ( body ) {
543- var status = body . breakpoint . status ;
544- var hasCorrectDescription = status . description . format . indexOf (
545- 'Expressions and conditions are not allowed by default.' ) === 0 ;
546- return status . isError && hasCorrectDescription ;
547- } )
548- . reply ( 200 ) ;
540+ . post ( REGISTER_PATH )
541+ . reply ( 200 , { debuggee : { id : DEBUGGEE_ID } } )
542+ . get ( BPS_PATH + '?success_on_timeout=true' )
543+ . reply ( 200 , {
544+ breakpoints : [ {
545+ id : 'test' ,
546+ action : 'CAPTURE' ,
547+ condition : 'x === 5' ,
548+ location : { path : 'fixtures/foo.js' , line : 2 }
549+ } ]
550+ } )
551+ . put ( BPS_PATH + '/test' ,
552+ verifyBreakpointRejection . bind ( null , EXPRESSIONS_REGEX ) )
553+ . reply ( 200 ) ;
549554
550555 debuglet . once ( 'registered' , function reg ( id ) {
551556 assert . equal ( id , DEBUGGEE_ID ) ;
@@ -570,23 +575,20 @@ describe('Debuglet', function() {
570575 debuglet . config_ . allowExpressions = false ;
571576
572577 var scope = nock ( API )
573- . post ( REGISTER_PATH )
574- . reply ( 200 , { debuggee : { id : DEBUGGEE_ID } } )
575- . get ( BPS_PATH + '?success_on_timeout=true' )
576- . reply ( 200 , { breakpoints : [ {
577- id : 'test' ,
578- action : 'CAPTURE' ,
579- expressions : [ 'x' ] ,
580- location : { path : 'fixtures/foo.js' , line : 2 }
581- } ] } )
582- . put ( BPS_PATH + '/test' ,
583- function ( body ) {
584- var status = body . breakpoint . status ;
585- var hasCorrectDescription = status . description . format . indexOf (
586- 'Expressions and conditions are not allowed by default.' ) === 0 ;
587- return status . isError && hasCorrectDescription ;
588- } )
589- . reply ( 200 ) ;
578+ . post ( REGISTER_PATH )
579+ . reply ( 200 , { debuggee : { id : DEBUGGEE_ID } } )
580+ . get ( BPS_PATH + '?success_on_timeout=true' )
581+ . reply ( 200 , {
582+ breakpoints : [ {
583+ id : 'test' ,
584+ action : 'CAPTURE' ,
585+ expressions : [ 'x' ] ,
586+ location : { path : 'fixtures/foo.js' , line : 2 }
587+ } ]
588+ } )
589+ . put ( BPS_PATH + '/test' ,
590+ verifyBreakpointRejection . bind ( null , EXPRESSIONS_REGEX ) )
591+ . reply ( 200 ) ;
590592
591593 debuglet . once ( 'registered' , function reg ( id ) {
592594 assert . equal ( id , DEBUGGEE_ID ) ;
0 commit comments