forked from neo4j-contrib/neo4j-apoc-procedures
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…ib#2725) * Fixes neo4j-contrib#2724, AWS S3 url handling * Fixes neo4j-contrib#2269: apoc.load procedures don't work anymore with urls containing % * Code formatting * Adds fix for the getHost problem Co-authored-by: Giuseppe Villani <[email protected]> Co-authored-by: Nacho Cordón <[email protected]>
- Loading branch information
1 parent
d8aa7be
commit 12fd21b
Showing
3 changed files
with
68 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/src/test/java/apoc/util/s3/S3ParamsExtractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package apoc.util.s3; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
public class S3ParamsExtractorTest { | ||
|
||
@Test | ||
public void testEncodedS3Url() throws Exception { | ||
S3Params params = S3ParamsExtractor.extract("s3://accessKeyId:some%2Fsecret%2Fkey:some%2Fsession%[email protected]:1234/bucket/path/to/key"); | ||
assertEquals("some/secret/key", params.getSecretKey()); | ||
assertEquals("some/session/token", params.getSessionToken()); | ||
assertEquals("accessKeyId", params.getAccessKey()); | ||
assertEquals("bucket", params.getBucket()); | ||
assertEquals("path/to/key", params.getKey()); | ||
assertEquals("s3.us-east-2.amazonaws.com:1234", params.getEndpoint()); | ||
assertEquals("us-east-2", params.getRegion()); | ||
} | ||
|
||
@Test | ||
public void testEncodedS3UrlQueryParams() throws Exception { | ||
S3Params params = S3ParamsExtractor.extract("s3://s3.us-east-2.amazonaws.com:1234/bucket/path/to/key?accessKey=accessKeyId&secretKey=some%2Fsecret%2Fkey&sessionToken=some%2Fsession%2Ftoken"); | ||
assertEquals("some/secret/key", params.getSecretKey()); | ||
assertEquals("some/session/token", params.getSessionToken()); | ||
assertEquals("accessKeyId", params.getAccessKey()); | ||
assertEquals("bucket", params.getBucket()); | ||
assertEquals("path/to/key", params.getKey()); | ||
assertEquals("s3.us-east-2.amazonaws.com:1234", params.getEndpoint()); | ||
} | ||
|
||
@Test | ||
public void testExtractEndpointPort() throws Exception { | ||
assertEquals("s3.amazonaws.com", S3ParamsExtractor.extract("s3://s3.amazonaws.com:80/bucket/path/to/key").getEndpoint()); | ||
assertEquals("s3.amazonaws.com:1234", S3ParamsExtractor.extract("s3://s3.amazonaws.com:1234/bucket/path/to/key").getEndpoint()); | ||
} | ||
|
||
@Test | ||
public void testExtractRegion() throws Exception { | ||
assertEquals("us-east-2", S3ParamsExtractor.extract("s3://s3.us-east-2.amazonaws.com:80/bucket/path/to/key").getRegion()); | ||
assertNull(S3ParamsExtractor.extract("s3://s3.amazonaws.com:80/bucket/path/to/key").getRegion()); | ||
} | ||
} |