github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/engine/saltpack_user_keyfinder_test.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 // Tests for the DeviceKeyfinder engine. 5 6 package engine 7 8 import ( 9 "testing" 10 11 "github.com/keybase/client/go/libkb" 12 ) 13 14 // Note: a lot of the functionality of SaltpackUserKeyfinder is tested through the SaltpackRecipientKeyfinderEngine (in go/saltpackkeys), 15 // which is used by the `keybase encrypt` command and calls this SaltpackUserKeyfinder to resolve keys for individual existing users. 16 // Tests are not repeated here for efficiency reasons. 17 18 func TestSaltpackUserKeyfinder(t *testing.T) { 19 tc := SetupEngineTest(t, "SaltpackUserKeyfinder") 20 defer tc.Cleanup() 21 22 u1 := CreateAndSignupFakeUser(tc, "naclp") 23 u2 := CreateAndSignupFakeUser(tc, "naclp") 24 u3 := CreateAndSignupFakeUser(tc, "naclp") 25 26 trackUI := &FakeIdentifyUI{ 27 Proofs: make(map[string]string), 28 } 29 30 uis := libkb.UIs{IdentifyUI: trackUI, SecretUI: u3.NewSecretUI()} 31 arg := libkb.SaltpackRecipientKeyfinderArg{ 32 Recipients: []string{u1.Username, u2.Username, u3.Username}, 33 UseEntityKeys: true, 34 } 35 eng := NewSaltpackUserKeyfinder(arg) 36 m := NewMetaContextForTest(tc).WithUIs(uis) 37 if err := RunEngine2(m, eng); err != nil { 38 t.Fatal(err) 39 } 40 41 up := eng.GetPublicKIDs() 42 if len(up) != 3 { 43 t.Errorf("number of users found: %d, expected 3", len(up)) 44 } 45 }