github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/libkb/constants_test.go (about)

     1  package libkb
     2  
     3  import (
     4  	"testing"
     5  
     6  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestProveTypes(t *testing.T) {
    11  	// Make sure we don't accidentally exclude any new proof types.
    12  	excludedServiceTypes := map[keybase1.ProofType]bool{
    13  		keybase1.ProofType_NONE: true,
    14  		keybase1.ProofType_PGP:  true,
    15  	}
    16  
    17  	excludedServiceOrderTypes := map[keybase1.ProofType]bool{
    18  		keybase1.ProofType_NONE: true,
    19  		keybase1.ProofType_DNS:  true,
    20  		keybase1.ProofType_PGP:  true,
    21  	}
    22  
    23  	remoteServiceTypesRevMap := map[keybase1.ProofType]bool{}
    24  	for _, pt := range RemoteServiceTypes {
    25  		remoteServiceTypesRevMap[pt] = true
    26  	}
    27  
    28  	remoteServiceOrderMap := map[keybase1.ProofType]bool{}
    29  	for _, pt := range RemoteServiceOrder {
    30  		remoteServiceOrderMap[pt] = true
    31  	}
    32  
    33  	for _, pt := range keybase1.ProofTypeMap {
    34  		if _, ok := remoteServiceTypesRevMap[pt]; !ok {
    35  			_, isExcluded := excludedServiceTypes[pt]
    36  			require.True(t, isExcluded, "%v is missing from RemoteServiceTypes", pt)
    37  		}
    38  		if _, ok := remoteServiceOrderMap[pt]; !ok {
    39  			_, isExcluded := excludedServiceOrderTypes[pt]
    40  			require.True(t, isExcluded, "%v is missing from RemoteServiceOrder", pt)
    41  		}
    42  	}
    43  }
    44  
    45  type MockedConfig struct {
    46  	NullConfiguration
    47  	mockedIsSslPinningEnabled bool
    48  }
    49  
    50  func (mc MockedConfig) IsCertPinningEnabled() bool {
    51  	return mc.mockedIsSslPinningEnabled
    52  }