Skip to content

Commit ce944b3

Browse files
AureliaDoloFirelightFlagboy
authored andcommitted
Rename LocalPendingEnrollment to PKILocalPendingEnrollment.
1 parent dc8ea7a commit ce944b3

File tree

10 files changed

+33
-33
lines changed

10 files changed

+33
-33
lines changed

docs/rfcs/1020-pki-support.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ and verify that the chosen certificate is able to sign a payload by default by u
116116

117117
### Create the local part of the async enrollment
118118

119-
[`pki_enrollment_create_local_pending`] create a pending enrollment ([`LocalPendingEnrollment`]) consisting of the following information:
119+
[`pki_enrollment_create_local_pending`] create a pending enrollment ([`PKILocalPendingEnrollment`]) consisting of the following information:
120120

121121
- Certificate ref (provided)
122122
- Server addr (provided)
@@ -128,7 +128,7 @@ and verify that the chosen certificate is able to sign a payload by default by u
128128

129129
The pending enrollment contains almost everything to create a device only missing the organization verification key that will be sent with the "accept" payload response ([`pki_enrollment_load_accept_payload`])
130130

131-
[`LocalPendingEnrollment`]: https://github.com/Scille/parsec-cloud/blob/df7bc6891989830c4d93f0b88ddaac9ade6b620c/libparsec/crates/types/schema/pki/local_pending_enrollment.json5
131+
[`PKILocalPendingEnrollment`]: https://github.com/Scille/parsec-cloud/blob/df7bc6891989830c4d93f0b88ddaac9ade6b620c/libparsec/crates/types/schema/pki/local_pending_enrollment.json5
132132

133133
### Submit the request to join an organization
134134

libparsec/crates/platform_device_loader/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ impl From<SaveDeviceError> for SavePkiLocalPendingError {
767767
}
768768

