Skip to content

Commit

Permalink
update test util
Browse files Browse the repository at this point in the history
  • Loading branch information
joshspicer authored Dec 28, 2023
1 parent 9b72935 commit 35f33b5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 5 additions & 0 deletions util/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module util

go 1.21.5

require github.com/google/uuid v1.5.0
2 changes: 2 additions & 0 deletions util/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
23 changes: 18 additions & 5 deletions util/util.go → util/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utilties
package main

import (
"crypto/hmac"
Expand All @@ -11,17 +11,31 @@ import (
"github.com/google/uuid"
)

func usageAndExit() {
fmt.Printf("Usage: %s <mode> <secret> <endpoint>\n", os.Args[0])
os.Exit(1)
}

func main() {
if len(os.Args) < 2 {
usageAndExit()
}

switch os.Args[1] {
case "hmac":
generateAuthHeader()

default:
usageAndExit()
}
}

func generateAuthHeader() {
endpoint := os.Args[2]
secret := os.Args[3]
if len(os.Args) < 4 {
usageAndExit()
}

secret := os.Args[2]
endpoint := os.Args[3]

timestamp := time.Now().Unix()
uuid, _ := uuid.NewRandom()
Expand All @@ -37,6 +51,5 @@ func generateAuthHeader() {
fmt.Printf("%s\n", nonce)
fmt.Printf("%s\n", auth)
fmt.Println()

fmt.Printf("curl http://127.0.0.1:4000/%s -H 'Authorization: %s' -H 'X-Jarvis-Timestamp: %s'\n", endpoint, auth, nonce)
}
Binary file added util/util
Binary file not shown.

0 comments on commit 35f33b5

Please sign in to comment.