|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package org.apache.doris.filesystem.cos; |
| 19 | + |
| 20 | +import org.junit.jupiter.api.Assertions; |
| 21 | +import org.junit.jupiter.api.Test; |
| 22 | + |
| 23 | +import java.util.HashMap; |
| 24 | +import java.util.Map; |
| 25 | + |
| 26 | +/** |
| 27 | + * The Tencent COS endpoint is matched by DNS hostname, so classification must be case-insensitive |
| 28 | + * (same class of defect as DORIS-29438 / OSS). |
| 29 | + */ |
| 30 | +class CosFileSystemProviderTest { |
| 31 | + |
| 32 | + private final CosFileSystemProvider provider = new CosFileSystemProvider(); |
| 33 | + |
| 34 | + @Test |
| 35 | + void supports_isCaseInsensitiveForCosEndpoint() { |
| 36 | + Map<String, String> lower = new HashMap<>(); |
| 37 | + lower.put("cos.endpoint", "cos.ap-shanghai.myqcloud.com"); |
| 38 | + Map<String, String> upper = new HashMap<>(); |
| 39 | + upper.put("cos.endpoint", "COS.AP-SHANGHAI.MYQCLOUD.COM"); |
| 40 | + |
| 41 | + Assertions.assertTrue(provider.supports(lower)); |
| 42 | + Assertions.assertTrue(provider.supports(upper), upper.toString()); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + void supportsGuess_isCaseInsensitiveForCosEndpointAndUri() { |
| 47 | + Map<String, String> upperEndpoint = new HashMap<>(); |
| 48 | + upperEndpoint.put("s3.endpoint", "COS.AP-SHANGHAI.MYQCLOUD.COM"); |
| 49 | + Assertions.assertTrue(provider.supportsGuess(upperEndpoint), upperEndpoint.toString()); |
| 50 | + |
| 51 | + Map<String, String> upperUri = new HashMap<>(); |
| 52 | + upperUri.put("uri", "cos://my-bucket.COS.AP-SHANGHAI.MYQCLOUD.COM/resources/doc.txt"); |
| 53 | + Assertions.assertTrue(provider.supportsGuess(upperUri), upperUri.toString()); |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + void supportsGuess_rejectsForeignEndpointRegardlessOfCase() { |
| 58 | + Map<String, String> aws = new HashMap<>(); |
| 59 | + aws.put("s3.endpoint", "HTTPS://S3.US-EAST-1.AMAZONAWS.COM"); |
| 60 | + |
| 61 | + Assertions.assertFalse(provider.supportsGuess(aws)); |
| 62 | + Assertions.assertFalse(provider.supports(aws)); |
| 63 | + } |
| 64 | +} |
0 commit comments