@@ -216,6 +216,22 @@ describe('Connect Tests', function () {
216216 const handshakeDocument = await prepareHandshakeDocument ( authContext ) ;
217217 expect ( handshakeDocument . client . env ) . to . not . have . property ( 'name' ) ;
218218 } ) ;
219+
220+ context ( 'when 512 byte size limit is exceeded' , async ( ) => {
221+ it ( `should not 'env' property in client` , async ( ) => {
222+ let longAppName = '' ;
223+ // make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
224+ for ( let i = 0 ; i < 493 ; i ++ ) {
225+ longAppName += 's' ;
226+ }
227+ const longAuthContext = {
228+ connection : { } ,
229+ options : { ...CONNECT_DEFAULTS , metadata : { appName : longAppName } }
230+ } ;
231+ const handshakeDocument = await prepareHandshakeDocument ( longAuthContext ) ;
232+ expect ( handshakeDocument . client ) . to . not . have . property ( 'env' ) ;
233+ } ) ;
234+ } ) ;
219235 } ) ;
220236
221237 context ( 'when kubernetes and FAAS are both present' , ( ) => {
@@ -245,6 +261,28 @@ describe('Connect Tests', function () {
245261 const handshakeDocument = await prepareHandshakeDocument ( authContext ) ;
246262 expect ( handshakeDocument . client . env . name ) . to . equal ( 'aws.lambda' ) ;
247263 } ) ;
264+
265+ context ( 'when 512 byte size limit is exceeded' , async ( ) => {
266+ it ( `should not have 'container' property in client.env` , async ( ) => {
267+ let longAppName = '' ;
268+ // make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
269+ for ( let i = 0 ; i < 485 ; i ++ ) {
270+ longAppName += 's' ;
271+ }
272+ const longAuthContext = {
273+ connection : { } ,
274+ options : {
275+ ...CONNECT_DEFAULTS ,
276+ metadata : {
277+ appName : longAppName ,
278+ env : { name : 'aws.lambda' }
279+ }
280+ }
281+ } ;
282+ const handshakeDocument = await prepareHandshakeDocument ( longAuthContext ) ;
283+ expect ( handshakeDocument . client ) . to . not . have . property ( 'env' ) ;
284+ } ) ;
285+ } ) ;
248286 } ) ;
249287
250288 context ( 'when container nor FAAS env is not present (empty string case)' , ( ) => {
0 commit comments