package Ġno . nav . f amil ie . ba . sk at te et aten Ċ Ċ import Ġno . nav . f amil ie . ba . sk at te et aten . Token TestUtil . Mask in port en Token Ċ import Ġno . nav . security . mock . oauth 2 . Mock OAuth 2 Server Ċ import Ġno . nav . security . token . support . spring . test . Enable Mock OAuth 2 Server Ċ import Ġokhttp 3 . mock webserver . Mock WebServer Ċ import Ġorg . junit . jupiter . api . After Each Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . beans . factory . annotation . Qualifier Ċ import Ġorg . springframework . beans . factory . annotation . Value Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . boot . test . web . client . Test Rest Template Ċ import Ġorg . springframework . boot . web . server . Local Server Port Ċ import Ġorg . springframework . http . HttpHeaders Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . junit . jupiter . Spring Extension Ċ Ċ @ Extend With ( Spring Extension :: class ) Ċ @ SpringBootTest ( classes Ġ= Ġ[ Dev Launcher :: class ], Ġweb Environment Ġ= ĠSpring Boot Test . Web Environment . RANDOM _ PORT ) Ċ @ Active Profiles (" integration test ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" mock - oauth ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" mock - ba - sak ") Ċ @ Enable Mock OAuth 2 Server Ċ class ĠIntegration Test Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock OAuth 2 Server : ĠMock OAuth 2 Server ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġ@ Qualifier (" mock - ba - sak ") ĊĠĠĠ Ġprotected Ġlateinit Ġvar Ġba S ak M ire mock : ĠMock WebServer ĊĊĠĠĠ Ġ@ Local Server Port ĊĠĠĠ Ġprivate Ġvar Ġport : ĠInt ? Ġ= Ġ 0 ĊĊĠĠĠ Ġ@ Value ("\ ${ MASK IN PORT EN _ W ELL _ KNOWN _ URL }") ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmask in port en Well Known Url : ĠString ĊĊĠĠĠ Ġprotected Ġval Ġrest Template Ġ= ĠTest Rest Template () ĊĠĠĠ Ġprotected Ġval Ġheaders Ġ= ĠHttp Headers () ĊĊĠĠĠ Ġ@ After Each ĊĠĠĠ Ġinternal Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġheaders . clear () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprotected Ġfun Ġlocalhost ( uri : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ" http :// localhost :$ port $ uri " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprotected Ġfun Ġwith Client Token ( client Token : ĠMask in port en Token Ġ= ĠMask in port en Token ()) Ġ{ ĊĠĠĠĠĠĠĠ Ġheaders . set Bearer Auth ( Token TestUtil . client Token ( mock OAuth 2 Server , Ġclient Token , Ġmask in port en Well Known Url )) ĊĠĠĠ Ġ} Ċ Ċ }