package Ġorg . http 4 k . contract Ċ Ċ import Ġcom . nat pr y ce . ham k rest . assertion . assertThat Ċ import Ġcom . nat pr y ce . ham k rest . equalTo Ċ import Ġorg . http 4 k . contract . security . ApiKey Security Ċ import Ġorg . http 4 k . contract . security . or Ċ import Ġorg . http 4 k . core . Http Handler Ċ import Ġorg . http 4 k . core . Method . GET Ċ import Ġorg . http 4 k . core . Request Ċ import Ġorg . http 4 k . core . Response Ċ import Ġorg . http 4 k . core . Status . Companion . OK Ċ import Ġorg . http 4 k . core . Status . Companion . UN AUTHORIZ ED Ċ import Ġorg . http 4 k . ham k rest . has Status Ċ import Ġorg . http 4 k . lens . Query Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġjava . util . concurrent . atomic . Atomic Integer Ċ Ċ class ĠOr Security Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcall Count Ġ= ĠAtomicInteger ( 0 ) ĊĊĠĠĠ Ġprivate Ġval Ġnext : ĠHttp Handler Ġ= Ġ{ ĊĠĠĠĠĠĠĠ Ġcall Count . increment AndGet () ĊĠĠĠĠĠĠĠ ĠResponse ( OK ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġcomposite Ġ= ĠApi Key Security ( Query . required (" first "), Ġ{ Ġtrue Ġ}) ĊĠĠĠĠĠĠĠ Ġ. or ( ApiKey Security ( Query . required (" second "), Ġ{ Ġtrue Ġ})) ĊĠĠĠĠĠĠĠ Ġ. or ( ApiKey Security ( Query . required (" third "), Ġ{ Ġtrue Ġ})) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` toString Ġmakes Ġsense `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( Foo Bar . or ( Bar Foo ). or ( Foo Bar ). toString (), ĠequalTo (" Or Security ( all =[ Foo Bar , ĠBar Foo , ĠFoo Bar ]) ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` requires Ġeither Ġse cur ities Ġto Ġpass Ġto Ġsucceed `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġhandler Ġ= Ġcomposite . filter ( next ) ĊĠĠĠĠĠĠĠ ĠassertThat ( handler ( Request ( GET , Ġ"") ), Ġhas Status ( UN AUTHORIZ ED )) ĊĠĠĠĠĠĠĠ ĠassertThat ( handler ( Request ( GET , Ġ"? first = true ")), Ġhas Status ( OK )) ĊĠĠĠĠĠĠĠ ĠassertThat ( call Count . get (), ĠequalTo ( 1 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( handler ( Request ( GET , Ġ"? second = true ")), Ġhas Status ( OK )) ĊĠĠĠĠĠĠĠ ĠassertThat ( call Count . get (), ĠequalTo ( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( handler ( Request ( GET , Ġ"? first = true & second = true ")), Ġhas Status ( OK )) ĊĠĠĠĠĠĠĠ ĠassertThat ( call Count . get (), ĠequalTo ( 3 )) ĊĠĠĠ Ġ} Ċ }