@@ -6,6 +6,7 @@ use crate::error::{ClientErrorKind, Error};
6
6
use crate :: BasicClient ;
7
7
use mockstream:: { FailingMockStream , MockStream } ;
8
8
use parsec_interface:: operations;
9
+ use parsec_interface:: operations:: list_keys:: KeyInfo ;
9
10
use parsec_interface:: operations:: list_providers:: { ProviderInfo , Uuid } ;
10
11
use parsec_interface:: operations:: psa_algorithm:: * ;
11
12
use parsec_interface:: operations:: psa_key_attributes:: * ;
@@ -118,6 +119,57 @@ fn list_opcodes_test() {
118
119
assert ! ( opcodes. contains( & Opcode :: PsaGenerateKey ) && opcodes. contains( & Opcode :: PsaDestroyKey ) ) ;
119
120
}
120
121
122
+ #[ test]
123
+ fn list_keys_test ( ) {
124
+ use parsec_interface:: operations:: psa_key_attributes:: {
125
+ Attributes , Lifetime , Policy , Type , UsageFlags ,
126
+ } ;
127
+
128
+ let mut client: TestBasicClient = Default :: default ( ) ;
129
+ let mut key_info = Vec :: new ( ) ;
130
+ key_info. push ( KeyInfo {
131
+ provider_id : ProviderID :: MbedCrypto ,
132
+ name : String :: from ( "Foo" ) ,
133
+ attributes : Attributes {
134
+ lifetime : Lifetime :: Persistent ,
135
+ key_type : Type :: RsaKeyPair ,
136
+ bits : 1024 ,
137
+ policy : Policy {
138
+ usage_flags : UsageFlags {
139
+ export : true ,
140
+ copy : true ,
141
+ cache : true ,
142
+ encrypt : true ,
143
+ decrypt : true ,
144
+ sign_message : true ,
145
+ verify_message : true ,
146
+ sign_hash : true ,
147
+ verify_hash : true ,
148
+ derive : true ,
149
+ } ,
150
+ permitted_algorithms : Algorithm :: AsymmetricSignature (
151
+ AsymmetricSignature :: RsaPkcs1v15Sign {
152
+ hash_alg : Hash :: Sha256 . into ( ) ,
153
+ } ,
154
+ ) ,
155
+ } ,
156
+ } ,
157
+ } ) ;
158
+
159
+ client. set_mock_read ( & get_response_bytes_from_result ( NativeResult :: ListKeys (
160
+ operations:: list_keys:: Result { keys : key_info } ,
161
+ ) ) ) ;
162
+
163
+ let keys = client. list_keys ( ) . expect ( "Failed to list keys" ) ;
164
+ // Check request:
165
+ // ListKeys request is empty so no checking to be done
166
+
167
+ // Check response:
168
+ assert_eq ! ( keys. len( ) , 1 ) ;
169
+ assert_eq ! ( keys[ 0 ] . name, "Foo" ) ;
170
+ assert_eq ! ( keys[ 0 ] . provider_id, ProviderID :: MbedCrypto ) ;
171
+ }
172
+
121
173
#[ test]
122
174
fn no_crypto_provider_test ( ) {
123
175
let client = BasicClient :: new ( AuthenticationData :: AppIdentity ( Secret :: new ( String :: from (
0 commit comments