本文整理汇总了Golang中github.com/keybase/client/go/libkb.TestContext.GenerateGPGKeyring方法的典型用法代码示例。如果您正苦于以下问题:Golang TestContext.GenerateGPGKeyring方法的具体用法?Golang TestContext.GenerateGPGKeyring怎么用?Golang TestContext.GenerateGPGKeyring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/libkb.TestContext
的用法示例。
在下文中一共展示了TestContext.GenerateGPGKeyring方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}