Skip to content

Commit

Permalink
Merge pull request #267 from capeprivacy/eric/add-token-for-test
Browse files Browse the repository at this point in the history
add token parameter to test cmd
  • Loading branch information
eric-capeprivacy authored Apr 6, 2023
2 parents 2e5fbd3 + 258307d commit d6c1394
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/cape/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
log "github.com/sirupsen/logrus"

"github.com/capeprivacy/attest/attest"
"github.com/capeprivacy/cli/entities"
"github.com/capeprivacy/cli/sdk"
)

Expand Down Expand Up @@ -40,7 +41,7 @@ Results are output to stdout so you can easily pipe them elsewhere`,

func init() {
rootCmd.AddCommand(testCmd)

testCmd.PersistentFlags().StringP("token", "t", "", "authorization token to use")
testCmd.PersistentFlags().StringP("file", "f", "", "input data file (or '-f -' to accept stdin)")
testCmd.PersistentFlags().StringSliceP("pcr", "p", []string{""}, "pass multiple PCRs to validate against")
}
Expand Down Expand Up @@ -96,9 +97,16 @@ func Test(cmd *cobra.Command, args []string) error {
return UserError{Msg: "invalid input", Err: errors.New("please provide input as a string, input file or stdin")}
}

token, err := authToken()
if err != nil {
return err
auth := entities.FunctionAuth{Type: entities.AuthenticationTypeUserToken}
token, _ := cmd.Flags().GetString("token")
if token != "" {
auth.Token = token
} else {
token, err := authToken()
if err != nil {
return err
}
auth.Token = token
}

verifier := attest.NewVerifier()
Expand Down

0 comments on commit d6c1394

Please sign in to comment.