本文整理汇总了Golang中github.com/keybase/client/go/libkb.TestContext类的典型用法代码示例。如果您正苦于以下问题:Golang TestContext类的具体用法?Golang TestContext怎么用?Golang TestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestContext类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: cloneContext
func cloneContext(prev *libkb.TestContext) *libkb.TestContext {
ret := prev.Clone()
ret.SetRuntimeDir(filepath.Join(ret.Tp.Home, "run"))
if err := ret.G.ConfigureSocketInfo(); err != nil {
ret.T.Fatal(err)
}
return &ret
}
开发者ID:mark-adams,项目名称:client,代码行数:8,代码来源:common_test.go
示例2: createFakeUserWithPGPMult
// multiple pgp keys
func createFakeUserWithPGPMult(t *testing.T, tc libkb.TestContext) *FakeUser {
fu := NewFakeUserOrBust(t, "login")
if err := tc.GenerateGPGKeyring(fu.Email, "[email protected]"); err != nil {
t.Fatal(err)
}
secui := &libkb.TestSecretUI{Passphrase: fu.Passphrase}
s := NewSignupEngine(nil, tc.G)
ctx := &Context{
GPGUI: &gpgtestui{},
SecretUI: secui,
LogUI: tc.G.UI.GetLogUI(),
LoginUI: &libkb.TestLoginUI{Username: fu.Username},
}
f := func(a libkb.LoginContext) error {
if err := s.genPassphraseStream(a, fu.Passphrase); err != nil {
return err
}
if err := s.join(a, fu.Username, fu.Email, testInviteCode, true); err != nil {
t.Fatal(err)
}
fu.User = s.GetMe()
// fake the lks:
if err := s.fakeLKS(); err != nil {
return err
}
if err := s.addGPG(a, ctx, false); err != nil {
return err
}
// hack the gpg ui to select a different key:
ctx.GPGUI = &gpgtestui{index: 1}
if err := s.addGPG(a, ctx, true); err != nil {
return err
}
return nil
}
if err := s.G().LoginState().ExternalFunc(f, "createFakeUserWithPGPPubMult"); err != nil {
t.Fatal(err)
}
// now it should have two pgp keys...
return fu
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:52,代码来源:fakeusers_test.go
示例3: createFakeUserWithPGPMultSubset
// multiple pgp keys, but only the one with fu.Email associated w/
// keybase account
func createFakeUserWithPGPMultSubset(t *testing.T, tc libkb.TestContext, alternateEmail string) *FakeUser {
fu := NewFakeUserOrBust(t, "login")
if err := tc.GenerateGPGKeyring(fu.Email, alternateEmail); err != nil {
t.Fatal(err)
}
secui := &libkb.TestSecretUI{Passphrase: fu.Passphrase}
s := NewSignupEngine(nil, tc.G)
ctx := &Context{
GPGUI: newGPGSelectEmailUI(fu.Email),
SecretUI: secui,
LogUI: tc.G.UI.GetLogUI(),
LoginUI: &libkb.TestLoginUI{Username: fu.Username},
}
f := func(a libkb.LoginContext) error {
if err := s.genPassphraseStream(a, fu.Passphrase); err != nil {
return err
}
if err := s.join(a, fu.Username, fu.Email, libkb.TestInvitationCode, true); err != nil {
t.Fatal(err)
}
fu.User = s.GetMe()
// fake the lks:
if err := s.fakeLKS(); err != nil {
return err
}
// this will add the GPG key for fu.Email to their account
if err := s.addGPG(a, ctx, false); err != nil {
return err
}
return nil
}
if err := s.G().LoginState().ExternalFunc(f, "createFakeUserWithPGPMultSubset"); err != nil {
t.Fatal(err)
}
// now it should have two pgp keys...
return fu
}
开发者ID:qbit,项目名称:client,代码行数:48,代码来源:fakeusers_test.go
示例4: armorKey
func armorKey(t *testing.T, tc libkb.TestContext, email string) (libkb.PGPFingerprint, keybase1.KID, string) {
bundle, err := tc.MakePGPKey(email)
if err != nil {
t.Fatal(err)
}
var buf bytes.Buffer
writer, err := armor.Encode(&buf, "PGP PRIVATE KEY BLOCK", nil)
if err != nil {
t.Fatal(err)
}
if err := bundle.Entity.SerializePrivate(writer, nil); err != nil {
t.Fatal(err)
}
if err := writer.Close(); err != nil {
t.Fatal(err)
}
fp := *bundle.GetFingerprintP()
kid := bundle.GetKID()
return fp, kid, string(buf.Bytes())
}
开发者ID:mark-adams,项目名称:client,代码行数:20,代码来源:pgp_import_key_test.go
示例5: CreateAndSignupFakeUserGPG
func CreateAndSignupFakeUserGPG(tc libkb.TestContext, prefix string) *FakeUser {
fu := NewFakeUserOrBust(tc.T, prefix)
if err := tc.GenerateGPGKeyring(fu.Email); err != nil {
tc.T.Fatal(err)
}
arg := MakeTestSignupEngineRunArg(fu)
arg.SkipGPG = false
ctx := &Context{
LogUI: tc.G.UI.GetLogUI(),
GPGUI: &gpgtestui{},
SecretUI: fu.NewSecretUI(),
LoginUI: libkb.TestLoginUI{Username: fu.Username},
}
s := NewSignupEngine(&arg, tc.G)
err := RunEngine(s, ctx)
if err != nil {
tc.T.Fatal(err)
}
return fu
}
开发者ID:moul,项目名称:client,代码行数:20,代码来源:common_test.go
示例6: createFakeUserWithPGPPubOnly
// private gpg key not pushed to server
func createFakeUserWithPGPPubOnly(t *testing.T, tc libkb.TestContext) *FakeUser {
fu := NewFakeUserOrBust(t, "login")
if err := tc.GenerateGPGKeyring(fu.Email); err != nil {
t.Fatal(err)
}
secui := &libkb.TestSecretUI{Passphrase: fu.Passphrase}
s := NewSignupEngine(nil, tc.G)
ctx := &Context{
GPGUI: &gpgPubOnlyTestUI{},
SecretUI: secui,
LogUI: tc.G.UI.GetLogUI(),
LoginUI: &libkb.TestLoginUI{Username: fu.Username},
}
f := func(a libkb.LoginContext) error {
if err := s.genPassphraseStream(a, fu.Passphrase); err != nil {
return err
}
if err := s.join(a, fu.Username, fu.Email, testInviteCode, true); err != nil {
return err
}
if err := s.fakeLKS(); err != nil {
return err
}
if err := s.addGPG(a, ctx, false); err != nil {
return err
}
return nil
}
if err := s.G().LoginState().ExternalFunc(f, "createFakeUserWithPGPPubOnly"); err != nil {
t.Fatal(err)
}
return fu
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:40,代码来源:fakeusers_test.go
注:本文中的github.com/keybase/client/go/libkb.TestContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论