-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add request ID to ReqContext in Op and include SKI in error logs
- Loading branch information
Mitali Rawat
committed
May 23, 2024
1 parent
5ca1df9
commit ef6c915
Showing
26 changed files
with
1,547 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package server | ||
|
||
import ( | ||
"crypto/rand" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/cloudflare/gokeyless/protocol" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestRequestID(t *testing.T) { | ||
require := require.New(t) | ||
|
||
r := make([]byte, 20) | ||
_, err := rand.Read(r) | ||
require.NoError(err) | ||
|
||
// empty byte array in ReqContext | ||
op := protocol.Operation{ | ||
Opcode: protocol.OpECDSASignSHA224, | ||
Payload: r, | ||
ReqContext: []byte{}, | ||
} | ||
reqID := addOperationRequestID(&op) | ||
require.NotEqual(reqID, "") | ||
|
||
// nil byte array | ||
op.ReqContext = nil | ||
reqID = addOperationRequestID(&op) | ||
require.NotEqual(reqID, "") | ||
|
||
// Operation.ReqContext contains a map and request id | ||
rc := map[string]interface{}{"request_id": "b76dfaf1-a852-4dc2-98ff-0ba1947a82b6"} | ||
b, err := json.Marshal(rc) | ||
require.NoError(err) | ||
op.ReqContext = b | ||
reqID = addOperationRequestID(&op) | ||
require.Equal(reqID, "b76dfaf1-a852-4dc2-98ff-0ba1947a82b6") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.