@@ -2223,50 +2223,26 @@ func TestSharedDriveGroupDynamicMembership(t *testing.T) {
22232223 members .Value (1 ).Object ().Value ("only_in_groups" ).IsEqual (true )
22242224 members .Value (1 ).Object ().Value ("groups" ).Array ().Value (0 ).IsEqual (0 )
22252225
2226- // Step 6: Set up Alice's instance to know about the owner's URL for the sharing (for auto-accept)
2227- FakeOwnerInstanceForSharing (t , aliceInstance , tsOwner .URL , sharingID )
2228-
2229- // Step 7: Wait for Alice's sharing to be auto-accepted
2226+ // Step 6: Wait for the sharing to exist on Alice's instance, then set up the owner's URL
22302227 eAlice := httpexpect .Default (t , tsAlice .URL )
2231- isMemberReady := func ( e * httpexpect. Expect , token , email string ) bool {
2232- resp := e .GET ("/sharings/" + sharingID ).
2233- WithHeader ("Authorization" , "Bearer " + token ).
2228+ require . Eventually ( t , func ( ) bool {
2229+ resp := eAlice .GET ("/sharings/" + sharingID ).
2230+ WithHeader ("Authorization" , "Bearer " + aliceAppToken ).
22342231 Expect ()
2235- if resp .Raw ().StatusCode != http .StatusOK {
2236- return false
2237- }
2232+ return resp .Raw ().StatusCode == 200
2233+ }, 10 * time .Second , 500 * time .Millisecond , "Alice's sharing should exist" )
22382234
2239- raw := resp .JSON (httpexpect.ContentOpts {MediaType : "application/vnd.api+json" }).Object ().Raw ()
2240- data , ok := raw ["data" ].(map [string ]interface {})
2241- if ! ok {
2242- return false
2243- }
2244- attrs , ok := data ["attributes" ].(map [string ]interface {})
2245- if ! ok {
2246- return false
2247- }
2248- members , ok := attrs ["members" ].([]interface {})
2249- if ! ok {
2250- return false
2251- }
2252-
2253- for _ , member := range members {
2254- memberObj , ok := member .(map [string ]interface {})
2255- if ! ok {
2256- continue
2257- }
2258- memberEmail , _ := memberObj ["email" ].(string )
2259- memberStatus , _ := memberObj ["status" ].(string )
2260- if memberEmail == email {
2261- return memberStatus == sharing .MemberStatusReady
2262- }
2263- }
2235+ // Now update the owner's URL in Alice's sharing document
2236+ FakeOwnerInstanceForSharing (t , aliceInstance , tsOwner .URL , sharingID )
22642237
2265- return false
2266- }
2238+ // Step 7: Wait for Alice's sharing to be auto-accepted
22672239 require .Eventually (t , func () bool {
2268- return isMemberReady (eAlice , aliceAppToken , "alice@example.com" )
2269- }, 10 * time .Second , 500 * time .Millisecond , "Alice's sharing should be auto-accepted" )
2240+ var s sharing.Sharing
2241+ if err := couchdb .GetDoc (aliceInstance , consts .Sharings , sharingID , & s ); err != nil {
2242+ return false
2243+ }
2244+ return s .Active
2245+ }, 10 * time .Second , 500 * time .Millisecond , "Alice's sharing should be auto-accepted and active" )
22702246
22712247 // Step 8: Verify Alice can access the file
22722248 eAlice .GET ("/sharings/drives/" + sharingID + "/" + fileID ).
@@ -2294,15 +2270,27 @@ func TestSharedDriveGroupDynamicMembership(t *testing.T) {
22942270 require .True (t , s .Members [2 ].OnlyInGroups )
22952271 require .Equal (t , []int {0 }, s .Members [2 ].Groups )
22962272
2297- // Step 13: Set up Bob's instance to know about the owner's URL for the sharing
2273+ // Step 13: Wait for the sharing to exist on Bob's instance, then set up the owner's URL
2274+ eBob := httpexpect .Default (t , tsBob .URL )
2275+ require .Eventually (t , func () bool {
2276+ resp := eBob .GET ("/sharings/" + sharingID ).
2277+ WithHeader ("Authorization" , "Bearer " + bobAppToken ).
2278+ Expect ()
2279+ return resp .Raw ().StatusCode == 200
2280+ }, 10 * time .Second , 500 * time .Millisecond , "Bob's sharing should exist" )
2281+
2282+ // Now update the owner's URL in Bob's sharing document
22982283 FakeOwnerInstanceForSharing (t , bobInstance , tsOwner .URL , sharingID )
22992284
23002285 // Step 14: Verify Bob can access the shared drive after auto-accept
23012286 // Wait for the sharing to be auto-accepted on Bob's side
2302- eBob := httpexpect .Default (t , tsBob .URL )
23032287 require .Eventually (t , func () bool {
2304- return isMemberReady (eBob , bobAppToken , "bob@example.com" )
2305- }, 10 * time .Second , 500 * time .Millisecond , "Bob's sharing should be auto-accepted" )
2288+ var s sharing.Sharing
2289+ if err := couchdb .GetDoc (bobInstance , consts .Sharings , sharingID , & s ); err != nil {
2290+ return false
2291+ }
2292+ return s .Active
2293+ }, 10 * time .Second , 500 * time .Millisecond , "Bob's sharing should be auto-accepted and active" )
23062294
23072295 // Step 15: Verify Bob can access the file in the shared drive
23082296 eBob .GET ("/sharings/drives/" + sharingID + "/" + fileID ).
0 commit comments