@@ -166,7 +166,38 @@ describe("processTemplate", () => {
166166 if ( ! baseUrl || ! secretKey ) return ;
167167
168168 expect ( baseUrl ) . toContain ( mockSchema . projectName ) ;
169- expect ( secretKey . split ( "=" ) [ 1 ] ) . toHaveLength ( 64 ) ;
169+ const base64Value = secretKey . split ( "=" ) [ 1 ] ;
170+ expect ( base64Value ) . toBeDefined ( ) ;
171+ if ( ! base64Value ) return ;
172+ expect ( base64Value ) . toMatch ( / ^ [ A - Z a - z 0 - 9 + / ] + = { 0 , 2 } $ / ) ;
173+ expect ( base64Value . length ) . toBeGreaterThanOrEqual ( 86 ) ;
174+ expect ( base64Value . length ) . toBeLessThanOrEqual ( 88 ) ;
175+ } ) ;
176+
177+ it ( "should process env vars when provided as an array" , ( ) => {
178+ const template : CompleteTemplate = {
179+ metadata : { } as any ,
180+ variables : { } ,
181+ config : {
182+ domains : [ ] ,
183+ env : [
184+ 'CLOUDFLARE_TUNNEL_TOKEN="<INSERT TOKEN>"' ,
185+ 'ANOTHER_VAR="some value"' ,
186+ "DOMAIN=${domain}" ,
187+ ] ,
188+ mounts : [ ] ,
189+ } ,
190+ } ;
191+
192+ const result = processTemplate ( template , mockSchema ) ;
193+ expect ( result . envs ) . toHaveLength ( 3 ) ;
194+
195+ // Should preserve exact format for static values
196+ expect ( result . envs [ 0 ] ) . toBe ( 'CLOUDFLARE_TUNNEL_TOKEN="<INSERT TOKEN>"' ) ;
197+ expect ( result . envs [ 1 ] ) . toBe ( 'ANOTHER_VAR="some value"' ) ;
198+
199+ // Should process variables in array items
200+ expect ( result . envs [ 2 ] ) . toContain ( mockSchema . projectName ) ;
170201 } ) ;
171202
172203 it ( "should allow using utility functions directly in env vars" , ( ) => {
@@ -195,7 +226,12 @@ describe("processTemplate", () => {
195226 if ( ! randomDomainEnv || ! secretKeyEnv ) return ;
196227
197228 expect ( randomDomainEnv ) . toContain ( mockSchema . projectName ) ;
198- expect ( secretKeyEnv . split ( "=" ) [ 1 ] ) . toHaveLength ( 32 ) ;
229+ const base64Value = secretKeyEnv . split ( "=" ) [ 1 ] ;
230+ expect ( base64Value ) . toBeDefined ( ) ;
231+ if ( ! base64Value ) return ;
232+ expect ( base64Value ) . toMatch ( / ^ [ A - Z a - z 0 - 9 + / ] + = { 0 , 2 } $ / ) ;
233+ expect ( base64Value . length ) . toBeGreaterThanOrEqual ( 42 ) ;
234+ expect ( base64Value . length ) . toBeLessThanOrEqual ( 44 ) ;
199235 } ) ;
200236 } ) ;
201237
@@ -325,17 +361,31 @@ describe("processTemplate", () => {
325361 if ( ! baseUrl || ! secretKey || ! totpKey ) return ;
326362
327363 expect ( baseUrl ) . toContain ( mockSchema . projectName ) ;
328- expect ( secretKey . split ( "=" ) [ 1 ] ) . toHaveLength ( 64 ) ;
329- expect ( totpKey . split ( "=" ) [ 1 ] ) . toHaveLength ( 32 ) ;
364+
365+ // Check base64 lengths and format
366+ const secretKeyValue = secretKey . split ( "=" ) [ 1 ] ;
367+ const totpKeyValue = totpKey . split ( "=" ) [ 1 ] ;
368+
369+ expect ( secretKeyValue ) . toBeDefined ( ) ;
370+ expect ( totpKeyValue ) . toBeDefined ( ) ;
371+ if ( ! secretKeyValue || ! totpKeyValue ) return ;
372+
373+ expect ( secretKeyValue ) . toMatch ( / ^ [ A - Z a - z 0 - 9 + / ] + = { 0 , 2 } $ / ) ;
374+ expect ( secretKeyValue . length ) . toBeGreaterThanOrEqual ( 86 ) ;
375+ expect ( secretKeyValue . length ) . toBeLessThanOrEqual ( 88 ) ;
376+
377+ expect ( totpKeyValue ) . toMatch ( / ^ [ A - Z a - z 0 - 9 + / ] + = { 0 , 2 } $ / ) ;
378+ expect ( totpKeyValue . length ) . toBeGreaterThanOrEqual ( 42 ) ;
379+ expect ( totpKeyValue . length ) . toBeLessThanOrEqual ( 44 ) ;
330380
331381 // Check mounts
332382 expect ( result . mounts ) . toHaveLength ( 1 ) ;
333383 const mount = result . mounts [ 0 ] ;
334384 expect ( mount ) . toBeDefined ( ) ;
335385 if ( ! mount ) return ;
336386 expect ( mount . content ) . toContain ( mockSchema . projectName ) ;
337- expect ( mount . content ) . toMatch ( / s e c r e t = [ A - Z a - z 0 - 9 + / ] { 64 } / ) ;
338- expect ( mount . content ) . toMatch ( / t o t p = [ A - Z a - z 0 - 9 + / ] { 32 } / ) ;
387+ expect ( mount . content ) . toMatch ( / s e c r e t = [ A - Z a - z 0 - 9 + / ] { 86 , 88 } / ) ;
388+ expect ( mount . content ) . toMatch ( / t o t p = [ A - Z a - z 0 - 9 + / ] { 42 , 44 } / ) ;
339389 } ) ;
340390 } ) ;
341391
0 commit comments