当前位置: 首页>>代码示例>>Golang>>正文


Golang TestContext.GenerateGPGKeyring方法代码示例

本文整理汇总了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
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:52,代码来源:fakeusers_test.go

示例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
}
开发者ID:qbit,项目名称:client,代码行数:48,代码来源:fakeusers_test.go

示例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
}
开发者ID:moul,项目名称:client,代码行数:20,代码来源:common_test.go

示例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
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:40,代码来源:fakeusers_test.go


注:本文中的github.com/keybase/client/go/libkb.TestContext.GenerateGPGKeyring方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。