package Ġid . walt . context Ċ Ċ import Ġid . walt . aud itor . Aud itor Ċ import Ġid . walt . aud itor . Signature Policy Ċ import Ġid . walt . model . Did Method Ċ import Ġid . walt . servic em at rix . Service Matrix Ċ import Ġid . walt . services . context . Context Manager Ċ import Ġid . walt . services . did . Did Service Ċ import Ġid . walt . sign atory . Proof Config Ċ import Ġid . walt . sign atory . Sign atory Ċ import Ġid . walt . test . RESOURCES _ PATH Ċ import Ġio . kot est . core . spec . style . Annotation Spec Ċ import Ġio . kot est . matchers . collections . should Have Size Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġio . kot est . matchers . should Not Be Ċ import Ġjava . io . File Ċ Ċ class ĠW alt Context Test : ĠAnnotation Spec () Ġ{ ĊĊĠ Ġ@ Before All ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ ĠService Matrix ("$ RESOURCES _ PATH / service - matrix . properties ") ĊĠĠĠ ĠFile ( TEST _ CONTEXT _ DATA _ ROOT ). delete Re cursively () ĊĠ Ġ} ĊĊĠ Ġ@ After All ĊĠ Ġfun Ġcleanup () Ġ{ ĊĠĠĠ ĠFile ( TEST _ CONTEXT _ DATA _ ROOT ). delete Re cursively () ĊĠ Ġ} ĊĊĠ Ġval Ġuser A Context Ġ= ĠTest Context (" user A ") ĊĠ Ġval Ġuser B Context Ġ= ĠTest Context (" user B ") ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Context () Ġ{ ĊĊĠĠĠ Ġvar Ġdid 1 : ĠString ? Ġ= Ġnull ĊĠĠĠ ĠContext Manager . run With ( user A Context ) Ġ{ ĊĠĠĠĠĠ Ġdid 1 Ġ= ĠDid Service . create ( Did Method . key ) ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠContext Manager . run With ( user B Context ) Ġ{ ĊĠĠĠĠĠ Ġval Ġdid 2 Ġ= ĠDid Service . create ( Did Method . key ) ĊĠĠĠĠĠ Ġval Ġdid List 2 Ġ= ĠDid Service . list D ids () ĊĠĠĠĠĠ Ġdid List 2 Ġshould Have Size Ġ 1 ĊĠĠĠĠĠ Ġdid List 2 . first () ĠshouldBe Ġdid 2 ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠContext Manager . run With ( user A Context ) Ġ{ ĊĠĠĠĠĠ Ġval Ġdid List 1 Ġ= ĠDid Service . list D ids () ĊĠĠĠĠĠ Ġdid List 1 Ġshould Have Size Ġ 1 ĊĠĠĠĠĠ Ġdid 1 Ġshould Not Be Ġnull ĊĠĠĠĠĠ Ġdid List 1 . first () ĠshouldBe Ġdid 1 ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Did Key Import () Ġ{ ĊĠĠĠ Ġvar Ġcred : ĠString Ġ= Ġ"" ĊĠĠĠ ĠContext Manager . run With ( user A Context ) Ġ{ ĊĠĠĠĠĠ Ġ// Ġcreate Ġdid : key Ġwith Ġnew Ġkey Ġin Ġuser ĠA Ġcontext ĊĠĠĠĠĠ Ġval Ġdid Ġ= ĠDid Service . create ( Did Method . key ) ĊĠĠĠĠĠ Ġ// Ġissue Ġcredential Ġusing Ġcreated Ġdid ĊĠĠĠĠĠ Ġcred Ġ= ĠSign atory . getService (). issue (" Ver ifiable Id ", ĠPro of Config ( did , Ġdid )) ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠContext Manager . run With ( user B Context ) Ġ{ ĊĠĠĠĠĠ Ġ// Ġverify Ġcredential Ġin Ġuser ĠB Ġcontext , Ġimporting Ġkey Ġfrom Ġdid Ġon Ġthe Ġfly ĊĠĠĠĠĠ Ġval Ġresult Ġ= ĠAud itor . getService (). verify ( cred , ĠlistOf ( Signature Policy ())) ĊĠĠĠĠĠ Ġresult . valid ĠshouldBe Ġtrue ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