diff --git a/cmd/cape/cmd/key.go b/cmd/cape/cmd/key.go index 629145e..6538d86 100644 --- a/cmd/cape/cmd/key.go +++ b/cmd/cape/cmd/key.go @@ -40,7 +40,7 @@ func key(cmd *cobra.Command, args []string) error { token, _ := cmd.Flags().GetString("token") if token == "" { - t, err := authTokenFunc() + t, err := authToken() if err != nil { return err } @@ -91,5 +91,4 @@ func GetKeyRequest(pcrSlice []string, token string) (sdk.KeyRequest, error) { }, nil } -var authTokenFunc = getAuthToken var keyFunc = sdk.Key diff --git a/cmd/cape/cmd/key_test.go b/cmd/cape/cmd/key_test.go index ad425f6..edf5313 100644 --- a/cmd/cape/cmd/key_test.go +++ b/cmd/cape/cmd/key_test.go @@ -30,12 +30,12 @@ vbU0SB7H7aX/bxqvQ+MOwS8CAwEAAQ== keyFunc = func(keyReq sdk.KeyRequest) ([]byte, error) { return []byte("0\x82\x02\"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa0͢!a}\xa1\xccX\x1aĔ\x9f+}?\xb3K\xabx/\xdfۍ$'H\x19\xe7\xbf\xcb\xc1\x10\x1e\x11D\x83\xa7\t8\xd3\xc9?\xad\x04\xffvm\xe2\x19\xebb\x1e\x1a\xe2\\{\xad]\x1aZK9+\x1aP\x8b\xa2\xcf?\xdf,P\xa2\xe4d\xef\xd9M\xc69R\vg\xecP\x106=}\xa2\x1bH\xdf\xd76X(1P\x1f\xf5!\x1e<\xe615H\xb1g\xc7~u\x99\xca \xe1]\xe9uN\x93\x1c\xadYA3a\x92\x89\xec/\f\x9a?\x94\U000e4b12\xa7?\x8e\x96\x03\x814;NE\x88\x83`\xb7Kc\xb5K\xfc\xef\xed^\xc5\xf4\xde\xe5J~\xee\xa6A\x93q\x84\xe4\x91\xda\xc0\xfa\x02\x81\"\xfc\xb6\x84\b\xc3>/ސ\x12\x13\x86\xbf.\xf0 \xba\xf5f7:*U$\xb1r\x8e\x95w\x8a\x84\x9d1\xc7\a\x01X\xcc\xe7$o6[7\x8ds45\xe0\x8f\x88\xf5\x17d-KO\xbd\xb54H\x1e\xc7\xed\xa5\xffo\x1a\xafC\xe3\x0e\xc1/\x02\x03\x01\x00\x01"), nil } - authTokenFunc = func() (string, error) { + authToken = func() (string, error) { return "you're you", nil } defer func() { keyFunc = sdk.Key - authTokenFunc = getAuthToken + authToken = getAuthToken }() if err := cmd.Execute(); err != nil { @@ -58,12 +58,12 @@ func TestKeyInvalidFormat(t *testing.T) { keyFunc = func(keyReq sdk.KeyRequest) ([]byte, error) { return []byte("-----BEGIN PUBLIC KEY-----\nTestKey\n-----END PUBLIC KEY-----\n"), nil } - authTokenFunc = func() (string, error) { + authToken = func() (string, error) { return "you're you", nil } defer func() { keyFunc = sdk.Key - authTokenFunc = getAuthToken + authToken = getAuthToken }() err := cmd.Execute()