github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/teams/identify_test.go (about) 1 package teams 2 3 import ( 4 "testing" 5 6 "github.com/keybase/client/go/libkb" 7 "github.com/keybase/client/go/protocol/keybase1" 8 "golang.org/x/net/context" 9 ) 10 11 func TestIdentifyLite(t *testing.T) { 12 tc, _, name := memberSetup(t) 13 defer tc.Cleanup() 14 15 team, err := GetForTestByStringName(context.Background(), tc.G, name) 16 if err != nil { 17 t.Fatal(err) 18 } 19 20 // test identify by assertion only 21 var assertions = []string{"team:" + name, "tid:" + team.ID.String()} 22 for _, assertion := range assertions { 23 au, err := libkb.ParseAssertionURL(tc.G.MakeAssertionContext(libkb.NewMetaContext(context.Background(), tc.G)), assertion, true) 24 if err != nil { 25 t.Fatal(err) 26 } 27 res, err := IdentifyLite(context.Background(), tc.G, keybase1.IdentifyLiteArg{Assertion: assertion}, au) 28 if err != nil { 29 t.Fatal(err) 30 } 31 if res.Ul.Name != name { 32 t.Errorf("assertion: %s, id lite name: %s, expected %s", assertion, res.Ul.Name, name) 33 } 34 35 if res.Ul.Id.String() != team.ID.String() { 36 t.Errorf("assertion: %s, id lite id: %s, expected %s", assertion, res.Ul.Id, team.ID) 37 } 38 } 39 40 // test identify by id and assertions 41 for _, assertion := range assertions { 42 au, err := libkb.ParseAssertionURL(tc.G.MakeAssertionContext(libkb.NewMetaContext(context.Background(), tc.G)), assertion, true) 43 if err != nil { 44 t.Fatal(err) 45 } 46 res, err := IdentifyLite(context.Background(), tc.G, keybase1.IdentifyLiteArg{Id: team.ID.AsUserOrTeam(), Assertion: assertion}, au) 47 if err != nil { 48 t.Fatal(err) 49 } 50 if res.Ul.Name != name { 51 t.Errorf("assertion: %s, id lite name: %s, expected %s", assertion, res.Ul.Name, name) 52 } 53 54 if res.Ul.Id.String() != team.ID.String() { 55 t.Errorf("assertion: %s, id lite id: %s, expected %s", assertion, res.Ul.Id, team.ID) 56 } 57 } 58 59 // test identify by id only 60 var empty libkb.AssertionKeybase 61 res, err := IdentifyLite(context.Background(), tc.G, keybase1.IdentifyLiteArg{Id: team.ID.AsUserOrTeam()}, empty) 62 if err != nil { 63 t.Fatal(err) 64 } 65 if res.Ul.Name != name { 66 t.Errorf("id lite name: %s, expected %s", res.Ul.Name, name) 67 } 68 69 if res.Ul.Id.String() != team.ID.String() { 70 t.Errorf("id lite id: %s, expected %s", res.Ul.Id, team.ID) 71 } 72 }