本文整理汇总了Golang中github.com/keybase/client/go/protocol.UID函数的典型用法代码示例。如果您正苦于以下问题:Golang UID函数的具体用法?Golang UID怎么用?Golang UID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: assertionToUIDLocked
func (k *KeybaseDaemonLocal) assertionToUIDLocked(ctx context.Context,
assertion string) (uid keybase1.UID, err error) {
expr, err := libkb.AssertionParseAndOnly(assertion)
if err != nil {
return keybase1.UID(""), err
}
urls := expr.CollectUrls(nil)
if len(urls) == 0 {
return keybase1.UID(""), errors.New("No assertion URLs")
}
for _, url := range urls {
var currUID keybase1.UID
if url.IsUID() {
currUID = url.ToUID()
} else {
key, val := url.ToKeyValuePair()
a := fmt.Sprintf("%[email protected]%s", val, key)
if url.IsKeybase() {
a = val
}
var ok bool
currUID, ok = k.asserts[a]
if !ok {
return keybase1.UID(""), NoSuchUserError{a}
}
}
if uid != keybase1.UID("") && currUID != uid {
return keybase1.UID(""),
errors.New("AND assertions resolve to different UIDs")
}
uid = currUID
}
return uid, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:35,代码来源:keybase_daemon_local.go
示例2: testIdentifyResolve2
func testIdentifyResolve2(t *testing.T, g *libkb.GlobalContext) {
cli, err := client.GetIdentifyClient(g)
if err != nil {
t.Fatalf("failed to get new identifyclient: %v", err)
}
if _, err := cli.Resolve(context.TODO(), "uid:eb72f49f2dde6429e5d78003dae0c919"); err != nil {
t.Fatalf("Resovle failed: %v\n", err)
}
// We don't want to hit the cache, since the previous lookup never hit the
// server. For Resolve2, we have to, since we need a username. So test that
// here.
if res, err := cli.Resolve2(context.TODO(), "uid:eb72f49f2dde6429e5d78003dae0c919"); err != nil {
t.Fatalf("Resovle failed: %v\n", err)
} else if res.Username != "t_tracy" {
t.Fatalf("Wrong username: %s != 't_tracy", res.Username)
}
if res, err := cli.Resolve2(context.TODO(), "[email protected]"); err != nil {
t.Fatalf("Resolve2 failed: %v\n", err)
} else if res.Username != "t_tracy" {
t.Fatalf("Wrong name: %s != 't_tracy", res.Username)
} else if !res.Uid.Equal(keybase1.UID("eb72f49f2dde6429e5d78003dae0c919")) {
t.Fatalf("Wrong uid for tracy: %s\n", res.Uid)
}
if _, err := cli.Resolve2(context.TODO(), "[email protected]"); err == nil {
t.Fatalf("expected an error on a bad resolve, but got none")
} else if _, ok := err.(libkb.ResolutionError); !ok {
t.Fatalf("Wrong error: wanted type %T but got (%v, %T)", libkb.ResolutionError{}, err, err)
}
}
开发者ID:mattcurrycom,项目名称:client,代码行数:34,代码来源:rpc_test.go
示例3: testLoadAllPublicKeysUnverified
func testLoadAllPublicKeysUnverified(t *testing.T, g *libkb.GlobalContext) {
cli, err := client.GetUserClient(g)
if err != nil {
t.Fatalf("failed to get user client: %s", err)
}
// t_rosetta
arg := keybase1.LoadAllPublicKeysUnverifiedArg{Uid: keybase1.UID("b8939251cb3d367e68587acb33a64d19")}
res, err := cli.LoadAllPublicKeysUnverified(context.TODO(), arg)
if err != nil {
t.Fatalf("failed to make load keys call: %s", err)
}
if len(res) != 3 {
t.Fatalf("wrong amount of keys loaded: %d != %d", len(res), 3)
}
keys := map[keybase1.KID]bool{
keybase1.KID("0101fe1183765f256289427d6943cd8bab3b5fe095bcdd27f031ed298da523efd3120a"): true,
keybase1.KID("0101b5839c4ccaa9d03b3016b9aa73a7e3eafb067f9c86c07a6f2f79cb8558b1c97f0a"): true,
keybase1.KID("0101188ee7e63ccbd05af498772ab2975ee29df773240d17dde09aecf6c132a5a9a60a"): true,
}
for _, key := range res {
if _, ok := keys[key.KID]; !ok {
t.Fatalf("unknown key in response: %s", key.KID)
}
}
}
开发者ID:qbit,项目名称:client,代码行数:30,代码来源:rpc_test.go
示例4: resolve
func (ra resolvableAssertion) resolve(ctx context.Context) (
nameUIDPair, keybase1.SocialAssertion, error) {
if ra.assertion == PublicUIDName {
return nameUIDPair{}, keybase1.SocialAssertion{}, fmt.Errorf("Invalid name %s", ra.assertion)
}
name, uid, err := ra.resolver.Resolve(ctx, ra.assertion)
if err == nil && ra.mustBeUser != keybase1.UID("") && ra.mustBeUser != uid {
// Force an unresolved assertion sinced the forced user doesn't match
err = NoSuchUserError{ra.assertion}
}
switch err := err.(type) {
default:
return nameUIDPair{}, keybase1.SocialAssertion{}, err
case nil:
return nameUIDPair{
name: name,
uid: uid,
}, keybase1.SocialAssertion{}, nil
case NoSuchUserError:
if !ra.sharingBeforeSignupEnabled {
return nameUIDPair{}, keybase1.SocialAssertion{}, err
}
socialAssertion, ok := libkb.NormalizeSocialAssertion(ra.assertion)
if !ok {
return nameUIDPair{}, keybase1.SocialAssertion{}, err
}
return nameUIDPair{}, socialAssertion, nil
}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:29,代码来源:tlf_handle.go
示例5: genUID
func genUID(t *testing.T) keybase1.UID {
uid := make([]byte, 8)
if _, err := rand.Read(uid); err != nil {
t.Fatalf("rand failed: %v\n", err)
}
return keybase1.UID(hex.EncodeToString(uid))
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:7,代码来源:rpc_test.go
示例6: Call
func (c *fakeKeybaseClient) Call(ctx context.Context, s string, args interface{},
res interface{}) error {
switch s {
case "keybase.1.session.currentSession":
*res.(*keybase1.Session) = keybase1.Session{
Uid: c.session.UID,
Username: "fake username",
Token: c.session.Token,
DeviceSubkeyKid: c.session.CryptPublicKey.kid,
DeviceSibkeyKid: c.session.VerifyingKey.kid,
}
c.currentSessionCalled = true
return nil
case "keybase.1.identify.identify2":
arg := args.([]interface{})[0].(keybase1.Identify2Arg)
uidStr := strings.TrimPrefix(arg.UserAssertion, "uid:")
if len(uidStr) == len(arg.UserAssertion) {
return fmt.Errorf("Non-uid assertion %s", arg.UserAssertion)
}
uid := keybase1.UID(uidStr)
userInfo, ok := c.users[uid]
if !ok {
return fmt.Errorf("Could not find user info for UID %s", uid)
}
*res.(*keybase1.Identify2Res) = keybase1.Identify2Res{
Upk: keybase1.UserPlusKeys{
Uid: uid,
Username: string(userInfo.Name),
},
}
c.identifyCalled = true
return nil
case "keybase.1.user.loadUserPlusKeys":
arg := args.([]interface{})[0].(keybase1.LoadUserPlusKeysArg)
userInfo, ok := c.users[arg.Uid]
if !ok {
return fmt.Errorf("Could not find user info for UID %s", arg.Uid)
}
*res.(*keybase1.UserPlusKeys) = keybase1.UserPlusKeys{
Uid: arg.Uid,
Username: string(userInfo.Name),
}
c.loadUserPlusKeysCalled = true
return nil
default:
return fmt.Errorf("Unknown call: %s %v %v", s, args, res)
}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:58,代码来源:keybase_daemon_rpc_test.go
示例7: Resolve
// Resolve implements the KeybaseDaemon interface for KeybaseDaemonRPC.
func (k *KeybaseDaemonRPC) Resolve(ctx context.Context, assertion string) (
libkb.NormalizedUsername, keybase1.UID, error) {
user, err := k.identifyClient.Resolve2(ctx, assertion)
if err != nil {
return libkb.NormalizedUsername(""), keybase1.UID(""),
convertIdentifyError(assertion, err)
}
return libkb.NewNormalizedUsername(user.Username), user.Uid, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:10,代码来源:keybase_daemon_rpc.go
示例8: GetCurrentUID
// GetCurrentUID implements the KBPKI interface for KBPKIClient.
func (k *KBPKIClient) GetCurrentUID(ctx context.Context) (keybase1.UID, error) {
s, err := k.session(ctx)
if err != nil {
// TODO: something more intelligent; maybe just shut down
// unless we want anonymous browsing of public data
return keybase1.UID(""), err
}
return s.UID, nil
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:10,代码来源:kbpki_client.go
示例9: Resolve
// Resolve implements KeybaseDaemon for KeybaseDaemonLocal.
func (k KeybaseDaemonLocal) Resolve(ctx context.Context, assertion string) (
keybase1.UID, error) {
uid, ok := k.asserts[assertion]
if !ok {
return keybase1.UID(""), NoSuchUserError{assertion}
}
return uid, nil
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:10,代码来源:keybase_daemon_local.go
示例10: addNewAssertionForTest
// addNewAssertionForTest makes newAssertion, which should be a single
// assertion that doesn't already resolve to anything, resolve to the
// same UID as oldAssertion, which should be an arbitrary assertion
// that does already resolve to something. It returns the UID of the
// user associated with the given assertions.
func (k *KeybaseDaemonLocal) addNewAssertionForTest(
oldAssertion, newAssertion string) (keybase1.UID, error) {
k.lock.Lock()
defer k.lock.Unlock()
uid, err := k.assertionToUIDLocked(context.Background(), oldAssertion)
if err != nil {
return keybase1.UID(""), err
}
lu, err := k.localUsers.getLocalUser(uid)
if err != nil {
return keybase1.UID(""), err
}
lu.Asserts = append(lu.Asserts, newAssertion)
k.asserts[newAssertion] = uid
k.localUsers[uid] = lu
return uid, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:23,代码来源:keybase_daemon_local.go
示例11: GetCurrentUserInfo
// GetCurrentUserInfo implements the KBPKI interface for KBPKIClient.
func (k *KBPKIClient) GetCurrentUserInfo(ctx context.Context) (
libkb.NormalizedUsername, keybase1.UID, error) {
s, err := k.session(ctx)
if err != nil {
// TODO: something more intelligent; maybe just shut down
// unless we want anonymous browsing of public data
return libkb.NormalizedUsername(""), keybase1.UID(""), err
}
return s.Name, s.UID, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:11,代码来源:kbpki_client.go
示例12: TestKBPKIClientIdentify
func TestKBPKIClientIdentify(t *testing.T) {
c, _, _ := makeTestKBPKIClient(t)
u, err := c.Identify(context.Background(), "test_name1", "")
if err != nil {
t.Fatal(err)
}
if u.UID == keybase1.UID("") {
t.Fatal("empty user")
}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:11,代码来源:kbpki_client_test.go
示例13: Resolve
// Resolve implements KeybaseDaemon for KeybaseDaemonLocal.
func (k *KeybaseDaemonLocal) Resolve(ctx context.Context, assertion string) (
libkb.NormalizedUsername, keybase1.UID, error) {
k.lock.Lock()
defer k.lock.Unlock()
uid, err := k.assertionToUIDLocked(ctx, assertion)
if err != nil {
return libkb.NormalizedUsername(""), keybase1.UID(""), err
}
return k.localUsers[uid].Name, uid, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:13,代码来源:keybase_daemon_local.go
示例14: CurrentSession
// CurrentSession implements the KeybaseDaemon interface for KeybaseDaemonRPC.
func (k *KeybaseDaemonRPC) CurrentSession(ctx context.Context, sessionID int) (
SessionInfo, error) {
cachedCurrentSession := k.getCachedCurrentSession()
if cachedCurrentSession != (SessionInfo{}) {
return cachedCurrentSession, nil
}
res, err := k.sessionClient.CurrentSession(ctx, sessionID)
if err != nil {
if ncs := (NoCurrentSessionError{}); err.Error() ==
NoCurrentSessionExpectedError {
// Use an error with a proper OS error code attached to
// it. TODO: move ErrNoSession from client/go/service to
// client/go/libkb, so we can use types for the check
// above.
err = ncs
}
return SessionInfo{}, err
}
// Import the KIDs to validate them.
deviceSubkey, err := libkb.ImportKeypairFromKID(res.DeviceSubkeyKid)
if err != nil {
return SessionInfo{}, err
}
deviceSibkey, err := libkb.ImportKeypairFromKID(res.DeviceSibkeyKid)
if err != nil {
return SessionInfo{}, err
}
cryptPublicKey := MakeCryptPublicKey(deviceSubkey.GetKID())
verifyingKey := MakeVerifyingKey(deviceSibkey.GetKID())
s := SessionInfo{
Name: libkb.NewNormalizedUsername(res.Username),
UID: keybase1.UID(res.Uid),
Token: res.Token,
CryptPublicKey: cryptPublicKey,
VerifyingKey: verifyingKey,
}
k.log.CDebugf(
ctx, "new session with username %s, uid %s, crypt public key %s, and verifying key %s",
s.Name, s.UID, s.CryptPublicKey, s.VerifyingKey)
k.setCachedCurrentSession(s)
return s, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:47,代码来源:keybase_daemon_rpc.go
示例15: runTable
func (e *ListTrackingEngine) runTable(trackList TrackList) error {
for _, link := range trackList {
uid, err := link.GetTrackedUID()
if err != nil {
return err
}
entry := keybase1.UserSummary{
Username: link.ToDisplayString(),
SigIDDisplay: link.GetSigID().ToDisplayString(true),
TrackTime: keybase1.ToTime(link.GetCTime()),
Uid: keybase1.UID(uid),
}
entry.Proofs.PublicKeys = e.linkPGPKeys(link)
entry.Proofs.Social = e.linkSocialProofs(link)
entry.Proofs.Web = e.linkWebProofs(link)
e.tableResult = append(e.tableResult, entry)
}
return nil
}
开发者ID:paul-pearce,项目名称:client-beta,代码行数:19,代码来源:list_tracking.go
示例16: CurrentSession
// CurrentSession implements the KeybaseDaemon interface for KeybaseDaemonRPC.
func (k *KeybaseDaemonRPC) CurrentSession(ctx context.Context, sessionID int) (
SessionInfo, error) {
cachedCurrentSession := k.getCachedCurrentSession()
if cachedCurrentSession != (SessionInfo{}) {
return cachedCurrentSession, nil
}
res, err := k.sessionClient.CurrentSession(ctx, sessionID)
if err != nil {
if ncs := (NoCurrentSessionError{}); err.Error() == ncs.Error() {
// Use an error with a proper OS error code attached to it.
err = ncs
}
return SessionInfo{}, err
}
// Import the KIDs to validate them.
deviceSubkey, err := libkb.ImportKeypairFromKID(res.DeviceSubkeyKid)
if err != nil {
return SessionInfo{}, err
}
deviceSibkey, err := libkb.ImportKeypairFromKID(res.DeviceSibkeyKid)
if err != nil {
return SessionInfo{}, err
}
cryptPublicKey := MakeCryptPublicKey(deviceSubkey.GetKID())
verifyingKey := MakeVerifyingKey(deviceSibkey.GetKID())
s := SessionInfo{
UID: keybase1.UID(res.Uid),
Token: res.Token,
CryptPublicKey: cryptPublicKey,
VerifyingKey: verifyingKey,
}
k.log.CDebugf(
ctx, "new session with uid %s, crypt public key %s, and verifying key %s",
s.UID, s.CryptPublicKey, s.VerifyingKey)
k.setCachedCurrentSession(s)
return s, nil
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:42,代码来源:keybase_daemon_rpc.go
示例17: TestKeybaseDaemonSessionCache
// Test that the session cache works and is invalidated as expected.
func TestKeybaseDaemonSessionCache(t *testing.T) {
k := MakeLocalUserCryptPublicKeyOrBust(
libkb.NormalizedUsername("fake username"))
v := MakeLocalUserVerifyingKeyOrBust(
libkb.NormalizedUsername("fake username"))
session := SessionInfo{
UID: keybase1.UID("fake uid"),
Token: "fake token",
CryptPublicKey: k,
VerifyingKey: v,
}
client := &fakeKeybaseClient{session: session}
c := newKeybaseDaemonRPCWithClient(
nil, client, logger.NewTestLogger(t))
// Should fill cache.
testCurrentSession(t, client, c, session, expectCall)
// Should be cached.
testCurrentSession(t, client, c, session, expectCached)
// Should invalidate cache.
err := c.LoggedOut(context.Background())
if err != nil {
t.Fatal(err)
}
// Should fill cache again.
testCurrentSession(t, client, c, session, expectCall)
// Should be cached again.
testCurrentSession(t, client, c, session, expectCached)
// Should invalidate cache.
c.OnDisconnected(UsingExistingConnection)
// Should fill cache again.
testCurrentSession(t, client, c, session, expectCall)
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:41,代码来源:keybase_daemon_rpc_test.go
示例18: GetUID
func (t Tracker) GetUID() keybase1.UID { return keybase1.UID(t.Tracker) }
开发者ID:mark-adams,项目名称:client,代码行数:1,代码来源:sync_trackers.go
示例19: TestTrackingNotifications
//.........这里部分代码省略.........
Contextified: libkb.NewContextified(tc2.G),
},
}
tc2.G.SetUI(&tui)
signup := client.NewCmdSignupRunner(tc2.G)
signup.SetTest()
<-startCh
if err := signup.Run(); err != nil {
t.Fatal(err)
}
tc2.G.Log.Debug("Login State: %v", tc2.G.LoginState())
nh := newTrackingNotifyHandler()
// Launch the server that will listen for tracking notifications.
launchServer := func(nh *trackingNotifyHandler) error {
cli, xp, err := client.GetRPCClientWithContext(tc5.G)
if err != nil {
return err
}
srv := rpc.NewServer(xp, nil)
if err = srv.Register(keybase1.NotifyTrackingProtocol(nh)); err != nil {
return err
}
ncli := keybase1.NotifyCtlClient{Cli: cli}
if err = ncli.SetNotifications(context.TODO(), keybase1.NotificationChannels{
Tracking: true,
}); err != nil {
return err
}
return nil
}
// Actually launch it in the background
go func() {
err := launchServer(nh)
if err != nil {
nh.errCh <- err
}
}()
// Have our test user track t_alice.
trackCmd := client.NewCmdTrackRunner(tc2.G)
trackCmd.SetUser("t_alice")
trackCmd.SetOptions(keybase1.TrackOptions{BypassConfirm: true})
err := trackCmd.Run()
if err != nil {
t.Fatal(err)
}
// Do a check for new tracking statements that should fire off a
// notification. Currently the track command above does not fetch the new
// chain link from the server, so this call is required. It's possible that
// TrackEngine (or our signature caching code) might change in the future,
// making this call unnecessary.
checkTrackingCmd := client.NewCmdCheckTrackingRunner(tc2.G)
err = checkTrackingCmd.Run()
if err != nil {
t.Fatal(err)
}
// Wait to get a notification back as we expect.
// NOTE: If this test ever starts deadlocking here, it's possible that
// we've changed how we cache signatures that we make on the local client,
// in such a way that the fetch done by CheckTracking above doesn't find
// any "isOwnNewLinkFromServer" links. If so, one way to fix this test
// would be to blow away the local db before calling CheckTracking.
tc.G.Log.Debug("Waiting for two tracking notifications.")
for i := 0; i < 2; i++ {
select {
case err := <-nh.errCh:
t.Fatalf("Error before notify: %v", err)
case arg := <-nh.trackingCh:
tAliceUID := keybase1.UID("295a7eea607af32040647123732bc819")
tc.G.Log.Debug("Got tracking changed notification (%#v)", arg)
if "t_alice" == arg.Username {
if !tAliceUID.Equal(arg.Uid) {
t.Fatalf("Bad UID back: %s != %s", tAliceUID, arg.Uid)
}
} else if userInfo.username == arg.Username {
if !tc.G.Env.GetUID().Equal(arg.Uid) {
t.Fatalf("Bad UID back: %s != %s", tc.G.Env.GetUID(), arg.Uid)
}
} else {
t.Fatalf("Bad username back: %s != %s || %s", arg.Username, "t_alice", userInfo.username)
}
}
}
if err := client.CtlServiceStop(tc2.G); err != nil {
t.Fatal(err)
}
// If the server failed, it's also an error
if err := <-stopCh; err != nil {
t.Fatal(err)
}
}
开发者ID:qbit,项目名称:client,代码行数:101,代码来源:tracking_test.go
示例20: newTestResolverCache
return &resolveTestClock{now: time.Now()}
}
func newTestResolverCache(g *GlobalContext) (*Resolver, *resolveTestClock) {
clock := newResolveTestClock()
res := NewResolver(g)
res.EnableCaching()
res.nowFunc = func() time.Time { return clock.now }
return res, clock
}
func (r *resolveTestClock) tick(d time.Duration) {
r.now = r.now.Add(d)
}
var tracyUID = keybase1.UID("eb72f49f2dde6429e5d78003dae0c919")
func TestResolveSimple(t *testing.T) {
tc := SetupTest(t, "resolveSimple", 1)
r, clock := newTestResolverCache(tc.G)
goodResolve := func(s string) {
res := r.Resolve(s)
if err := res.GetError(); err != nil {
t.Fatal(err)
}
if res.GetUID() != tracyUID {
t.Fatalf("Got wrong UID; wanted %s but got %s", tracyUID, res.GetUID())
}
}
goodResolve("[email protected]")
开发者ID:qbit,项目名称:client,代码行数:31,代码来源:resolve_test.go
注:本文中的github.com/keybase/client/go/protocol.UID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论