package Ġid . walt . web wallet . backend . wallet Ċ Ċ import Ġcom . be ust . kl ax on . Kl ax on Ċ import Ġcom . nim bus ds . jwt . JWT Ċ import Ġcom . nim bus ds . jwt . JWT Parser Ċ import Ġid . walt . cust od ian . Cust od ian Ċ import Ġid . walt . model . Did Method Ċ import Ġid . walt . model . oidc . ID Token Ċ import Ġid . walt . model . oidc . SI OP v 2 Request Ċ import Ġid . walt . model . oidc . kl ax on Ċ import Ġid . walt . servic em at rix . Service Matrix Ċ import Ġid . walt . servic em at rix . Service Registry Ċ import Ġid . walt . services . context . Context Manager Ċ import Ġid . walt . services . did . Did Service Ċ import Ġid . walt . services . h kv store . FileSystem H KV Store Ċ import Ġid . walt . services . h kv store . Filesystem Store Config Ċ import Ġid . walt . services . jwt . Jwt Service Ċ import Ġid . walt . services . keystore . H KV KeyStore Service Ċ import Ġid . walt . services . vc store . H KV Vc Store Service Ċ import Ġid . walt . sign atory . Proof Config Ċ import Ġid . walt . sign atory . Sign atory Ċ import Ġid . walt . vc lib . credentials . Ver ifiable Id Ċ import Ġid . walt . vc lib . model . to Credential Ċ import Ġid . walt . vc lib . credentials . Ver ifiable Presentation Ċ import Ġid . walt . vc lib . model . Ver ifiable Credential Ċ import Ġid . walt . vc lib . templates . Vc Template Manager Ċ import Ġid . walt . verifier . backend . SI OP v 2 Request Manager Ċ import Ġid . walt . web wallet . backend . auth . UserInfo Ċ import Ġid . walt . web wallet . backend . context . User Context Ċ import Ġid . walt . web wallet . backend . context . Wallet Context Manager Ċ import Ġio . jav al in . core . util . Route Overview Util . meta Info Ċ import Ġio . jav al in . http . Context Ċ import Ġio . kot est . core . spec . style . Annotation Spec Ċ import Ġio . kot est . matchers . collections . be Empty Ċ import Ġio . kot est . matchers . collections . shouldBe In Ċ import Ġio . kot est . matchers . collections . should Contain Ċ import Ġio . kot est . matchers . collections . should Have Size Ċ import Ġio . kot est . matchers . should Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġio . kot est . matchers . should Not Ċ import Ġio . kot est . matchers . should Not Be Ċ import Ġio . kot est . matchers . types . be OfType Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġjava . net . URL Decoder Ċ import Ġjava . net . URL Encoder Ċ import Ġjava . nio . charset . StandardCharsets Ċ Ċ class ĠSI OP v 2 Test Ġ: ĠAnnotation Spec () Ġ{ ĊĊĠ Ġval Ġtest User Context Ġ= ĠUser Context ( H KV KeyStore Service (), ĠH KV Vc Store Service (), ĠFileSystem H KV Store ( Filesystem Store Config (" data / test @ mail . com "))) ĊĠ Ġval Ġw alt Context Ġ= Ġmock k < Wallet Context Manager >( relax ed Ġ= Ġtrue ) ĊĠ Ġprivate Ġlateinit Ġvar Ġsi op v 2 Request : ĠSI OP v 2 Request ĊĠ Ġprivate Ġlateinit Ġvar Ġsubject Did : ĠString ĊĠ Ġprivate Ġlateinit Ġvar Ġsi op v 2 Request Params : ĠMap < String , ĠString > ĊĠ Ġprivate Ġlateinit Ġvar Ġvc 1 : ĠVer ifiable Credential ĊĠ Ġprivate Ġlateinit Ġvar Ġvc 2 : ĠVer ifiable Credential ĊĊĠ Ġ@ Before All ĊĠ Ġfun Ġinit () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġw alt Context . h kv Store Ġ} Ġreturns Ġtest User Context . h kv Store ĊĠĠĠ Ġevery Ġ{ Ġw alt Context . key Store Ġ} Ġreturns Ġtest User Context . key Store ĊĠĠĠ Ġevery Ġ{ Ġw alt Context . vc Store Ġ} Ġreturns Ġtest User Context . vc Store ĊĊĠĠĠ ĠService Matrix (" service - matrix . properties ") ĊĠĠĠ ĠService Registry . register Service < Context Manager >( walt Context ) ĊĊĠĠĠ Ġsi op v 2 Request Ġ= ĠSI OP v 2 Request Manager . new Request ( Vc Template Manager . load Template (" Ver ifiable Id "). credential Schema !!. id ) ĊĠĠĠ Ġsubject Did Ġ= ĠDid Service . create ( Did Method . eb si ) ĊĠĠĠ Ġsi op v 2 Request Params Ġ= Ġsi op v 2 Request . to Uri QueryString (). split ("& "). map Ġ{ Ġit . split (" =") Ġ}. map Ġ{ Ġit [ 0 ] Ġto ĠURL Decoder . decode ( it [ 1 ], ĠStandard Charsets . UTF _ 8 ) Ġ}. toMap () ĊĠĠĠ Ġvc 1 Ġ= ĠSign atory . getService (). issue (" Ver ifiable Id ", ĠPro of Config ( subject Did , Ġsubject Did )). to Credential () ĊĠĠĠ Ġvc 2 Ġ= ĠSign atory . getService (). issue (" Ver ifiable Id ", ĠPro of Config ( subject Did , Ġsubject Did )). to Credential () ĊĠĠĠ ĠC ust od ian . getService (). store Credential ( vc 1 . id !! , Ġvc 1 ) ĊĠĠĠ ĠC ust od ian . getService (). store Credential ( vc 2 . id !! , Ġvc 2 ) ĊĠ Ġ} ĊĊĠ Ġ@ Test () ĊĠ Ġfun Ġtest Presentation Exchange () Ġ{ ĊĠĠĠ Ġlateinit Ġvar Ġpe : ĠPresentation Exchange ĊĠĠĠ Ġval Ġctx 1 Ġ= Ġmock k < Context >( relax ed Ġ= Ġtrue ) ĊĠĠĠ Ġevery Ġ{ Ġctx 1 . query Param ( not (" subject _ did ")) Ġ} Ġanswers Ġ{ Ġ Ġsi op v 2 Request Params . get ( first Arg ()) Ġ} ĊĠĠĠ Ġevery Ġ{ Ġctx 1 . query Param (" subject _ did ") Ġ} Ġreturns Ġsubject Did ĊĠĠĠ Ġevery Ġ{ Ġctx 1 . json ( of Type ( Presentation Exchange :: class )) Ġ} Ġanswers Ġ{ Ġpe Ġ= Ġfirst Arg (); Ġctx 1 Ġ} ĊĊĠĠĠ ĠWallet Controller . get Presentation Exchange ( ctx 1 ) ĊĠĠĠ Ġverify Ġ{ Ġctx 1 . json ( of Type ( Presentation Exchange :: class )) Ġ} ĊĊĠĠĠ Ġpe . subject ĠshouldBe Ġsubject Did ĊĠĠĠ Ġpe . claimed Credentials Ġshould Have Size Ġ 2 ĊĠĠĠ Ġvc 1 . id ĠshouldBe In Ġpe . claimed Credentials . map Ġ{ Ġit . credential Id Ġ} ĊĠĠĠ Ġvc 2 . id ĠshouldBe In Ġpe . claimed Credentials . map Ġ{ Ġit . credential Id Ġ} ĊĊĠĠĠ Ġval Ġselected CC Ġ= Ġpe . claimed Credentials [ 0 ] ĊĠĠĠ Ġval Ġpe Sel Ġ= ĠPresentation Exchange ( ĊĠĠĠĠĠ Ġsubject Did , Ġsi op v 2 Request , ĠlistOf ( selected CC ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġlateinit Ġvar Ġpe Response : ĠPresentation Exchange Response ĊĊĠĠĠ Ġval Ġctx 2 Ġ= Ġmock k < Context >( relax ed Ġ= Ġtrue ) ĊĠĠĠ Ġevery Ġ{ Ġctx 2 . body () Ġ} Ġreturns Ġkl ax on . toJson String ( pe Sel ) ĊĠĠĠ Ġevery Ġ{ Ġctx 2 . json ( of Type ( Presentation Exchange Response :: class )) Ġ} Ġanswers Ġ{ Ġpe Response Ġ= Ġfirst Arg (); Ġctx 2 Ġ} ĊĊĠĠĠ ĠWallet Controller . post Presentation Exchange ( ctx 2 ) ĊĠĠĠ Ġverify Ġ{ Ġctx 2 . json ( of Type ( Presentation Exchange Response :: class )) Ġ} ĊĊĠĠĠ Ġpe Response . id _ token Ġshould Not Be Ġnull ĊĠĠĠ Ġpe Response . vp _ token Ġshould Not Be Ġnull ĊĠĠĠ ĠJwt Service . getService (). verify ( pe Response . id _ token ) ĠshouldBe Ġtrue ĊĊĠĠĠ Ġval Ġid _ token Ġ= ĠK l ax on (). parse < ID Token >( JWT Parser . parse ( pe Response . id _ token ). jwt Claims Set . toString ()) ĊĊĠĠĠ Ġid _ token !!. subject ĠshouldBe Ġsubject Did ĊĠĠĠ Ġpe Response . vp _ token . to Credential () Ġshould Ġbe OfType < Ver ifiable Presentation >() ĊĠĠĠ Ġ( pe Response . vp _ token . to Credential () Ġas ĠVer ifiable Presentation ). ver ifiable Credential Ġshould Have Size Ġ 1 ĊĠĠĠ Ġ( pe Response . vp _ token . to Credential () Ġas ĠVer ifiable Presentation ). ver ifiable Credential . first (). id ĠshouldBe Ġselected CC . credential Id ĊĊĠ Ġ} Ċ } Ċ