Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/record/recording_https_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (r *RecordingHTTPSProxy) proxyRequest(w http.ResponseWriter, req *http.Requ
}

func (r *RecordingHTTPSProxy) recordResponse(recReq *store.RecordedRequest, resp *http.Response, fileName string, shaSum string, body []byte) error {
recordedResponse, err := store.NewRecordedResponse(resp, body)
recordedResponse, err := store.NewRecordedResponse(resp, r.redactor, body)
if err != nil {
return err
}
Expand All @@ -204,9 +204,9 @@ func (r *RecordingHTTPSProxy) recordResponse(recReq *store.RecordedRequest, resp
recordPath := filepath.Join(r.recordingDir, fileName+".json")

recordDir := filepath.Dir(recordPath)
if err := os.MkdirAll(recordDir, 0755); err != nil {
return err
}
if err := os.MkdirAll(recordDir, 0755); err != nil {
return err
}

// Default to overwriting the file.
fileMode := os.O_TRUNC
Expand Down
7 changes: 4 additions & 3 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"strings"

"github.com/google/test-server/internal/config"
"github.com/google/test-server/internal/redact"
)

const HeadSHA = "b4d6e60a9b97e7b98c63df9308728c5c88c0b40c398046772c63447b94608b4d"
Expand Down Expand Up @@ -162,7 +163,7 @@ func (r *RecordedRequest) RedactHeaders(headers []string) {
}
}

func NewRecordedResponse(resp *http.Response, body []byte) (*RecordedResponse, error) {
func NewRecordedResponse(resp *http.Response, redactor *redact.Redact, body []byte) (*RecordedResponse, error) {
if resp.Header.Get("Content-Encoding") == "gzip" {
gzipReader, err := gzip.NewReader(bytes.NewReader(body))
if err != nil {
Expand Down Expand Up @@ -206,7 +207,7 @@ func NewRecordedResponse(resp *http.Response, body []byte) (*RecordedResponse, e
continue
}

bodySegments = append(bodySegments, jsonMap)
bodySegments = append(bodySegments, redactor.Map(jsonMap))
}
}

Expand All @@ -215,7 +216,7 @@ func NewRecordedResponse(resp *http.Response, body []byte) (*RecordedResponse, e
return nil, err
}
} else {
bodySegments = append(bodySegments, bodySegment)
bodySegments = append(bodySegments, redactor.Map(bodySegment))
}

recordedResponse := &RecordedResponse{
Expand Down