package Ġcom . microsoft . did . sdk . crypto . keys Ċ Ċ import Ġcom . microsoft . did . sdk . crypto . keys . rsa . R sa PublicKey Ċ import Ġcom . microsoft . did . sdk . crypto . models . Key Use Ċ import Ġcom . microsoft . did . sdk . crypto . models . web Crypto Api . Json Web Key Ċ import Ġcom . microsoft . did . sdk . crypto . models . web Crypto Api . Key Usage Ċ import Ġcom . microsoft . did . sdk . util . cont ro lf low . Key Exception Ċ import Ġio . mock k . impl . annotations . Mock K Ċ import Ġio . mock k . mock k Ċ import Ġorg . assertj . core . api . Assertions Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ Ċ class ĠPublicKey Test Ġ{ ĊĠĠĠ Ġprivate Ġvar Ġrsa PublicKey : ĠR sa PublicKey ĊĠĠĠ Ġ@ Mock K ĊĠĠĠ Ġprivate Ġvar Ġactual J wk : ĠJson Web Key ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġactual J wk Ġ= ĠJson Web Key ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġk ty Ġ= ĠKey Type . RSA . value , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġalg Ġ= Ġ" RS 2 5 6 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuse Ġ= ĠKey Use . Signature . value , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġkid Ġ= Ġ"# key 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġkey _ ops Ġ= ĠlistOf ( Key Usage . Verify . value ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrsa PublicKey Ġ= ĠR sa PublicKey ( actual J wk ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` rsa Ġpublic Ġkey Ġcreation `() Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( rsa PublicKey . k ty ). isEqualTo ( KeyType . RSA ) ĊĠĠĠĠĠĠĠ ĠassertThat ( rsa PublicKey . use ). isEqualTo ( Key Use . Signature ) ĊĠĠĠĠĠĠĠ ĠassertThat ( rsa PublicKey . alg ). isEqualTo (" RS 2 5 6 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( rsa PublicKey . kid ). isEqualTo ("# key 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( rsa PublicKey . key _ ops ). contains Only ( Key Usage . Verify ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` con verting Ġrsa Ġpublic Ġkey Ġto Ġjson Ġweb Ġkey `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected J wk Ġ= Ġrsa PublicKey . to J WK () ĊĠĠĠĠĠĠĠ ĠassertThat ( actual J wk ). isEqualTo Comp aring Field By Field Re cursively ( expected J wk ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` fail ing Ġrsa Ġpublic Ġkey Ġcreation Ġwith Ġwrong Ġkey Ġtype `() Ġ{ ĊĠĠĠĠĠĠĠ Ġactual J wk Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ ĠAssertions . assertThat Thrown By Ġ{ ĠR sa PublicKey ( actual J wk ) Ġ}. isInstanceOf ( Key Exception :: class . java ) ĊĠĠĠ Ġ} Ċ }