github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/user_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  package libkb
     5  
     6  import (
     7  	"testing"
     8  
     9  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
    10  )
    11  
    12  func TestExportUser(t *testing.T) {
    13  	tc := SetupTest(t, "export_user", 1)
    14  	defer tc.Cleanup()
    15  	alice, err := LoadUser(NewLoadUserByNameArg(tc.G, "t_alice"))
    16  	if err != nil {
    17  		t.Fatal(err)
    18  	}
    19  
    20  	exportedAlice := alice.Export()
    21  
    22  	if exportedAlice.Uid.String() != "295a7eea607af32040647123732bc819" {
    23  		t.Fatal("wrong UID", exportedAlice.Uid)
    24  	}
    25  
    26  	if exportedAlice.Username != "t_alice" {
    27  		t.Fatal("wrong username", exportedAlice.Username)
    28  	}
    29  
    30  	var publicKeys []keybase1.PublicKey
    31  	if alice.GetComputedKeyFamily() != nil {
    32  		publicKeys = alice.GetComputedKeyFamily().Export()
    33  	}
    34  
    35  	if len(publicKeys) != 1 {
    36  		t.Fatal("expected 1 public key", publicKeys)
    37  	}
    38  
    39  	if publicKeys[0].PGPFingerprint != "2373fd089f28f328916b88f99c7927c0bdfdadf9" {
    40  		t.Fatal("wrong fingerprint", publicKeys[0].PGPFingerprint)
    41  	}
    42  }