package Ġlibrary . kotlin . test . io . envoy proxy . envoy mobile Ċ Ċ import Ġio . envoy proxy . envoy mobile . RequestBuilder Ċ import Ġio . envoy proxy . envoy mobile . Request Method Ċ import Ġio . envoy proxy . envoy mobile . Retry Policy Ċ import Ġio . envoy proxy . envoy mobile . Retry Rule Ċ import Ġio . envoy proxy . envoy mobile . outbound Headers Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ Ċ class ĠRequest Mapper Test Ġ{ ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` method Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" POST ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` scheme Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": scheme "]). contains Exactly (" https ") ĊĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` authority Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": authority "]). contains Exactly (" api . foo . com ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` path Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": path "]). contains Exactly ("/ foo ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` same Ġkey Ġheaders Ġare Ġjoined Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. add Header (" header _ 1 ", Ġ" value _ a ") ĊĠĠĠĠĠĠĠ Ġ. add Header (" header _ 1 ", Ġ" value _ b ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [" header _ 1 "]). contains Exactly (" value _ a ", Ġ" value _ b ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` invalid Ġsem icolon Ġprefixed Ġheader Ġkeys Ġare Ġfiltered Ġout Ġof Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. add Header (": restricted ", Ġ" value ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers ). does Not Contain Key (": restricted ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` restricted Ġheaders Ġare Ġnot Ġoverwritten Ġin Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. add Header (": scheme ", Ġ" override ") ĊĠĠĠĠĠĠĠ Ġ. add Header (": authority ", Ġ" override ") ĊĠĠĠĠĠĠĠ Ġ. add Header (": path ", Ġ" override ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": scheme "]). contains Exactly (" https ") ĊĠĠĠ ĠassertThat ( request Headers [ ": authority "]). contains Exactly (" api . foo . com ") ĊĠĠĠ ĠassertThat ( request Headers [ ": path "]). contains Exactly ("/ foo ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` request Ġheaders Ġare Ġforwarded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. add Header (" header _ 1 ", Ġ" value _ a ") ĊĠĠĠĠĠĠĠ Ġ. add Header (" header _ 2 ", Ġ" value _ b ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [" header _ 1 "]). contains Exactly (" value _ a ") ĊĠĠĠ ĠassertThat ( request Headers [" header _ 2 "]). contains Exactly (" value _ b ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retry Ġpolicy Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġretry Policy Ġ= ĠRetry Policy ( ĊĠĠĠĠĠĠĠ Ġmax Retry Count Ġ= Ġ 1 2 3 , ĊĠĠĠĠĠĠĠ Ġretry On Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . STATUS _ 5 XX , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . GATE WAY _ ERROR , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . CONNECT _ FAILURE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . RE TRI ABLE _ 4 XX , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . REF USED _ UP STREAM ), ĊĠĠĠĠĠĠĠ Ġper Retry Timeout Ms Ġ= Ġ 9 0 0 1 ) ĊĠĠĠ Ġval Ġretry Policy Headers Ġ= Ġretry Policy . outbound Headers () ĊĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. add Retry Policy ( retry Policy ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers ). contains All Entries Of ( retry Policy Headers ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` retry Ġpolicy Ġheaders Ġare Ġnot Ġoverwritten Ġin Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġretry Policy Ġ= ĠRetry Policy ( ĊĠĠĠĠĠĠĠ Ġmax Retry Count Ġ= Ġ 1 2 3 , ĊĠĠĠĠĠĠĠ Ġretry On Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . STATUS _ 5 XX , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . GATE WAY _ ERROR , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . CONNECT _ FAILURE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . RE TRI ABLE _ 4 XX , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRetry Rule . REF USED _ UP STREAM ), ĊĠĠĠĠĠĠĠ Ġper Retry Timeout Ms Ġ= Ġ 9 0 0 1 ) ĊĠĠĠ Ġval Ġretry Policy Headers Ġ= Ġretry Policy . outbound Headers () ĊĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. add Header (" x - envoy - max - retries ", Ġ" override ") ĊĠĠĠĠĠĠĠ Ġ. add Retry Policy ( retry Policy ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers ). contains All Entries Of ( retry Policy Headers ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` delete Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . DELETE , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" DELETE ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` get Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . GET , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" GET ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` head Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . HEAD , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" HEAD ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` options Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . OPTIONS , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" OPTIONS ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` patch Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . PATCH , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" PATCH ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` post Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . POST , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" POST ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` put Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . PUT , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" PUT ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` trace Ġmethod Ġis Ġadded Ġto Ġoutbound Ġrequest Ġheaders `() Ġ{ ĊĠĠĠ Ġval Ġrequest Headers Ġ= ĠRequest Builder ( method Ġ= ĠRequestMethod . TRACE , Ġscheme Ġ= Ġ" https ", Ġauthority Ġ= Ġ" api . foo . com ", Ġpath Ġ= Ġ"/ foo ") ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ. outbound Headers () ĊĊĠĠĠ ĠassertThat ( request Headers [ ": method "]). contains Exactly (" TRACE ") ĊĠ Ġ} Ċ } Ċ