Skip to content

Commit

Permalink
fix(api): Fix connecting to AppSync from China with API category (#2948)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcreaser authored Nov 15, 2024
1 parent 59bde4e commit 0e81068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum DomainType {
CUSTOM;

private static final String STANDARD_ENDPOINT_REGEX =
"^https:\\/\\/\\w{26}\\.appsync\\-api\\.\\w{2}(?:(?:\\-\\w{2,})+)\\-\\d\\.amazonaws.com\\/graphql$";
"^https:\\/\\/\\w{26}\\.appsync\\-api\\.\\w{2}(?:\\-\\w{2,})+\\-\\d\\.amazonaws.com(?:\\.cn)?\\/graphql$";

/**
* Get Domain type based on defined endpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
public class DomainTypeTest {
private static final String STANDARD_URL =
"https://abcdefghijklmnopqrstuvwxyz.appsync-api.us-west-2.amazonaws.com/graphql";
private static final String STANDARD_URL_CHINA =
"https://abcdefghijklmnopqrstuvwxyz.appsync-api.us-west-2.amazonaws.com.cn/graphql";
private static final String CUSTOM_URL = "https://something.in.somedomain.com/graphql";

/**
Expand All @@ -34,6 +36,14 @@ public void testStandardURLMatch() {
Assert.assertEquals(STANDARD, DomainType.from(STANDARD_URL));
}

/**
* Test that Domain type is {@link DomainType#STANDARD} for generated URL.
*/
@Test
public void testStandardURLChinaMatch() {
Assert.assertEquals(STANDARD, DomainType.from(STANDARD_URL_CHINA));
}

/**
* Test that Domain type is set to {@link DomainType#CUSTOM} for custom URLs.
*/
Expand Down

0 comments on commit 0e81068

Please sign in to comment.