Усилить безопасность и надёжность выполнения операций
This commit is contained in:
1 parent
626f2845e2
commit
8318e4b560
40 files changed
+1343
-185
No files matched your search
@@ -15,6 +15,7 @@ pub struct RuntimeRequestContext {
|
||||
pub response_cache_scope: Option<ResponseCacheScope>,
|
||||
pub metering_context: Option<MeteringContext>,
|
||||
pub confirmation_token: Option<String>,
|
||||
pub approval_granted: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -32,6 +33,7 @@ impl RuntimeRequestContext {
|
||||
response_cache_scope: None,
|
||||
metering_context: None,
|
||||
confirmation_token: None,
|
||||
approval_granted: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +91,15 @@ impl RuntimeRequestContext {
|
||||
pub fn confirmation_token(&self) -> Option<&str> {
|
||||
self.confirmation_token.as_deref()
|
||||
}
|
||||
|
||||
pub fn with_approval_granted(mut self) -> Self {
|
||||
self.approval_granted = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn approval_granted(&self) -> bool {
|
||||
self.approval_granted
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ResponseCacheScope> for crank_core::ResponseCacheScope {
|
||||
@@ -154,6 +165,7 @@ mod tests {
|
||||
assert_eq!(context.correlation_id, "req_123");
|
||||
assert!(context.response_cache_scope.is_none());
|
||||
assert!(context.confirmation_token.is_none());
|
||||
assert!(!context.approval_granted());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -187,4 +199,11 @@ mod tests {
|
||||
|
||||
assert_eq!(context.confirmation_token(), Some("ct_123"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn records_prior_human_approval() {
|
||||
let context = RuntimeRequestContext::from_request_id("req_123").with_approval_granted();
|
||||
|
||||
assert!(context.approval_granted());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user