pub const PROTOCOL_BASE: &str = "https://firstperson.network/protocols/provision-integration/1.0";
pub const PROVISION_INTEGRATION: &str =
"https://firstperson.network/protocols/provision-integration/1.0/provision-integration";
pub const PROVISION_INTEGRATION_RESULT: &str =
"https://firstperson.network/protocols/provision-integration/1.0/provision-integration-result";
pub const CANONICAL_PROVISION_INTEGRATION: &str =
"https://trusttasks.org/spec/provision/integration/0.1";
pub const CANONICAL_PROVISION_INTEGRATION_RESULT: &str =
"https://trusttasks.org/spec/provision/integration/0.1#response";
pub fn result_uri_for(request_uri: &str) -> &'static str {
if request_uri == CANONICAL_PROVISION_INTEGRATION {
CANONICAL_PROVISION_INTEGRATION_RESULT
} else {
PROVISION_INTEGRATION_RESULT
}
}
pub mod request {
pub use crate::provision_integration::http::{AssertionMode, ProvisionIntegrationRequest};
}
pub mod result {
pub use crate::provision_integration::http::{ProvisionIntegrationResponse, ProvisionSummary};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn result_uri_for_canonical_request_emits_canonical_response() {
assert_eq!(
result_uri_for(CANONICAL_PROVISION_INTEGRATION),
CANONICAL_PROVISION_INTEGRATION_RESULT
);
}
#[test]
fn result_uri_for_legacy_request_emits_legacy_response() {
assert_eq!(
result_uri_for(PROVISION_INTEGRATION),
PROVISION_INTEGRATION_RESULT
);
}
#[test]
fn result_uri_for_unknown_request_defaults_to_legacy() {
assert_eq!(
result_uri_for("https://example.invalid/something-else"),
PROVISION_INTEGRATION_RESULT
);
}
#[test]
fn canonical_uri_matches_registry() {
assert_eq!(
CANONICAL_PROVISION_INTEGRATION,
"https://trusttasks.org/spec/provision/integration/0.1"
);
assert_eq!(
CANONICAL_PROVISION_INTEGRATION_RESULT,
"https://trusttasks.org/spec/provision/integration/0.1#response"
);
}
}