github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/test/implicit_teams_test.go (about) 1 // Copyright 2017 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package test 6 7 import ( 8 "testing" 9 ) 10 11 func TestImplicitTeamsTwoWritersPrivate(t *testing.T) { 12 test(t, 13 users("alice", "bob"), 14 implicitTeam("alice,bob", ""), 15 inPrivateTlf("alice,bob"), 16 as(alice, 17 mkfile("a", "hello"), 18 ), 19 as(bob, 20 read("a", "hello"), 21 mkfile("b", "world"), 22 ), 23 as(alice, 24 read("b", "world"), 25 ), 26 ) 27 } 28 29 func TestImplicitTeamsTwoWritersPublic(t *testing.T) { 30 test(t, 31 users("alice", "bob", "charlie"), 32 implicitTeam("alice,bob", "public"), 33 inPublicTlf("alice,bob"), 34 as(alice, 35 mkfile("a", "hello"), 36 ), 37 as(bob, 38 read("a", "hello"), 39 mkfile("b", "world"), 40 ), 41 as(alice, 42 read("b", "world"), 43 ), 44 as(charlie, 45 read("b", "world"), 46 expectError(mkfile("foo.txt", "hello world"), 47 "charlie does not have write access to directory /keybase/public/alice,bob"), 48 ), 49 ) 50 } 51 52 func TestImplicitTeamsTwoWritersPrivateNonCanonical(t *testing.T) { 53 test(t, 54 users("alice", "bob"), 55 implicitTeam("alice,bob", ""), 56 inPrivateTlfNonCanonical("bob,alice", "alice,bob"), 57 as(alice, 58 mkfile("a", "hello"), 59 ), 60 as(bob, 61 read("a", "hello"), 62 mkfile("b", "world"), 63 ), 64 as(alice, 65 read("b", "world"), 66 ), 67 ) 68 } 69 70 func TestImplicitTeamsTwoWritersOneReaderPrivate(t *testing.T) { 71 test(t, 72 users("alice", "bob", "charlie"), 73 implicitTeam("alice,bob", "charlie"), 74 inPrivateTlf("alice,bob#charlie"), 75 as(alice, 76 mkfile("a", "hello"), 77 ), 78 as(bob, 79 read("a", "hello"), 80 mkfile("b", "world"), 81 ), 82 as(alice, 83 read("b", "world"), 84 ), 85 as(charlie, 86 read("b", "world"), 87 expectError(mkfile("foo.txt", "hello world"), 88 "charlie does not have write access to directory /keybase/private/alice,bob#charlie"), 89 ), 90 ) 91 } 92 93 func TestImplicitTeamsTwoWritersJournal(t *testing.T) { 94 test(t, journal(), 95 users("alice", "bob"), 96 implicitTeam("alice,bob", ""), 97 inPrivateTlf("alice,bob"), 98 as(alice, 99 // The tests don't support enabling journaling on a 100 // non-existent TLF, so force the TLF creation first. 101 mkfile("foo", "bar"), 102 rm("foo"), 103 ), 104 as(alice, 105 enableJournal(), 106 mkfile("a", "hello"), 107 ), 108 as(alice, 109 // Wait for the flush, after doing a SyncAll(). 110 flushJournal(), 111 ), 112 as(bob, 113 enableJournal(), 114 read("a", "hello"), 115 mkfile("b", "world"), 116 ), 117 as(bob, 118 // Wait for the flush, after doing a SyncAll(). 119 flushJournal(), 120 ), 121 as(alice, 122 read("b", "world"), 123 ), 124 ) 125 }