@@ -365,6 +365,49 @@ for (const pingProtocol of ['XML-RPC', 'REST']) {
365365 }
366366 } ) ;
367367
368+ it ( `should not notify subscribers with excessive errors` , async function ( ) {
369+ const feedPath = '/rss.xml' ,
370+ pingPath = '/feedupdated' ,
371+ resourceUrl = mock . serverUrl + feedPath ;
372+
373+ let apiurl = ( 'http-post' === protocol ? mock . serverUrl : mock . secureServerUrl ) + pingPath ,
374+ notifyProcedure = false ;
375+
376+ if ( 'xml-rpc' === protocol ) {
377+ apiurl = mock . serverUrl + '/RPC2' ;
378+ notifyProcedure = 'river.feedUpdated' ;
379+ }
380+
381+ mock . route ( 'GET' , feedPath , 200 , '<RSS Feed />' ) ;
382+ mock . route ( 'POST' , pingPath , 200 , 'Thanks for the update! :-)' ) ;
383+ mock . rpc ( notifyProcedure , rpcReturnSuccess ( true ) ) ;
384+ const subscription = await mongodb . addSubscription ( resourceUrl , notifyProcedure , apiurl , protocol ) ;
385+ subscription . ctConsecutiveErrors = config . maxConsecutiveErrors ;
386+ await mongodb . updateSubscription ( resourceUrl , subscription ) ;
387+
388+ let res = await ping ( pingProtocol , resourceUrl , returnFormat ) ;
389+
390+ expect ( res ) . status ( 200 ) ;
391+
392+ if ( 'XML-RPC' === pingProtocol ) {
393+ expect ( res . text ) . xml . equal ( rpcReturnSuccess ( true ) ) ;
394+ } else {
395+ if ( 'JSON' === returnFormat ) {
396+ expect ( res . body ) . deep . equal ( { success : true , msg : 'Thanks for the ping.' } ) ;
397+ } else {
398+ expect ( res . text ) . xml . equal ( '<result success="true" msg="Thanks for the ping."/>' ) ;
399+ }
400+ }
401+
402+ expect ( mock . requests . GET ) . property ( feedPath ) . lengthOf ( 1 , `Missing GET ${ feedPath } ` ) ;
403+
404+ if ( 'xml-rpc' === protocol ) {
405+ expect ( mock . requests . RPC2 ) . property ( notifyProcedure ) . lengthOf ( 0 , `Missing XML-RPC call ${ notifyProcedure } ` ) ;
406+ } else {
407+ expect ( mock . requests . POST ) . property ( pingPath ) . lengthOf ( 0 , `Missing POST ${ pingPath } ` ) ;
408+ }
409+ } ) ;
410+
368411 } ) ;
369412
370413} // end for pingProtocol
0 commit comments