Skip to content

Commit

Permalink
Merge branch 'main' into mattcreaser/api-regex-china
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcreaser authored Nov 15, 2024
2 parents a1a2798 + 59bde4e commit 18f1b1a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull

private val standardEndpointRegex =
"^https://\\w{26}\\.appsync-api\\.\\w{2}(?:-\\w{2,})+-\\d\\.amazonaws.com/graphql$".toRegex()
"^https://\\w{26}\\.appsync-api\\.\\w{2}(?:-\\w{2,})+-\\d\\.amazonaws.com(?:\\.cn)?/graphql$".toRegex()

/**
* Class representing the AppSync endpoint. There are multiple URLs associated with each AppSync endpoint: the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import org.junit.Test

class AppSyncEndpointTest {
private val standardAppSyncUrl = "https://example1234567890123456789.appsync-api.us-east-1.amazonaws.com/graphql"
private val standardAppSyncUrlChina =
"https://example1234567890123456789.appsync-api.us-east-1.amazonaws.com.cn/graphql"
private val customAppSyncUrl = "https://api.example.com/graphql"

@Test
Expand All @@ -48,6 +50,13 @@ class AppSyncEndpointTest {
"https://example1234567890123456789.appsync-realtime-api.us-east-1.amazonaws.com/graphql/connect"
}

@Test
fun `uses expected realtime URL for standard endpoint in China`() {
val endpoint = AppSyncEndpoint(standardAppSyncUrlChina)
endpoint.websocketConnection.toString() shouldBe
"https://example1234567890123456789.appsync-realtime-api.us-east-1.amazonaws.com.cn/graphql/connect"
}

@Test
fun `uses expected realtime URL for custom endpoint`() {
val endpoint = AppSyncEndpoint(customAppSyncUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ import com.amplifyframework.logging.LoggingCategory
@Suppress("unused")
class Amplify {
companion object {
val Analytics = AnalyticsCategory()
val Analytics: AnalyticsCategory = delegate.Analytics
val API = KotlinApiFacade()
val Auth = KotlinAuthFacade()
val Geo = KotlinGeoFacade()
val Logging = LoggingCategory()
val Logging: LoggingCategory = delegate.Logging
val Storage = KotlinStorageFacade()
val Hub = KotlinHubFacade()
val DataStore = KotlinDataStoreFacade()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public final class RxAmplify {
private RxAmplify() {}

// Breaking the rules, here. Don't look.
@SuppressWarnings({"checkstyle:all"}) public static final AnalyticsCategory Analytics = new AnalyticsCategory();
@SuppressWarnings({"checkstyle:all"}) public static final AnalyticsCategory Analytics = Amplify.Analytics;
@SuppressWarnings({"checkstyle:all"}) public static final RxApiCategoryBehavior API = new RxApiBinding();
@SuppressWarnings({"checkstyle:all"}) public static final RxAuthCategoryBehavior Auth = new RxAuthBinding();
@SuppressWarnings({"checkstyle:all"}) public static final LoggingCategory Logging = new LoggingCategory();
@SuppressWarnings({"checkstyle:all"}) public static final LoggingCategory Logging = Amplify.Logging;
@SuppressWarnings({"checkstyle:all"}) public static final RxStorageCategoryBehavior Storage = new RxStorageBinding();
@SuppressWarnings({"checkstyle:all"}) public static final RxHubCategoryBehavior Hub = new RxHubBinding();
@SuppressWarnings({"checkstyle:all"}) public static final RxDataStoreCategoryBehavior DataStore = new RxDataStoreBinding();
Expand Down

0 comments on commit 18f1b1a

Please sign in to comment.