()
| 15 | |
| 16 | #[test] |
| 17 | fn notification_authorization() { |
| 18 | let TestEnv { |
| 19 | env, canister_ids, .. |
| 20 | } = setup_new_env(); |
| 21 | |
| 22 | // admin makes a failed request which triggers a notification |
| 23 | let change_canister_operation_input = SystemUpgradeOperationInput { |
| 24 | target: SystemUpgradeTargetDTO::UpgradeUpgrader, |
| 25 | module: vec![], |
| 26 | module_extra_chunks: None, |
| 27 | arg: None, |
| 28 | take_backup_snapshot: None, |
| 29 | }; |
| 30 | let request_status = execute_request_with_extra_ticks( |
| 31 | &env, |
| 32 | WALLET_ADMIN_USER, |
| 33 | canister_ids.station, |
| 34 | RequestOperationInput::SystemUpgrade(change_canister_operation_input.clone()), |
| 35 | 10, |
| 36 | ) |
| 37 | .unwrap_err() |
| 38 | .unwrap(); |
| 39 | match request_status { |
| 40 | RequestStatusDTO::Failed { .. } => (), |
| 41 | _ => panic!("Unexpected request status: {request_status:?}"), |
| 42 | }; |
| 43 | |
| 44 | // admin user can list and update notifications |
| 45 | let list_notifications_input = ListNotificationsInput { |
| 46 | status: None, |
| 47 | notification_type: None, |
| 48 | from_dt: None, |
| 49 | to_dt: None, |
| 50 | }; |
| 51 | let res: (ApiResult<ListNotificationsResponse>,) = update_candid_as( |
| 52 | &env, |
| 53 | canister_ids.station, |
| 54 | WALLET_ADMIN_USER, |
| 55 | "list_notifications", |
| 56 | (list_notifications_input.clone(),), |
| 57 | ) |
| 58 | .unwrap(); |
| 59 | let notifications = res.0.unwrap().notifications; |
| 60 | assert_eq!(notifications.len(), 1); |
| 61 | let admin_notification = ¬ifications[0]; |
| 62 | let mark_notifications_read_input = MarkNotificationsReadInput { |
| 63 | notification_ids: vec![admin_notification.id.clone()], |
| 64 | read: true, |
| 65 | }; |
| 66 | let res: (ApiResult<()>,) = update_candid_as( |
| 67 | &env, |
| 68 | canister_ids.station, |
| 69 | WALLET_ADMIN_USER, |
| 70 | "mark_notifications_read", |
| 71 | (mark_notifications_read_input.clone(),), |
| 72 | ) |
| 73 | .unwrap(); |
| 74 | res.0.unwrap(); |
nothing calls this directly
no test coverage detected