Skip to content

Commit

Permalink
Fix upgraded for 0.9.6 (and use better testdata)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Bruijnzeels committed Nov 29, 2023
1 parent 5ea3718 commit da81cb2
Show file tree
Hide file tree
Showing 87 changed files with 1,233 additions and 850 deletions.
25 changes: 23 additions & 2 deletions src/upgrades/pre_0_10_0/cas_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl UpgradeAggregateStorePre0_14 for CasMigration {
match old_event {
Pre0_10CertAuthEvent::AspaObjectsUpdated { updates, .. } => {
let ca = old_command.handle().clone();
let removed = updates.removed;
let removed = updates.removed.into_iter().map(rpki::resources::Asn::from).collect();
let added_or_updated = updates
.updated
.into_iter()
Expand Down Expand Up @@ -187,12 +187,33 @@ impl UpgradeAggregateStorePre0_14 for CasMigration {
UnconvertedEffect::Success { events } => {
let mut full_events: Vec<CertAuthEvent> = vec![]; // We just had numbers, we need to include the full events
for old_event in events {
full_events.push(old_event.try_into()?);
match old_event {
Pre0_10CertAuthEvent::AspaConfigAdded { .. }
| Pre0_10CertAuthEvent::AspaConfigRemoved { .. }
| Pre0_10CertAuthEvent::AspaConfigUpdated { .. }
| Pre0_10CertAuthEvent::AspaObjectsUpdated { .. } => {
// we only expect AspaObjectsUpdated to be possible outside of
// Aspa related commands, e.g. because of a key rollover, but
// to be sure.. we do not migrate any of the ASPA events in
// this migration.
}
_ => {
full_events.push(old_event.try_into()?);
}
}
}
new_command_builder.finish_with_events(full_events)
}
};

// if the new command would be a no-op because no events are actually migrated,
// then return CommandMigrationEffect::Nothing
if let Some(events) = new_command.events() {
if events.is_empty() {
return Ok(CommandMigrationEffect::Nothing);
}
}

Ok(CommandMigrationEffect::StoredCommand(new_command))
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/upgrades/pre_0_10_0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use rpki::ca::publication::Base64;
use rpki::repository::x509::Time;

use crate::commons::api::AspaDefinition;
use crate::commons::api::CustomerAsn;

pub use self::cas_migration::*;

Expand Down Expand Up @@ -52,5 +51,16 @@ pub struct Pre0_10_0AspaObjectsUpdates {
pub updated: Vec<Pre0_10_0AspaInfo>,

#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub removed: Vec<CustomerAsn>,
pub removed: Vec<Pre0_10_0CustomerAsn>,
}

//------------ Pre_0_10_0CustomerAsn -------------------------------------------

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Pre0_10_0CustomerAsn(Pre0_14_0ProviderAs); // re-use ProviderAs for string parsing

impl From<Pre0_10_0CustomerAsn> for rpki::resources::Asn {
fn from(pre: Pre0_10_0CustomerAsn) -> Self {
pre.0.provider
}
}
34 changes: 0 additions & 34 deletions src/upgrades/pre_0_14_0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,37 +476,3 @@ pub struct Pre0_14_0AspaProvidersUpdate {
added: Vec<Pre0_14_0ProviderAs>,
removed: Vec<Pre0_14_0ProviderAs>,
}

// //------------ AspaObjectsUpdates ------------------------------------------

// #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
// pub struct Pre0_14_0AspaObjectsUpdates {
// #[serde(skip_serializing_if = "Vec::is_empty", default)]
// updated: Vec<Pre0_14_0AspaInfo>,

// #[serde(skip_serializing_if = "Vec::is_empty", default)]
// removed: Vec<CustomerAsn>,
// }

// //------------ Pre0_14_0AspaInfo -------------------------------------------

// #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
// pub struct Pre0_14_0AspaInfo {
// // The customer ASN and all Provider ASNs
// definition: Pre0_14_0AspaDefinition,

// // The validity time for this ASPA.
// validity: Validity,

// // The serial number (needed for revocation)
// serial: Serial,

// // The URI where this object is expected to be published
// uri: uri::Rsync,

// // The actual ASPA object in base64 format.
// base64: Base64,

// // The ASPA object's hash
// hash: Hash,
// }

Large diffs are not rendered by default.

90 changes: 0 additions & 90 deletions test-resources/migrations/v0_9_6/ca_objects/testbed-client.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"actor": "admin-token",
"time": "2023-10-19T08:19:47.707453175Z",
"handle": "testbed-client",
"time": "2023-11-29T10:58:02.903827344Z",
"handle": "krill-upgrade-test",
"version": 1,
"sequence": 1,
"details": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"actor": "admin-token",
"time": "2023-10-19T08:20:03.545594564Z",
"handle": "testbed-client",
"time": "2023-11-29T10:58:47.337300726Z",
"handle": "krill-upgrade-test",
"version": 2,
"sequence": 2,
"details": {
"type": "repo_update",
"service_uri": "https://testbed.krill.cloud/rfc8181/testbed-client/"
"service_uri": "https://testbed.krill.cloud/rfc8181/krill-upgrade-test/"
},
"effect": {
"result": "success",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"actor": "krill",
"time": "2023-10-19T08:20:04.680568334Z",
"handle": "testbed-client",
"time": "2023-11-29T10:58:48.549103631Z",
"handle": "krill-upgrade-test",
"version": 3,
"sequence": 3,
"details": {
Expand All @@ -11,9 +11,9 @@
{
"resource_class_name": "0",
"resources": {
"asn": "AS204325, AS211321",
"v4": "185.49.140.0/22",
"v6": "2a04:b900::/29"
"asn": "AS65000-AS65005",
"v4": "192.168.0.0/16",
"v6": "2001:db8::/32"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"actor": "krill",
"time": "2023-10-19T08:20:06.717504859Z",
"handle": "testbed-client",
"time": "2023-11-29T10:58:50.764147557Z",
"handle": "krill-upgrade-test",
"version": 5,
"sequence": 4,
"details": {
"type": "update_rcvd_cert",
"resource_class_name": "0",
"resources": {
"asn": "AS204325, AS211321",
"v4": "185.49.140.0/22",
"v6": "2a04:b900::/29"
"asn": "AS65000-AS65005",
"v4": "192.168.0.0/16",
"v6": "2001:db8::/32"
}
},
"effect": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"actor": "admin-token",
"time": "2023-11-29T11:00:14.915606890Z",
"handle": "krill-upgrade-test",
"version": 6,
"sequence": 5,
"details": {
"type": "roa_definition_updates",
"updates": {
"added": [
{
"asn": 64496,
"prefix": "192.168.0.0/16"
}
],
"removed": []
}
},
"effect": {
"result": "success",
"events": [
6,
7
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"actor": "admin-token",
"time": "2023-11-29T11:00:32.734882878Z",
"handle": "krill-upgrade-test",
"version": 8,
"sequence": 6,
"details": {
"type": "roa_definition_updates",
"updates": {
"added": [
{
"asn": 64496,
"prefix": "2001:db8::/64"
}
],
"removed": []
}
},
"effect": {
"result": "success",
"events": [
8,
9
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"actor": "admin-token",
"time": "2023-11-29T11:00:53.349370524Z",
"handle": "krill-upgrade-test",
"version": 10,
"sequence": 7,
"details": {
"type": "roa_definition_updates",
"updates": {
"added": [],
"removed": [
{
"asn": 64496,
"prefix": "192.168.0.0/16"
}
]
}
},
"effect": {
"result": "success",
"events": [
10,
11
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"actor": "admin-token",
"time": "2023-11-29T11:01:01.322993044Z",
"handle": "krill-upgrade-test",
"version": 12,
"sequence": 8,
"details": {
"type": "roa_definition_updates",
"updates": {
"added": [
{
"asn": 64496,
"prefix": "192.168.0.0/24"
}
],
"removed": []
}
},
"effect": {
"result": "success",
"events": [
12,
13
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"actor": "admin-token",
"time": "2023-11-29T11:01:19.358422295Z",
"handle": "krill-upgrade-test",
"version": 14,
"sequence": 9,
"details": {
"type": "roa_definition_updates",
"updates": {
"added": [
{
"asn": 0,
"prefix": "192.168.0.0/22"
}
],
"removed": []
}
},
"effect": {
"result": "success",
"events": [
14,
15
]
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"actor": "admin-token",
"time": "2023-10-19T08:31:21.961752867Z",
"handle": "testbed-client",
"time": "2023-11-29T11:09:15.443905088Z",
"handle": "krill-upgrade-test",
"version": 16,
"sequence": 7,
"sequence": 10,
"details": {
"type": "aspas_update",
"updates": {
"add_or_replace": [
{
"customer": "AS204325",
"customer": "AS65000",
"providers": [
"AS65000",
"AS65001"
"AS65001(v4)",
"AS65002(v6)",
"AS65003"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
{
"actor": "admin-token",
"time": "2023-10-19T08:35:28.666963249Z",
"handle": "testbed-client",
"time": "2023-11-29T11:09:33.556191233Z",
"handle": "krill-upgrade-test",
"version": 18,
"sequence": 9,
"sequence": 11,
"details": {
"type": "aspas_update_existing",
"customer": "AS204325",
"customer": "AS65000",
"update": {
"added": [
"AS65002(v4)",
"AS65003(v6)"
],
"added": [],
"removed": [
"AS65001"
"AS65003"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"actor": "admin-token",
"time": "2023-11-29T11:10:10.854747771Z",
"handle": "krill-upgrade-test",
"version": 20,
"sequence": 12,
"details": {
"type": "aspas_update",
"updates": {
"add_or_replace": [],
"remove": [
"AS65000"
]
}
},
"effect": {
"result": "success",
"events": [
20,
21
]
}
}
Loading

0 comments on commit da81cb2

Please sign in to comment.