Skip to content

Commit 34e2fd3

Browse files
committed
Remove RepoBuilder::commit_skip_validation
1 parent 3961b36 commit 34e2fd3

File tree

2 files changed

+10
-67
lines changed

2 files changed

+10
-67
lines changed

tuf/src/client.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,16 +1434,14 @@ mod test {
14341434
// Store an expired root in the local store.
14351435
let mut local = EphemeralRepository::<Json>::new();
14361436
let metadata1 = RepoBuilder::create(&mut local)
1437+
.current_time(Utc.timestamp(0, 0))
14371438
.trusted_root_keys(&[&KEYS[0]])
14381439
.trusted_targets_keys(&[&KEYS[0]])
14391440
.trusted_snapshot_keys(&[&KEYS[0]])
14401441
.trusted_timestamp_keys(&[&KEYS[0]])
1441-
.stage_root_with_builder(|bld| {
1442-
bld.consistent_snapshot(true)
1443-
.expires(Utc.ymd(1970, 1, 1).and_hms(0, 0, 0))
1444-
})
1442+
.stage_root_with_builder(|bld| bld.consistent_snapshot(true))
14451443
.unwrap()
1446-
.commit_skip_validation()
1444+
.commit()
14471445
.await
14481446
.unwrap();
14491447

@@ -1709,38 +1707,32 @@ mod test {
17091707

17101708
// Store an expired root in the local store.
17111709
let metadata1 = RepoBuilder::create(&mut local)
1710+
.current_time(Utc.timestamp(0, 0))
17121711
.trusted_root_keys(&[&KEYS[0]])
17131712
.trusted_targets_keys(&[&KEYS[0]])
17141713
.trusted_snapshot_keys(&[&KEYS[0]])
17151714
.trusted_timestamp_keys(&[&KEYS[0]])
1716-
.stage_root_with_builder(|bld| {
1717-
bld.version(1)
1718-
.consistent_snapshot(true)
1719-
.expires(Utc.ymd(1970, 1, 1).and_hms(0, 0, 0))
1720-
})
1715+
.stage_root_with_builder(|bld| bld.version(1).consistent_snapshot(true))
17211716
.unwrap()
1722-
.commit_skip_validation()
1717+
.commit()
17231718
.await
17241719
.unwrap();
17251720

17261721
let metadata2 = RepoBuilder::create(&mut local)
1722+
.current_time(Utc.timestamp(0, 0))
17271723
.trusted_root_keys(&[&KEYS[0]])
17281724
.trusted_targets_keys(&[&KEYS[0]])
17291725
.trusted_snapshot_keys(&[&KEYS[0]])
17301726
.trusted_timestamp_keys(&[&KEYS[0]])
1731-
.stage_root_with_builder(|bld| {
1732-
bld.version(2)
1733-
.consistent_snapshot(true)
1734-
.expires(Utc.ymd(1970, 1, 1).and_hms(0, 0, 0))
1735-
})
1727+
.stage_root_with_builder(|bld| bld.version(2).consistent_snapshot(true))
17361728
.unwrap()
17371729
.stage_targets_with_builder(|bld| bld.version(2))
17381730
.unwrap()
17391731
.stage_snapshot_with_builder(|bld| bld.version(2))
17401732
.unwrap()
17411733
.stage_timestamp_with_builder(|bld| bld.version(2))
17421734
.unwrap()
1743-
.commit_skip_validation()
1735+
.commit()
17441736
.await
17451737
.unwrap();
17461738

tuf/src/repo_builder.rs

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -917,17 +917,6 @@ where
917917
self.stage_targets_if_necessary()?.commit().await
918918
}
919919

920-
/// Commit the metadata for this repository without validating it.
921-
///
922-
/// Warning: This can write invalid metadata to a repository without
923-
/// validating that it is correct.
924-
#[cfg(test)]
925-
pub async fn commit_skip_validation(self) -> Result<RawSignedMetadataSet<D>> {
926-
self.stage_targets_if_necessary()?
927-
.commit_skip_validation()
928-
.await
929-
}
930-
931920
fn need_new_targets(&self) -> bool {
932921
// We need a new targets metadata if we added any targets.
933922
if !self.state.targets.is_empty() {
@@ -1086,17 +1075,6 @@ where
10861075
self.stage_snapshot_if_necessary()?.commit().await
10871076
}
10881077

1089-
/// Commit the metadata for this repository without validating it.
1090-
///
1091-
/// Warning: This can write invalid metadata to a repository without
1092-
/// validating that it is correct.
1093-
#[cfg(test)]
1094-
pub async fn commit_skip_validation(self) -> Result<RawSignedMetadataSet<D>> {
1095-
self.stage_snapshot_if_necessary()?
1096-
.commit_skip_validation()
1097-
.await
1098-
}
1099-
11001078
fn need_new_snapshot(&self) -> bool {
11011079
// We need a new snapshot metadata if we staged a new root.
11021080
if self.state.staged_root.is_some() {
@@ -1255,17 +1233,6 @@ where
12551233
self.stage_timestamp_if_necessary()?.commit().await
12561234
}
12571235

1258-
/// Commit the metadata for this repository without validating it.
1259-
///
1260-
/// Warning: This can write invalid metadata to a repository without
1261-
/// validating that it is correct.
1262-
#[cfg(test)]
1263-
pub async fn commit_skip_validation(self) -> Result<RawSignedMetadataSet<D>> {
1264-
self.stage_timestamp_if_necessary()?
1265-
.commit_skip_validation()
1266-
.await
1267-
}
1268-
12691236
fn need_new_timestamp(&self) -> bool {
12701237
// We need a new timestamp metadata if we staged a new root.
12711238
if self.state.staged_root.is_some() {
@@ -1312,23 +1279,7 @@ where
13121279
pub async fn commit(mut self) -> Result<RawSignedMetadataSet<D>> {
13131280
self.validate_built_metadata()?;
13141281
self.write_repo().await?;
1315-
Ok(self.build_skip_validation())
1316-
}
13171282

1318-
/// Commit the metadata for this repository without validating it.
1319-
///
1320-
/// Warning: This can write invalid metadata to a repository without validating that it is
1321-
/// correct.
1322-
#[cfg(test)]
1323-
pub async fn commit_skip_validation(mut self) -> Result<RawSignedMetadataSet<D>> {
1324-
self.write_repo().await?;
1325-
Ok(self.build_skip_validation())
1326-
}
1327-
1328-
/// Build the metadata without validating it for correctness.
1329-
///
1330-
/// Warning: This can produce invalid metadata.
1331-
fn build_skip_validation(self) -> RawSignedMetadataSet<D> {
13321283
let mut builder = RawSignedMetadataSetBuilder::new();
13331284

13341285
if let Some(root) = self.state.staged_root {
@@ -1347,7 +1298,7 @@ where
13471298
builder = builder.timestamp(timestamp.raw);
13481299
}
13491300

1350-
builder.build()
1301+
Ok(builder.build())
13511302
}
13521303

13531304
/// Before we commit any metadata, make sure that we can update from our

0 commit comments

Comments
 (0)