@@ -18,6 +18,13 @@ const parentContext = {
1818 description : 'test-description' ,
1919} ;
2020
21+ const withUtf8CharsContext = {
22+ type : 'test字type' ,
23+ name : 'test漢字name' ,
24+ id : '9000☺' ,
25+ description : 'test-description' ,
26+ } ;
27+
2128describe ( 'trace' , ( ) => {
2229 let esServer : kbnTestServer . TestElasticsearchUtils ;
2330 let root : ReturnType < typeof kbnTestServer . createRoot > ;
@@ -384,6 +391,35 @@ describe('trace', () => {
384391 expect ( response . body ) . toEqual ( parentContext ) ;
385392 } ) ;
386393
394+ it ( 'supports UTF-8 characters' , async ( ) => {
395+ const { http } = await root . setup ( ) ;
396+ const { createRouter } = http ;
397+
398+ const router = createRouter ( '' ) ;
399+ router . get ( { path : '/execution-context' , validate : false } , async ( context , req , res ) => {
400+ const { headers } = await context . core . elasticsearch . client . asCurrentUser . ping (
401+ { } ,
402+ { meta : true }
403+ ) ;
404+ return res . ok ( { body : headers || { } } ) ;
405+ } ) ;
406+
407+ await root . start ( ) ;
408+ const response = await kbnTestServer . request
409+ . get ( root , '/execution-context' )
410+ . set ( 'x-opaque-id' , 'utf-test' )
411+ . set ( new ExecutionContextContainer ( withUtf8CharsContext ) . toHeader ( ) )
412+ . expect ( 200 ) ;
413+
414+ const rawOpaqueId = response . body [ 'x-opaque-id' ] ;
415+ expect ( rawOpaqueId ) . toEqual (
416+ 'utf-test;kibana:test%E5%AD%97type:test%E6%BC%A2%E5%AD%97name:9000%E2%98%BA'
417+ ) ;
418+ expect ( decodeURIComponent ( rawOpaqueId ) ) . toEqual (
419+ 'utf-test;kibana:test字type:test漢字name:9000☺'
420+ ) ;
421+ } ) ;
422+
387423 it ( 'execution context is the same for all the lifecycle events' , async ( ) => {
388424 const { executionContext, http } = await root . setup ( ) ;
389425 const {
0 commit comments