Skip to content

Commit b579d94

Browse files
feat: Remove caller restrictions get_changes_since endpoint (#2257)
1 parent d8c6591 commit b579d94

File tree

2 files changed

+9
-43
lines changed

2 files changed

+9
-43
lines changed

rs/nns/integration_tests/src/registry_get_changes_since.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ use ic_nns_test_utils::{
55
registry_get_changes_since, setup_nns_canisters, state_machine_builder_for_nns_tests,
66
},
77
};
8-
use ic_registry_transport::pb::v1::{
9-
registry_error, RegistryError, RegistryGetChangesSinceResponse,
10-
};
8+
use ic_registry_transport::pb::v1::RegistryGetChangesSinceResponse;
119
use std::str::FromStr;
1210

1311
#[test]
14-
fn test_disallow_opaque_caller() {
12+
fn test_allow_opaque_caller() {
1513
// Step 1: Prepare the world.
1614
let state_machine = state_machine_builder_for_nns_tests().build();
1715

@@ -36,27 +34,11 @@ fn test_disallow_opaque_caller() {
3634
deltas,
3735
} = response;
3836

39-
assert_eq!(version, 0);
40-
assert_eq!(deltas, vec![]);
41-
42-
let error = error.unwrap();
43-
let RegistryError { code, reason, key } = error;
44-
45-
assert_eq!(key, Vec::<u8>::new());
46-
47-
assert_eq!(
48-
registry_error::Code::try_from(code),
49-
Ok(registry_error::Code::Authorization)
50-
);
51-
let reason = reason.to_lowercase();
52-
for key_word in ["caller", "self-authenticating", "anonymous", "opaque"] {
53-
assert!(
54-
reason.contains(key_word),
55-
"{} not in {:?}",
56-
key_word,
57-
reason
58-
);
59-
}
37+
assert_eq!(error, None);
38+
// The important thing is that deltas is not empty. The exact number of
39+
// elements is not so important.
40+
assert_eq!(deltas.len(), 13);
41+
assert_eq!(version, 1);
6042
}
6143

6244
#[test]

rs/registry/canister/canister/canister.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use candid::{candid_method, Decode};
22
use dfn_candid::{candid, candid_one};
33
use dfn_core::{
4-
api::{arg_data, caller, data_certificate, reply, trap_with},
4+
api::{arg_data, data_certificate, reply, trap_with},
55
over, over_async, stable,
66
};
7-
use ic_base_types::{NodeId, PrincipalId, PrincipalIdClass};
7+
use ic_base_types::{NodeId, PrincipalId};
88
use ic_certified_map::{AsHashTree, HashTree};
99
use ic_nervous_system_string::clamp_debug_len;
1010
use ic_nns_constants::{GOVERNANCE_CANISTER_ID, ROOT_CANISTER_ID};
@@ -188,22 +188,6 @@ ic_nervous_system_common_build_metadata::define_get_build_metadata_candid_method
188188
#[export_name = "canister_query get_changes_since"]
189189
fn get_changes_since() {
190190
fn main() -> Result<RegistryGetChangesSinceResponse, (Code, String)> {
191-
// Authorize: Only self-authenticating and anonymous principals are allowed to call us.
192-
const ALLOWED_CALLER_CLASSES: [Result<PrincipalIdClass, String>; 2] = [
193-
Ok(PrincipalIdClass::SelfAuthenticating),
194-
Ok(PrincipalIdClass::Anonymous),
195-
];
196-
let class = caller().class();
197-
if !ALLOWED_CALLER_CLASSES.contains(&class) {
198-
return Err((
199-
Code::Authorization,
200-
format!(
201-
"Caller must be self-authenticating, or anonymous (but was {:?}).",
202-
class,
203-
),
204-
));
205-
}
206-
207191
// Parse request.
208192
let request = deserialize_get_changes_since_request(arg_data())
209193
.map_err(|err| (Code::MalformedMessage, err.to_string()))?;

0 commit comments

Comments
 (0)