github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/systests/subteams_test.go (about)

     1  package systests
     2  
     3  import (
     4  	"testing"
     5  
     6  	"fmt"
     7  
     8  	"github.com/keybase/client/go/teams"
     9  	"github.com/stretchr/testify/require"
    10  	"golang.org/x/net/context"
    11  
    12  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
    13  )
    14  
    15  func TestSubteamAdminships(t *testing.T) {
    16  	// This is not a real test - we used it to debug and profile
    17  	// multiple level subteam loading where implicit adminships were
    18  	// involved.
    19  	t.Skip()
    20  
    21  	tt := newTeamTester(t)
    22  	defer tt.cleanup()
    23  
    24  	al := tt.addUser("al")
    25  	bob := tt.addUser("bob")
    26  	eve := tt.addUser("eve")
    27  
    28  	_, teamName := al.createTeam2()
    29  
    30  	const subteamBasename = "bb1"
    31  	subteamID1, err := teams.CreateSubteam(context.TODO(), al.tc.G, subteamBasename,
    32  		teamName, keybase1.TeamRole_NONE /* addSelfAs */)
    33  	require.NoError(t, err)
    34  
    35  	subTeamName1, _ := teamName.Append(subteamBasename)
    36  
    37  	t.Logf("Subteam created %s / %s", subteamID1.String(), subTeamName1.String())
    38  
    39  	const subSubTeamBasename = "cc2"
    40  	subteamID2, err := teams.CreateSubteam(context.TODO(), al.tc.G, subSubTeamBasename,
    41  		subTeamName1, keybase1.TeamRole_NONE /* addSelfAs */)
    42  	require.NoError(t, err)
    43  
    44  	subTeamName2, _ := subTeamName1.Append(subSubTeamBasename)
    45  
    46  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID1)
    47  	require.NoError(t, err)
    48  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID1)
    49  	require.NoError(t, err)
    50  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID1)
    51  	require.NoError(t, err)
    52  
    53  	t.Logf("Sub-Subteam created %s / %s", subteamID2.String(), subTeamName2.String())
    54  
    55  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID1)
    56  	require.NoError(t, err)
    57  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID1)
    58  	require.NoError(t, err)
    59  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID1)
    60  	require.NoError(t, err)
    61  
    62  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID2)
    63  	require.NoError(t, err)
    64  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID2)
    65  	require.NoError(t, err)
    66  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID2)
    67  	require.NoError(t, err)
    68  
    69  	al.addTeamMember(subTeamName2.String(), bob.username, keybase1.TeamRole_WRITER)
    70  	al.addTeamMember(subTeamName2.String(), eve.username, keybase1.TeamRole_READER)
    71  
    72  	bob.leave(subTeamName2.String())
    73  
    74  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID2)
    75  	require.NoError(t, err)
    76  	err = teams.RotateKeyVisible(context.TODO(), al.tc.G, *subteamID2)
    77  	require.NoError(t, err)
    78  
    79  	t.Logf("Eve loads team ...")
    80  	fmt.Printf(":: Eve loads team %s ...\n", subteamID2.String())
    81  
    82  	eve.loadTeam(subTeamName2.String(), false)
    83  }