Skip to content

Commit d4c5f9a

Browse files
Key Vault: Added getters for KeyVaultKey (Azure#203)
1 parent 5dda98d commit d4c5f9a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

sdk/key_vault/src/key.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::client::API_VERSION_PARAM;
1212
use crate::{KeyClient, KeyVaultError};
1313

1414
/// A KeyBundle consisting of a WebKey plus its attributes.
15-
#[derive(Debug, Deserialize)]
15+
#[derive(Debug, Deserialize, Getters)]
16+
#[getset(get = "pub")]
1617
pub struct KeyVaultKey {
1718
/// The key management properties.
1819
#[serde(flatten)]
@@ -364,27 +365,30 @@ mod tests {
364365
.await
365366
.unwrap();
366367

367-
let JsonWebKey { id, n, .. } = key.key;
368+
let JsonWebKey { id, n, .. } = key.key();
368369
let KeyProperties {
369370
attributes,
370371
managed,
371372
tags,
372-
} = key.properties;
373+
} = key.properties();
373374
let KeyAttributes {
374375
created_on,
375376
enabled,
376377
updated_on,
377378
..
378379
} = attributes;
379380
let expected_n = base64::decode_config("2HJAE5fU3Cw2Rt9hEuq-F6XjINKGa-zskfISVqopqUy60GOs2eyhxbWbJBeUXNor_gf-tXtNeuqeBgitLeVa640UDvnEjYTKWjCniTxZRaU7ewY8BfTSk-7KxoDdLsPSpX_MX4rwlAx-_1UGk5t4sQgTbm9T6Fm2oqFd37dsz5-Gj27UP2GTAShfJPFD7MqU_zIgOI0pfqsbNL5xTQVM29K6rX4jSPtylZV3uWJtkoQIQnrIHhk1d0SC0KwlBV3V7R_LVYjiXLyIXsFzSNYgQ68ZjAwt8iL7I8Osa-ehQLM13DVvLASaf7Jnu3sC3CWl3Gyirgded6cfMmswJzY87w", BASE64_URL_SAFE).unwrap();
380-
assert_eq!(expected_n, n.unwrap());
381+
assert_eq!(expected_n, n.to_owned().unwrap());
381382
assert_eq!(
382383
"https://test-keyvault.vault.azure.net/keys/test-key/78deebed173b48e48f55abf87ed4cf71",
383-
id.unwrap()
384+
id.to_owned().unwrap()
384385
);
385386

386387
assert!(managed.is_none());
387-
assert_eq!(tags.unwrap().get("purpose").unwrap(), "unit test");
388+
assert_eq!(
389+
tags.to_owned().unwrap().get("purpose").unwrap(),
390+
"unit test"
391+
);
388392
assert_eq!(true, enabled.unwrap());
389393
assert!(diff(time_created, created_on.unwrap()) < Duration::seconds(1));
390394
assert!(diff(time_updated, updated_on.unwrap()) < Duration::seconds(1));
@@ -418,16 +422,16 @@ mod tests {
418422
.await
419423
.unwrap();
420424

421-
let kid = res.key_id;
422-
let sig = res.signature;
423-
let alg = res.algorithm;
425+
let kid = res.key_id();
426+
let sig = res.signature();
427+
let alg = res.algorithm();
424428

425429
assert_eq!(
426430
kid,
427431
"https://myvault.vault.azure.net/keys/testkey/9885aa558e8d448789683188f8c194b0"
428432
);
429433
let expected_sig = base64::decode_config("aKFG8NXcfTzqyR44rW42484K_zZI_T7zZuebvWuNgAoEI1gXYmxrshp42CunSmmu4oqo4-IrCikPkNIBkHXnAW2cv03Ad0UpwXhVfepK8zzDBaJPMKVGS-ZRz8CshEyGDKaLlb3J3zEkXpM3RrSEr0mdV6hndHD_mznLB5RmFui5DsKAhez4vUqajgtkgcPfCekMqeSwp6r9ItVL-gEoAohx8XMDsPedqu-7BuZcBcdayaPuBRL4wWoTDULA11P-UN_sJ5qMj3BbiRYhIlBWGR04wIGfZ3pkJjHJUpOvgH2QajdYPzUBauOCewMYbq9XkLRSzI_A7HkkDVycugSeAA", BASE64_URL_SAFE).unwrap();
430-
assert_eq!(expected_sig, sig);
434+
assert_eq!(expected_sig, sig.to_owned());
431435
assert!(matches!(alg, SignatureAlgorithm::RS512));
432436
}
433437
}

0 commit comments

Comments
 (0)