github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/engine/prove_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 engine
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/keybase/client/go/libkb"
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestProveRooter(t *testing.T) {
    14  	doWithSigChainVersions(func(sigVersion libkb.SigVersion) {
    15  		_testProveRooter(t, sigVersion)
    16  	})
    17  }
    18  
    19  func _testProveRooter(t *testing.T, sigVersion libkb.SigVersion) {
    20  	tc := SetupEngineTest(t, "prove")
    21  	defer tc.Cleanup()
    22  
    23  	fu := CreateAndSignupFakeUser(tc, "prove")
    24  
    25  	proveUI, _, err := proveRooter(tc.G, fu, sigVersion)
    26  	require.NoError(t, err)
    27  
    28  	require.False(t, proveUI.overwrite)
    29  	require.False(t, proveUI.warning)
    30  	require.False(t, proveUI.recheck)
    31  	require.True(t, proveUI.checked)
    32  }
    33  
    34  // Make sure the prove engine uses the secret store.
    35  func TestProveRooterWithSecretStore(t *testing.T) {
    36  	doWithSigChainVersions(func(sigVersion libkb.SigVersion) {
    37  		_testProveRooterWithSecretStore(t, sigVersion)
    38  	})
    39  }
    40  
    41  func _testProveRooterWithSecretStore(t *testing.T, sigVersion libkb.SigVersion) {
    42  	testEngineWithSecretStore(t, func(
    43  		tc libkb.TestContext, fu *FakeUser, secretUI libkb.SecretUI) {
    44  		_, _, err := proveRooterWithSecretUI(tc.G, fu, secretUI, sigVersion)
    45  		require.NoError(t, err)
    46  	})
    47  }
    48  
    49  // When device keys are cached, proofs shouldn't require passphrase prompt.
    50  func TestProveRooterCachedKeys(t *testing.T) {
    51  	tc := SetupEngineTest(t, "prove")
    52  	defer tc.Cleanup()
    53  	sigVersion := libkb.GetDefaultSigVersion(tc.G)
    54  
    55  	fu := CreateAndSignupFakeUser(tc, "prove")
    56  	clearCaches(tc.G)
    57  
    58  	_, _, err := proveRooterWithSecretUI(tc.G, fu, &libkb.TestSecretUI{}, sigVersion)
    59  	require.NoError(t, err)
    60  }
    61  
    62  func TestProveGenericSocial(t *testing.T) {
    63  	tc := SetupEngineTest(t, "prove")
    64  	defer tc.Cleanup()
    65  	sigVersion := libkb.KeybaseSignatureV2
    66  
    67  	fu := CreateAndSignupFakeUser(tc, "prove")
    68  	proveGubbleSocial(tc, fu, sigVersion)
    69  	proveGubbleCloud(tc, fu, sigVersion)
    70  }