https://opendal.apache.org/ logo
iCloud behavior test
# general
b
Hi.I encountered some troubles when setting the iCloud behavior test. What should I miss? If someone gives suggestions, I will be grateful. https://cdn.discordapp.com/attachments/1081052319342407715/1194089222534078554/20240109092238.png?ex=65af153f&is=659ca03f&hm=04f554332fa9d46a2594a4b6b5d884c9e6ae522e36e13c0503a82dee049a6152&
x
our behavior tests are capability based. Are you setting icloud's capability corrently?
x
Nearly all tests need write & read
think about it, how could we test services that only support stat?
b
ok,I didn't expect to be here.Because in my side verification demo, I can directly get metadata
x
It's fine to submit current progress as a PR
It might be a huge work if we need both read and write implemented.
In this screenshot I have seen somethings need to change. It's better to change them earlier.
b
No... I can't test the accuracy of the
path_cache
map, other things should be possible
emmm look like java?
x
I don't know, but at least not like the code in opendal.
x
I plan to add a general path cache in opendal today so our services don't need to implement them again.
And photos support should be split into another services.
b
All implementations of Opendal services are native. I plan to extract the read and write operations under the
raw
and` types` modules to complete the icloud section, and then bring it over
it is response format:
Copy code
{
  "document_id": "D3CDF1CA-4FC3-414F414",
  "item_id": "CJWdk48eFPlyeIgku15BQ",
  "owner_dsid": 8084889,
  "data_token": {
    "url": "https://cvws.icloud-content.com.cn/B/AVmSqNSADS3TXERCrSP8K03IsskyAa5ivBtFaEGn76Sneg1Y1IHHD76h/%25E7%25BA%25A225EF%25BC%259A%25E5%2585%2583%25E6%2598%25A5%25E7%25AF%2587.txt?o",
    "token": "CAogTxo7WveD8ur9E5uPEk8LDwigo1M8YTE7T5nb6t9pCaESbRCO+sW6zzEYjtehvM8xIgEAUgTIsskyWgTHD76haibl+cyPqp4U=",
    "signature": "AVmSqNSADSK03Issky",
    "wrapping_key": "EjXCZuP8ex5YA==",
    "reference_signature": "Aa5ivBtFaEG1IHHD76h"
  },
  "double_etag": "wb::wa"
}
only look like url is useful for me.
x
I’m guessing the response from the url will have range and content length?
b
I tried url.. But without any header information, it can be downloaded directly in website
x
What’s the headers returned from this url?
b
Copy code
url: https://cvws.icloud-content.com.cn/B/ATK6A
0/normal_file.txt.txt?o=AsfJkS382lQ9iHF2WvZ_eoRjTreT0LC6gHuPlSlY&e=1705252926&fl=&r=

