mirror of
https://github.com/versity/versitygw.git
synced 2026-09-03 06:37:05 +00:00
test: bucket setup/resetting cleanup, go virtual path handling, s3api profile setup
This commit is contained in:
@@ -39,7 +39,7 @@ func (c *CurlCommand) Render() error {
|
||||
if c.Config.Method != "GET" {
|
||||
curlCommand = append(curlCommand, fmt.Sprintf("-X %s ", c.Config.Method))
|
||||
}
|
||||
fullPath := c.Config.Url + c.path
|
||||
fullPath := c.url + c.path
|
||||
awsUrl, err := url.Parse(fullPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing URL: %w", err)
|
||||
|
||||
@@ -28,6 +28,7 @@ type S3Request struct {
|
||||
dataSource DataSource
|
||||
canonicalRequestHash string
|
||||
signingKey []byte
|
||||
url string
|
||||
}
|
||||
|
||||
func (s *S3Request) CalculateDateTimeParams() {
|
||||
@@ -50,12 +51,21 @@ func (s *S3Request) DeriveHost() error {
|
||||
if len(protocolAndHost) != 2 {
|
||||
return fmt.Errorf("invalid URL value: %s", s.Config.Url)
|
||||
}
|
||||
s.host = protocolAndHost[1]
|
||||
if s.Config.AddressFormat == AddressFormatVirtual && s.Config.BucketName != "" {
|
||||
s.host = fmt.Sprintf("%s.%s", s.Config.BucketName, protocolAndHost[1])
|
||||
s.url = strings.Join([]string{protocolAndHost[0], s.host}, "://")
|
||||
} else {
|
||||
s.host = protocolAndHost[1]
|
||||
s.url = s.Config.Url
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *S3Request) DeriveBucketAndKeyPath() {
|
||||
s.path = "/" + s.Config.BucketName
|
||||
s.path = "/"
|
||||
if s.Config.BucketName != "" && s.Config.AddressFormat == AddressFormatPath {
|
||||
s.path += s.Config.BucketName
|
||||
}
|
||||
if s.Config.ObjectKey != "" {
|
||||
s.path += "/" + s.Config.ObjectKey
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@ const (
|
||||
OPENSSL = "openssl"
|
||||
)
|
||||
|
||||
const (
|
||||
AddressFormatPath = "path"
|
||||
AddressFormatVirtual = "virtual"
|
||||
)
|
||||
|
||||
const (
|
||||
UnsignedPayload = "UNSIGNED-PAYLOAD"
|
||||
StreamingAWS4HMACSHA256Payload = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
|
||||
@@ -80,6 +85,7 @@ type S3RequestConfigData struct {
|
||||
WriteXMLPayloadToFile string
|
||||
OutputFile string
|
||||
HeaderFile string
|
||||
AddressFormat string
|
||||
}
|
||||
|
||||
type S3RequestBuilder struct {
|
||||
|
||||
Reference in New Issue
Block a user