|
1 | 1 | // Copyright 2019 Contributors to the Parsec project.
|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
| 3 | +use e2e_tests::RawRequestClient; |
3 | 4 | use e2e_tests::TestClient;
|
4 | 5 | use parsec_client::core::interface::operations::list_providers::Uuid;
|
5 |
| -use parsec_client::core::interface::requests::{AuthType, Opcode, ProviderID, Result}; |
| 6 | +use parsec_client::core::interface::requests::request::RawHeader; |
| 7 | +use parsec_client::core::interface::requests::{ |
| 8 | + AuthType, Opcode, ProviderID, ResponseStatus, Result, |
| 9 | +}; |
6 | 10 | use std::collections::HashSet;
|
7 | 11 |
|
8 | 12 | #[test]
|
@@ -141,7 +145,23 @@ fn list_keys() {
|
141 | 145 | .collect();
|
142 | 146 |
|
143 | 147 | assert_eq!(key_names.len(), 3);
|
144 |
| - assert!(key_names.contains(&(key1.clone(),ProviderID::MbedCrypto))); |
145 |
| - assert!(key_names.contains(&(key2.clone(),ProviderID::Pkcs11))); |
146 |
| - assert!(key_names.contains(&(key3.clone(),ProviderID::Tpm))); |
| 148 | + assert!(key_names.contains(&(key1.clone(), ProviderID::MbedCrypto))); |
| 149 | + assert!(key_names.contains(&(key2.clone(), ProviderID::Pkcs11))); |
| 150 | + assert!(key_names.contains(&(key3.clone(), ProviderID::Tpm))); |
| 151 | +} |
| 152 | + |
| 153 | +#[test] |
| 154 | +// See #310 |
| 155 | +fn invalid_provider_list_keys() { |
| 156 | + let mut client = RawRequestClient {}; |
| 157 | + let mut req_hdr = RawHeader::new(); |
| 158 | + |
| 159 | + // Always targeting the Mbed Crypto provider |
| 160 | + req_hdr.provider = 0x1; |
| 161 | + req_hdr.opcode = Opcode::ListKeys as u32; |
| 162 | + |
| 163 | + let resp = client |
| 164 | + .send_raw_request(req_hdr, Vec::new()) |
| 165 | + .expect("Failed to read Response"); |
| 166 | + assert_eq!(resp.header.status, ResponseStatus::PsaErrorNotSupported); |
147 | 167 | }
|
0 commit comments