header:{
k server    

v"AppleHttpServer/00f954eb1bdc0aaa7c04e434a9aff1da4f8c1183"
k date    v"Sun, 14 Jan 2024 16:22:06 GMT"
k content-type    v"text/plain"
k content-length    v"30482"
k x-responding-instance    v"contentvendorws:10001:icloud-contentvendorws-cn-east-1c-57fcfc69db-4dngq:8401:23RC177:343df7665737aa772f2"
k access-control-allow-credentials    v"false"
k access-control-allow-methods    v"GET,OPTIONS"
k access-control-allow-headers    v""
k content-disposition    v"attachment; filename=\"normal_file.txt.txt\"; filename*=UTF-8''normal_file.txt.txt"
k accept-ranges    v"bytes"
k last-modified    v"Sun, 14 Jan 2024 16:22:06 GMT"
k cache-control    v"no-transform,private,max-age=25920,s-maxage=25920"
k x-b3-traceid    v"2503aa12164860c5"
k strict-transport-security    v"max-age=315"
k x-apple-xrail    v"false"
k via    v"ef5f95d862fbe56114387549ef7ce198:06558e6537411d306d01a5e3565:3"
k x-apple-request-uuid    v"b1d42b16-3c5d-49c5-a"
k access-control-expose-headers    v"X-Apple-Request-UUID,Via"
k x-apple-edge-response-time    v"235"}
I don't find conten-range.It may be failed in last 13 tests reasons.
x
This header do said it accepts range bytes.
Do you handle the OpRead’s range correctly?
We need to set the Range header before sending requests to this uri.
b
thx for your patience.I will fix it tomorrow
sad day:)
x
Yep, only read only services like nginx will use this. They configure this in the CI.
b
Are you satisfied with this change? Can we continue:)
x
I still have many place to polish, but I think it's ok to merge first.
Hi, @bokket., does this mean apple will change those content for every request?
b
No,We only need to save a short session that is trusted by Apple.Although I haven't tested whether cookies should be kept yet.
Hi.We must maintain cookies in
SessionData
. It is an important return in
Auth verification
.Apple server will check
X-APPLE-WEBAUTH-USER cookie
when obtaining file status if object exist.We do not need to update each time ,it only needs to be saved when it is in
authenticate statue
when it is inited. It will return to what we want https://cdn.discordapp.com/attachments/1194089222718623834/1197880397850218537/20240119202703.png?ex=65bce00e&is=65aa6b0e&hm=096c67dfbfd5daa77f35c0c2ee5a6ba0b38000a5b194ec01d8bccb639ce5ea8f&
x
Are we using cookies across different domain?
I don't know why reqwest didn't set cookies.
b
Can I open an iusse to ask?
x
Are we applying cookies to different urls?
b
whether a default path for cookies is formed from the URI.https://github.com/seanmonstar/reqwest/issues/2005
I modified
http_utils
to print cookies
Copy code
url: https://setup.icloud.com/setup/ws/1/accountLogin
cookie: Cookie { cookie_string: Some("X-APPLE-WEBAUTH-USER=\"v=1:s=1:d=8084835989\";Expires=Wed, 21-Feb-2024 02:22:25 GMT;Path=/;Domain=.icloud.com.cn;Secure;HttpOnly"), name: Indexed(0, 20), value: Indexed(22, 42), expires: Some(DateTime(2024-02-21 2:22:25.0 +00:00:00)), max_age: None, domain: Some(Indexed(97, 110)), path: Some(Indexed(87, 88)), secure: Some(true), http_only: Some(true), same_site: None }
x
So the cookie feature doesn't work as we expected.
Let's handle the cookie by hand.
b
I think we don't set correctly`Other url: https://p219-drivews.icloud.com.cn/retrieveItemDetailsInFolders` Cookies.So I think it is cross -domain or different URL require
https: // setup.icloud.com/setup/WS/1/AcountLogin
cookies conten. https://cdn.discordapp.com/attachments/1194089222718623834/1198816778076307556/20240122102922.png?ex=65c04820&is=65add320&hm=b1a53288d9ad7913810a8f7cd38342162c5e0fd32ee9c64b51f6e1730cf4df7e&
If we handle it manually, do we still need`internal-http-cookies` feature?I read the relevant API. It provides
cookie_provider
to preserve, obviously we don’t need
x
Let's remove it.
b
Actually, I really want to mention an`iusse`..........Because I don't understand what Applehttpserver has done
x
For "mention an issue", what do you mean?
b
Open iusse for
reqwest
x
Feel free to do so if you are interested.
BTW, cookies contain sensitive information, please make sure you have mask the content before sending out.
How to reduce the request rate?I have been blocked for the second time.I think there will be less opportunities for testing write behavior. https://cdn.discordapp.com/attachments/1194089222718623834/1199183116959486073/20240123104347.png?ex=65c19d4e&is=65af284e&hm=fdb4391fa3d5a92be0133633a0f735cba8395206ac9d0f894bf1a30aa290f7d6&
x
Maybe we can persist the cookies to local fs like icloud-py does.
Did I not add an appropriate header?It seems to need Multipart, but pyicloud is directly
post url
x
pyicloud is using request which will use multipart automanticlly.
b
I don't quite understand this test.In icloud ,file size must obtain,it will generates a receipt.Add the receipt if we have one. Will be absent for 0-sized files(The result I saw was to become dir) https://cdn.discordapp.com/attachments/1194089222718623834/1199665891760160818/20240124184059.png?ex=65c35eed&is=65b0e9ed&hm=ae5f90298f2c5e6783e2606f86040efd9eeeae3e5f5654a3e5514cd791ee7b0a&
x
Which part you didn't understand?
This test seems direct and clear.
x
🤔 , How could this be a dir?
We are calling
op.write(path, content)
here,
path
must be a file instead.
b
It's my fault,I have fixed it. I have new worries now. The size of each time is less than 4MB, but there will always be a beyond SIZE failed because of writing close.I guess it was the server that was turned off by itself, it returned my size less than the current writing size. Have any better suggestion? https://cdn.discordapp.com/attachments/1194089222718623834/1199786812395233289/20240125023438.png?ex=65c3cf8b&is=65b15a8b&hm=4a10b18a2d1e5c5a21f7db2cf1c0b09ee1693c7e2c1b2b679f70a69f5185176c&
x
Can’t tell from the error message. We need to know how you implement write function.
b
cc in pr?We may upload 1MB each time .
x
🤔 , why 1MiB?
Do you tried to use pyicloud to upload a 4MiB file?
b
no.pyicloud not support china region,we some test write done 3MB in web but also write close timeout.I confused
x
support chain region should be simple by adding a
cn
to endpoint?
How about test the behavior via pyicloud first before making decisions?
It's possible that we did something wrong at our side like constructing a wrong request.
b
no,Our request is not a problem.I open a single test alone to perform a single test on the previous failure case like
OPENDAL_TEST=icloud cargo test behavior::test_stat_nested_parent_dir --features=tests,services-icloud
.It sometimes success , failed in 3~4MB. But I reopen other single tests, 3MB was also successful, so I don't understand
Copy code
get_upload_url path:acb3a9c4-4dcd-4f36-8019-cbb5e829616b !@#$%^&()_+-=;',.txt | contenws size:3554628 | docwsid:E6020E4E-B7E5-4EC9-BE6D-B6F1F1A76B41
test behavior::test_stat_with_special_chars ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 64 filtered out; finished in 15.61s


