test: REST PutObject, HeadObject, organization, skips removal

This commit is contained in:
Luke McCrone
2025-08-25 11:55:42 -03:00
parent 9992e341da
commit b3286c44e2
25 changed files with 602 additions and 451 deletions
+8 -1
View File
@@ -23,6 +23,7 @@ var awsSecretAccessKey *string
var serviceName *string
var debug *bool
var signedParamsMap restParams
var payloadFile *string
type S3Command struct {
Method string
@@ -35,6 +36,7 @@ type S3Command struct {
AwsSecretAccessKey string
ServiceName string
SignedParams map[string]string
PayloadFile string
currentDateTime string
host string
@@ -84,6 +86,7 @@ func main() {
AwsSecretAccessKey: *awsSecretAccessKey,
ServiceName: *serviceName,
SignedParams: signedParamsMap,
PayloadFile: *payloadFile,
}
curlShellCommand, err := s3Command.CurlShellCommand()
if err != nil {
@@ -104,6 +107,7 @@ func checkFlags() error {
serviceName = flag.String("serviceName", "s3", "Service name")
debug = flag.Bool("debug", false, "Print debug statements")
flag.Var(&signedParamsMap, "signedParams", "Signed params, separated by comma")
payloadFile = flag.String("payloadFile", "", "Payload file path, if any")
// Parse the flags
flag.Parse()
@@ -168,7 +172,7 @@ func (s *S3Command) generateCanonicalRequestString() {
signedParams := []string{"host"}
for _, headerValue := range s.headerValues {
key := headerValue[0]
key := strings.ToLower(headerValue[0])
canonicalRequestLines = append(canonicalRequestLines, key+":"+headerValue[1])
signedParams = append(signedParams, key)
}
@@ -225,5 +229,8 @@ func (s *S3Command) buildCurlShellCommand() string {
headerString := fmt.Sprintf("\"%s: %s\"", headerValue[0], headerValue[1])
curlCommand = append(curlCommand, "-H", headerString)
}
if s.PayloadFile != "" {
curlCommand = append(curlCommand, "-T", s.PayloadFile)
}
return strings.Join(curlCommand, " ")
}