fix: CORS wildcard subdomain matching cache race condition (#7736)
test: add HTTPS test cases for CORS wildcard subdomain matching This adds comprehensive test coverage for HTTPS subdomain wildcard matching in TestMatchesOrigin: - https exact match - https no match - https wildcard subdomain match - https wildcard subdomain no match (base domain) - https wildcard subdomain no match (different domain) - protocol mismatch tests (http pattern vs https origin and vice versa) The matchWildcard function was already working correctly - this just adds test coverage for the HTTPS cases that were previously untested. Note: The cache invalidation is already handled synchronously by setBucketMetadata() which is called via: - UpdateBucketCORS -> UpdateBucketMetadata -> setBucketMetadata - ClearBucketCORS -> UpdateBucketMetadata -> setBucketMetadata Added clarifying comments to document this call chain.
This commit is contained in:
@@ -612,26 +612,28 @@ func (s3a *S3ApiServer) getCORSConfiguration(bucket string) (*cors.CORSConfigura
|
||||
// updateCORSConfiguration updates the CORS configuration for a bucket
|
||||
func (s3a *S3ApiServer) updateCORSConfiguration(bucket string, corsConfig *cors.CORSConfiguration) s3err.ErrorCode {
|
||||
// Update using structured API
|
||||
// Note: UpdateBucketCORS -> UpdateBucketMetadata -> setBucketMetadata
|
||||
// already invalidates the cache synchronously after successful update
|
||||
err := s3a.UpdateBucketCORS(bucket, corsConfig)
|
||||
if err != nil {
|
||||
glog.Errorf("updateCORSConfiguration: failed to update CORS config for bucket %s: %v", bucket, err)
|
||||
return s3err.ErrInternalError
|
||||
}
|
||||
|
||||
// Cache will be updated automatically via metadata subscription
|
||||
return s3err.ErrNone
|
||||
}
|
||||
|
||||
// removeCORSConfiguration removes the CORS configuration for a bucket
|
||||
func (s3a *S3ApiServer) removeCORSConfiguration(bucket string) s3err.ErrorCode {
|
||||
// Update using structured API
|
||||
// Note: ClearBucketCORS -> UpdateBucketMetadata -> setBucketMetadata
|
||||
// already invalidates the cache synchronously after successful update
|
||||
err := s3a.ClearBucketCORS(bucket)
|
||||
if err != nil {
|
||||
glog.Errorf("removeCORSConfiguration: failed to remove CORS config for bucket %s: %v", bucket, err)
|
||||
return s3err.ErrInternalError
|
||||
}
|
||||
|
||||
// Cache will be updated automatically via metadata subscription
|
||||
return s3err.ErrNone
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user