name:c67b26b8-f256-48c0-b3b0-6b7bf545143b | size:3328180 | id:9D0A2C6C-0A87-423B-BED6-0883E2FB6305
  2024-01-25T08:20:01.342297Z ERROR opendal::services: service=icloud operation=Writer::close path=ddb80d80-82c6-4895-943a-ea20f9ab9c9d/c67b26b8-f256-48c0-b3b0-6b7bf545143b written=3328180B -> data close failed: Unexpected (permanent) at Writer::close
failures:
    behavior::test_stat_nested_parent_dir

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 64 filtered out; finished in 138.52s


name:0a4d1a31-1c56-4892-9b7d-8f979859d369 | size:531744 | id:8AC27F9B-EDE9-40EE-9675-F579570E1C79
get_upload_url path:0a4d1a31-1c56-4892-9b7d-8f979859d369 | contenws size:531744 | docwsid:EA249D29-6FF6-4C4F-95FB-BF959F61BF90
test behavior::test_stat_nested_parent_dir ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 64 filtered out; finished in 20.23s
x
the log listed here seems not writing the same file
If you are sure that icloud doesn't support large files, you can set
write_total_max_size
for icloud service: https://opendal.apache.org/docs/rust/opendal/struct.Capability.html#structfield.write_total_max_size
b
I mean, it's more like random. The same test in the case above fist fail and twice sucess .A single test suceess, but combined it will fail randomly. I can only be sure that I can upload data <=4MB.
x
So tricky..
Let's set write_total_max_size to 4MiB to pass the write test, we can dig this later.
5 Views