769769
pub async fn save_pki_local_pending(
770-
local_pending: LocalPendingEnrollment,
770+
local_pending: PKILocalPendingEnrollment,
771771
local_file: PathBuf,
772772
) -> Result<(), SavePkiLocalPendingError> {
773773
log::debug!("Saving local device at {}", local_file.display());
@@ -784,6 +784,6 @@ pub enum ListPkiLocalPendingError {
784784

785785
pub async fn list_pki_local_pending(
786786
config_dir: &Path,
787-
) -> Result<Vec<LocalPendingEnrollment>, ListPkiLocalPendingError> {
787+
) -> Result<Vec<PKILocalPendingEnrollment>, ListPkiLocalPendingError> {
788788
platform::list_pki_local_pending(config_dir).await
789789
}

libparsec/crates/platform_device_loader/src/native/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ pub(super) fn is_keyring_available() -> bool {
522522
}
523523

524524
pub async fn save_pki_local_pending(
525-
local_pending: LocalPendingEnrollment,
525+
local_pending: PKILocalPendingEnrollment,
526526
local_file: PathBuf,
527527
) -> Result<(), SavePkiLocalPendingError> {
528528
let file_content = local_pending.dump();
@@ -533,7 +533,7 @@ pub async fn save_pki_local_pending(
533533

534534
pub async fn list_pki_local_pending(
535535
config_dir: &Path,
536-
) -> Result<Vec<LocalPendingEnrollment>, ListPkiLocalPendingError> {
536+
) -> Result<Vec<PKILocalPendingEnrollment>, ListPkiLocalPendingError> {
537537
let pending_dir = crate::get_local_pending_dir(config_dir);
538538
let mut files = find_local_pending_files(&pending_dir).await?;
539539

@@ -573,12 +573,12 @@ async fn find_local_pending_files(path: &Path) -> Result<Vec<PathBuf>, ListPkiLo
573573
Ok(files)
574574
}
575575

576-
async fn load_pki_pending_file(path: &Path) -> Result<LocalPendingEnrollment, LoadFileError> {
576+
async fn load_pki_pending_file(path: &Path) -> Result<PKILocalPendingEnrollment, LoadFileError> {
577577
let content = tokio::fs::read(path)
578578
.await
579579
.map_err(Into::into)
580580
.map_err(LoadFileError::InvalidPath)?;
581-
LocalPendingEnrollment::load(&content)
581+
PKILocalPendingEnrollment::load(&content)
582582
.inspect_err(
583583
|err| log::debug!(path:% = path.display(), err:%; "Failed to load pki pending file"),
584584
)

libparsec/crates/platform_device_loader/src/web/internal.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl Storage {
268268
pub(crate) async fn save_pki_local_pending(
269269
&self,
270270
local_file: PathBuf,
271-
file_data: LocalPendingEnrollment,
271+
file_data: PKILocalPendingEnrollment,
272272
) -> Result<(), SaveRawDataError> {
273273
let data = file_data.dump();
274274
self.save_raw_data(&local_file, &data).await
@@ -277,7 +277,7 @@ impl Storage {
277277
pub(crate) async fn list_pki_local_pending(
278278
&self,
279279
config_dir: &Path,
280-
) -> Result<Vec<LocalPendingEnrollment>, ListPkiLocalPendingError> {
280+
) -> Result<Vec<PKILocalPendingEnrollment>, ListPkiLocalPendingError> {
281281
let pending_dir = crate::get_local_pending_dir(config_dir);
282282
let file_entries = self
283283
.list_file_entries(&pending_dir, crate::LOCAL_PENDING_EXT)
@@ -318,12 +318,12 @@ async fn load_available_device(file: &File) -> Result<AvailableDevice, LoadAvail
318318

319319
async fn load_pki_local_pending(
320320
file: &File,
321-
) -> Result<LocalPendingEnrollment, LoadPkiLocalPendingError> {
321+
) -> Result<PKILocalPendingEnrollment, LoadPkiLocalPendingError> {
322322
let raw_data = file
323323
.read_to_end()
324324
.await
325325
.map_err(LoadPkiLocalPendingError::ReadToEnd)?;
326-
LocalPendingEnrollment::load(&raw_data)
326+
PKILocalPendingEnrollment::load(&raw_data)
327327
.inspect_err(|err| {
328328
log::warn!(
329329
path:% = file.path().display(),

libparsec/crates/platform_device_loader/src/web/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub(super) async fn remove_device(device_path: &Path) -> Result<(), RemoveDevice
177177
}
178178

179179
pub(super) async fn save_pki_local_pending(
180-
local_pending: LocalPendingEnrollment,
180+
local_pending: PKILocalPendingEnrollment,
181181
local_file: PathBuf,
182182
) -> Result<(), SavePkiLocalPendingError> {
183183
let Ok(storage) = Storage::new().await.inspect_err(|e| {
@@ -193,7 +193,7 @@ pub(super) async fn save_pki_local_pending(
193193

194194
pub(super) async fn list_pki_local_pending(
195195
config_dir: &Path,
196-
) -> Result<Vec<LocalPendingEnrollment>, ListPkiLocalPendingError> {
196+
) -> Result<Vec<PKILocalPendingEnrollment>, ListPkiLocalPendingError> {
197197
let Ok(storage) = Storage::new().await.inspect_err(|e| {
198198
log::error!("Failed to access storage: {e}");
199199
}) else {

libparsec/crates/platform_device_loader/tests/units/pki/save.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use libparsec_testbed::TestbedEnv;
44
use libparsec_tests_fixtures::prelude::*;
55
use libparsec_tests_lite::parsec_test;
66
use libparsec_types::{
7-
Bytes, LocalPendingEnrollment, PKIEnrollmentID, ParsecPkiEnrollmentAddr,
7+
Bytes, PKIEnrollmentID, PKILocalPendingEnrollment, ParsecPkiEnrollmentAddr,
88
PkiEnrollmentSubmitPayload, X509CertificateHash,
99
};
1010

@@ -19,7 +19,7 @@ async fn ok_simple(tmp_path: TmpPath, env: &TestbedEnv) {
1919
alice_device.organization_addr.clone(),
2020
alice_device.organization_id().clone(),
2121
);
22-
let local_pending = LocalPendingEnrollment {
22+
let local_pending = PKILocalPendingEnrollment {
2323
cert_ref: X509CertificateHash::fake_sha256().into(),
2424
addr: pki_addr,
2525
submitted_on: "2000-01-01T00:00:00Z".parse().unwrap(),

libparsec/crates/platform_pki/src/shared/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
EncryptedMessage, PkiSignatureAlgorithm,
1313
};
1414
use libparsec_types::{
15-
DateTime, LocalPendingEnrollment, PKIEnrollmentID, ParsecPkiEnrollmentAddr,
15+
DateTime, PKIEnrollmentID, PKILocalPendingEnrollment, ParsecPkiEnrollmentAddr,
1616
PkiEnrollmentAnswerPayload, PkiEnrollmentSubmitPayload, PrivateParts, SecretKey,
1717
X509CertificateReference,
1818
};
@@ -88,7 +88,7 @@ pub fn create_local_pending(
8888
submitted_on: DateTime,
8989
payload: PkiEnrollmentSubmitPayload,
9090
private_parts: PrivateParts,
91-
) -> Result<LocalPendingEnrollment, crate::errors::CreateLocalPendingError> {
91+
) -> Result<PKILocalPendingEnrollment, crate::errors::CreateLocalPendingError> {
9292
let key = SecretKey::generate();
9393
let EncryptedMessage {
9494
cert_ref,
@@ -97,7 +97,7 @@ pub fn create_local_pending(
9797
} = encrypt_message(key.as_ref(), cert_ref)?;
9898
let ciphered_private_parts = key.encrypt(&private_parts.dump()).into();
9999

100-
let local_pending = LocalPendingEnrollment {
100+
let local_pending = PKILocalPendingEnrollment {
101101
cert_ref,
102102
addr,
103103
submitted_on,

libparsec/crates/types/schema/pki/local_pending_enrollment.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"label": "LocalPendingEnrollment",
2+
"label": "PKILocalPendingEnrollment",
33
"type": "local_pending_enrollment",
44
"other_fields": [
55
{

libparsec/crates/types/src/pki/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ impl_transparent_data_format_conversion!(
140140

141141
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
142142
#[serde(
143-
into = "LocalPendingEnrollmentData",
144-
try_from = "LocalPendingEnrollmentData"
143+
into = "PKILocalPendingEnrollmentData",
144+
try_from = "PKILocalPendingEnrollmentData"
145145
)]
146-
pub struct LocalPendingEnrollment {
146+
pub struct PKILocalPendingEnrollment {
147147
pub cert_ref: X509CertificateReference,
148148
pub addr: ParsecPkiEnrollmentAddr,
149149
pub submitted_on: DateTime,
@@ -154,7 +154,7 @@ pub struct LocalPendingEnrollment {
154154
pub ciphertext: Bytes,
155155
}
156156

157-
impl LocalPendingEnrollment {
157+
impl PKILocalPendingEnrollment {
158158
pub fn load(raw: &[u8]) -> DataResult<Self> {
159159
format_vx_load(raw)
160160
}
@@ -166,10 +166,10 @@ impl LocalPendingEnrollment {
166166

167167
parsec_data!("schema/pki/local_pending_enrollment.json5");
168168

169-
impl TryFrom<LocalPendingEnrollmentData> for LocalPendingEnrollment {
169+
impl TryFrom<PKILocalPendingEnrollmentData> for PKILocalPendingEnrollment {
170170
type Error = &'static str;
171171

172-
fn try_from(data: LocalPendingEnrollmentData) -> Result<Self, Self::Error> {
172+
fn try_from(data: PKILocalPendingEnrollmentData) -> Result<Self, Self::Error> {
173173
let addr = {
174174
let server_addr =
175175
ParsecAddr::from_http_url(&data.server_url).map_err(|_| "Invalid server URL")?;
@@ -188,8 +188,8 @@ impl TryFrom<LocalPendingEnrollmentData> for LocalPendingEnrollment {
188188
}
189189
}
190190

191-
impl From<LocalPendingEnrollment> for LocalPendingEnrollmentData {
192-
fn from(obj: LocalPendingEnrollment) -> Self {
191+
impl From<PKILocalPendingEnrollment> for PKILocalPendingEnrollmentData {
192+
fn from(obj: PKILocalPendingEnrollment) -> Self {
193193
let server_url = {
194194
let server_addr = ParsecAddr::new(
195195
obj.addr.hostname().to_string(),

libparsec/crates/types/tests/unit/pki.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn serde_pki_enrollment_submit_payload() {
209209
"6f454350e17d34cb15e3f2cd88067b5d4ab38d4c08a001"
210210
)[..],
211211
Box::new(|alice: &Device| {
212-
LocalPendingEnrollment {
212+
PKILocalPendingEnrollment {
213213
cert_ref: X509CertificateReference::from(X509CertificateHash::fake_sha256())
214214
.add_or_replace_uri(X509WindowsCngURI::from(&b"foo"[..])),
215215
addr: ParsecPkiEnrollmentAddr::from_str(
@@ -265,7 +265,7 @@ fn serde_pki_enrollment_submit_payload() {
265265
"75bbae9cd9062204d0"
266266
)[..],
267267
Box::new(|alice: &Device| {
268-
LocalPendingEnrollment {
268+
PKILocalPendingEnrollment {
269269
cert_ref: X509CertificateReference::from(X509CertificateHash::fake_sha256()),
270270
addr: ParsecPkiEnrollmentAddr::from_str(
271271
"parsec3://parsec.example.com/my_org?a=pki_enrollment",
@@ -288,17 +288,17 @@ fn serde_pki_enrollment_submit_payload() {
288288
fn serde_local_pending_enrollment(
289289
alice: &Device,
290290
#[case] raw: &[u8],
291-
#[case] generate_expected: Box<dyn FnOnce(&Device) -> LocalPendingEnrollment>,
291+
#[case] generate_expected: Box<dyn FnOnce(&Device) -> PKILocalPendingEnrollment>,
292292
) {
293293
let expected = generate_expected(alice);
294294

295295
println!("***expected: {:?}", expected.dump());
296-
let data = LocalPendingEnrollment::load(raw).unwrap();
296+
let data = PKILocalPendingEnrollment::load(raw).unwrap();
297297
p_assert_eq!(data, expected);
298298

299299
// Also test serialization round trip
300300
let raw = data.dump();
301-
let data = LocalPendingEnrollment::load(&raw).unwrap();
301+
let data = PKILocalPendingEnrollment::load(&raw).unwrap();
302302

303303
p_assert_eq!(data, expected);
304304
}

0 commit comments

Comments
 (0)