()
| 11 | |
| 12 | #[test] |
| 13 | fn cancel_pending_requests() { |
| 14 | let TestEnv { |
| 15 | env, canister_ids, .. |
| 16 | } = setup_new_env(); |
| 17 | |
| 18 | // allow anyone to create system upgrade requests |
| 19 | let add_permission = RequestOperationInput::EditPermission(EditPermissionOperationInput { |
| 20 | resource: station_api::ResourceDTO::System(SystemResourceActionDTO::Upgrade), |
| 21 | auth_scope: Some(station_api::AuthScopeDTO::Authenticated), |
| 22 | user_groups: None, |
| 23 | users: None, |
| 24 | }); |
| 25 | execute_request( |
| 26 | &env, |
| 27 | WALLET_ADMIN_USER, |
| 28 | canister_ids.station, |
| 29 | add_permission, |
| 30 | ) |
| 31 | .unwrap(); |
| 32 | |
| 33 | // register a new user (Alice) |
| 34 | let alice_user_id = user_test_id(0); |
| 35 | let add_user = RequestOperationInput::AddUser(AddUserOperationInput { |
| 36 | name: "Alice".to_string(), |
| 37 | identities: vec![alice_user_id], |
| 38 | groups: vec![], |
| 39 | status: station_api::UserStatusDTO::Active, |
| 40 | }); |
| 41 | let request_dto = |
| 42 | execute_request(&env, WALLET_ADMIN_USER, canister_ids.station, add_user).unwrap(); |
| 43 | let alice_user_dto = match request_dto.operation { |
| 44 | RequestOperationDTO::AddUser(operation) => operation.user.unwrap(), |
| 45 | _ => panic!("Unexpected request operation: {:?}", request_dto.operation), |
| 46 | }; |
| 47 | |
| 48 | // register a new user (Bob) |
| 49 | let bob_user_id = user_test_id(1); |
| 50 | let add_user = RequestOperationInput::AddUser(AddUserOperationInput { |
| 51 | name: "Bob".to_string(), |
| 52 | identities: vec![bob_user_id], |
| 53 | groups: vec![], |
| 54 | status: station_api::UserStatusDTO::Active, |
| 55 | }); |
| 56 | execute_request(&env, WALLET_ADMIN_USER, canister_ids.station, add_user).unwrap(); |
| 57 | |
| 58 | // Alice makes a bunch of system upgrade requests |
| 59 | let station_upgrade = RequestOperationInput::SystemUpgrade(SystemUpgradeOperationInput { |
| 60 | target: SystemUpgradeTargetDTO::UpgradeStation, |
| 61 | module: vec![], |
| 62 | module_extra_chunks: None, |
| 63 | arg: None, |
| 64 | take_backup_snapshot: None, |
| 65 | }); |
| 66 | let mut alice_request_dtos = vec![]; |
| 67 | for _ in 0..10 { |
| 68 | let request_dto = submit_request( |
| 69 | &env, |
| 70 | alice_user_id, |
nothing calls this directly
no test coverage detected