Skip to content

Commit

Permalink
Use existing auth function var
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisFriesen committed Apr 13, 2023
1 parent 9eefe8b commit b355151
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cmd/cape/cmd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -91,5 +91,4 @@ func GetKeyRequest(pcrSlice []string, token string) (sdk.KeyRequest, error) {
}, nil
}

var authTokenFunc = getAuthToken
var keyFunc = sdk.Key
8 changes: 4 additions & 4 deletions cmd/cape/cmd/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<j\x9b\xa8\x91o\xb0P\xad\xcf\xf0\x85\x88\xfc\x16\x97\xe3\xf7i\xbc\xddŤ\xfa8e\xa9D0\x8c\xc6wo@}\x8ed\x9f\xcdCf\x11\x91'\x83\xff\x81\xc3\xd8E\xa4\xc1\xf8\xf0\xb3\xac\x00| ϛB\xd5\x18n\x18\x8eH\xb3\xa5Z)G\x8anzme\x04D!\xc5ܳo9\xee\x1f\xb5\x8b\xa1\x15[]l\x86~\bF\x93\xa5\xde{šO\xadH<)9\x05\xec\xee\x81\\\xb0E\xb3\xfa\xa8i\x92s\x1cA\xf7\x7f~\xff\xf3\xe0T\x94\xba\xf4\xad\xceSN\xe9\xbb\x06\x9b\u00816\xd5ˍ6\xe1+\x85{C\x8e\nq\x8b\xa5\xa3\x0fç\x84j\xdc\xf7\xfedx(\xaa\x97\xea\xba;)Y]R\x87\xef\xae\xea\xb3µ\xef%2\x8c\xc4!Wu\xb1Ƃ[\x0fR\xc3X\x9d\xf2\xc8.%7\xe0q\xccu\x1c\x16\xe9華Sl\xe8\x8d\xf4\x1f\xf8@20|\r\xd3\xfe\t\x9e\xa6u\x98\x96O\x86/g\x1a\x99\xc85\x9b\xb2\xc0\x1b\r>;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 {
Expand All @@ -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()
Expand Down

0 comments on commit b355151

Please sign in to comment.