@@ -21,6 +21,15 @@ var chai = require('chai'),
2121 SignatureVersion : '1' ,
2222 SigningCertURL : "https://localhost:56789/cert.pem"
2323 } ,
24+ validLambdaMessage = {
25+ Type : 'Notification' ,
26+ MessageId : '1' ,
27+ TopicArn : 'arn' ,
28+ Message : 'A Lambda message for you!' ,
29+ Timestamp : ( new Date ) . toISOString ( ) ,
30+ SignatureVersion : '1' ,
31+ SigningCertUrl : "https://localhost:56789/cert.pem"
32+ } ,
2433 validSubscriptionControlMessage = _ . extend ( { } , validMessage , {
2534 Token : 'Nonce' ,
2635 SubscribeURL : 'https://www.amazonaws.com' ,
@@ -46,6 +55,7 @@ describe('Message Validator', function () {
4655 var crypto = require ( 'crypto' ) ,
4756 validMessages = [
4857 validMessage ,
58+ validLambdaMessage ,
4959 validSubscriptionControlMessage ,
5060 utf8Message ,
5161 utf8SubscriptionControlMessage
@@ -113,6 +123,23 @@ describe('Message Validator', function () {
113123 } ) ;
114124 } ) ;
115125
126+ it ( 'should accept Lambda payloads with improper "Url" casing' , function ( done ) {
127+ ( new MessageValidator ( / ^ l o c a l h o s t : 5 6 7 8 9 $ / ) )
128+ . validate ( validLambdaMessage , function ( err , message ) {
129+ if ( err ) {
130+ return done ( new Error ( 'The validator should have accepted this message.' ) ) ;
131+ }
132+
133+ try {
134+ expect ( message . Message )
135+ . to . equal ( 'A Lambda message for you!' ) ;
136+ done ( ) ;
137+ } catch ( e ) {
138+ done ( e ) ;
139+ }
140+ } ) ;
141+ } ) ;
142+
116143 it ( 'should reject hashes residing on an invalid domain' , function ( done ) {
117144 ( new MessageValidator )
118145 . validate ( validMessage , function ( err , message ) {
0 commit comments