| 798 | #[test] |
| 799 | #[ignore = "Requires environment configuration and is expensive"] |
| 800 | fn test_acls_public() { |
| 801 | #[tokio::main] |
| 802 | async fn run(context: &mut TestContext) { |
| 803 | let (filename, content) = context.random_file(); |
| 804 | |
| 805 | let username1 = context.get_username(1); |
| 806 | |
| 807 | // Share username1's file with the public. |
| 808 | context.do_login(1).await; |
| 809 | context |
| 810 | .service |
| 811 | .patch_file_content(&username1, &filename, content.clone()) |
| 812 | .await |
| 813 | .unwrap(); |
| 814 | |
| 815 | // Read username1's file as a guest before it is shared. |
| 816 | context.do_logout().await; |
| 817 | let err = context.service.get_file(&username1, &filename).await.unwrap_err(); |
| 818 | assert_eq!(io::ErrorKind::NotFound, err.kind(), "{}", err); |
| 819 | |
| 820 | // Share username1's file with the public. |
| 821 | context.do_login(1).await; |
| 822 | context |
| 823 | .service |
| 824 | .patch_file_acls( |
| 825 | &username1, |
| 826 | &filename, |
| 827 | &FileAcls::default().with_readers(["public".to_owned()]), |
| 828 | &FileAcls::default(), |
| 829 | ) |
| 830 | .await |
| 831 | .unwrap(); |
| 832 | |
| 833 | // Read username1's file as a guest again, now that it is shared. |
| 834 | context.do_logout().await; |
| 835 | let response = context.service.get_file(&username1, &filename).await.unwrap(); |
| 836 | assert_eq!(content, response); |
| 837 | } |
| 838 | run(&mut TestContext::new_from_env()); |
| 839 | } |
| 840 | |
| 841 | #[test] |
| 842 | #[ignore = "Requires environment configuration and is expensive"] |