MCPcopy Create free account
hub / github.com/dfinity/orbit / can_remove_admin

Function can_remove_admin

core/station/impl/src/services/user.rs:369–389  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

367
368 #[tokio::test]
369 async fn can_remove_admin() {
370 let ctx: TestContext = setup();
371 let mut caller = user_test_utils::mock_user();
372 caller.identities = vec![ctx.call_context.caller()];
373 caller.groups = vec![*ADMIN_GROUP_ID];
374 let mut admin = user_test_utils::mock_user();
375 admin.identities = vec![Principal::from_slice(&[255; 29])];
376 admin.groups = vec![*ADMIN_GROUP_ID, [1; 16]];
377
378 ctx.repository.insert(caller.to_key(), caller.clone());
379 ctx.repository.insert(admin.to_key(), admin.clone());
380
381 let result = ctx
382 .service
383 .remove_admin(&admin.identities[0], &ctx.call_context)
384 .await;
385 assert!(result.is_ok());
386
387 let admin = ctx.repository.get(&admin.to_key()).unwrap();
388 assert_eq!(admin.groups, vec![[1; 16]]);
389 }
390
391 #[tokio::test]
392 async fn fail_remove_self_admin() {

Callers

nothing calls this directly

Calls 6

remove_adminMethod · 0.80
setupFunction · 0.70
mock_userFunction · 0.50
insertMethod · 0.45
to_keyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected