Skip to content

Commit

Permalink
Revert cognito/custom domain back to one field
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcreaser committed Apr 22, 2024
1 parent 9470418 commit db8e84c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ data class AuthConfiguration internal constructor(
OauthConfiguration(
appClient = auth.userPoolClientId,
appSecret = null, // Not supported in Gen2
// Use the custom domain if specified, otherwise use the generated cognito domain
domain = it.customDomain ?: it.cognitoDomain,
domain = it.domain,
scopes = it.scopes.toSet(),
// Note: Gen2 config gives an array for these values, while Gen1 is just a String. In Gen1
// if you specify multiple URIs the CLI will join them to a comma-delimited string in the json.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class AuthConfigurationTest {
requireSymbols = true
}
oauth {
cognitoDomain = "https://test.com"
domain = "https://test.com"
identityProviders += AmplifyOutputsData.Auth.Oauth.IdentityProviders.GOOGLE
scopes += listOf("myScope", "myScope2")
redirectSignInUri += "https://test.com/signin"
Expand Down Expand Up @@ -259,22 +259,6 @@ class AuthConfigurationTest {
configuration.identityPool.shouldBeNull()
}

@Test
fun `uses custom oauth domain if specified`() {
val data = amplifyOutputsData {
auth {
oauth {
cognitoDomain = "cognito"
customDomain = "custom"
}
}
}

val configuration = AuthConfiguration.from(data)

configuration.oauth?.domain shouldBe "custom"
}

@Test
fun `throws exception if auth is not configured in amplify outputs`() {
val data = amplifyOutputsData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ interface AmplifyOutputsData {
@InternalAmplifyApi
interface Oauth {
val identityProviders: List<IdentityProviders>
val cognitoDomain: String
val customDomain: String?
val domain: String
val scopes: List<String>
val redirectSignInUri: List<String>
val redirectSignOutUri: List<String>
Expand Down Expand Up @@ -301,8 +300,7 @@ internal data class AmplifyOutputsDataImpl(
@Serializable
data class Oauth(
override val identityProviders: List<IdentityProviders>,
override val cognitoDomain: String,
override val customDomain: String?,
override val domain: String,
override val scopes: List<String>,
override val redirectSignInUri: List<String>,
override val redirectSignOutUri: List<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ class PasswordPolicyBuilder : AmplifyOutputsData.Auth.PasswordPolicy {

class OauthBuilder : AmplifyOutputsData.Auth.Oauth {
override val identityProviders: MutableList<AmplifyOutputsData.Auth.Oauth.IdentityProviders> = mutableListOf()
override var cognitoDomain: String = "domain"
override var customDomain: String? = null
override var domain: String = "domain"
override val scopes: MutableList<String> = mutableListOf()
override val redirectSignInUri: MutableList<String> = mutableListOf()
override val redirectSignOutUri: MutableList<String> = mutableListOf()
Expand Down

0 comments on commit db8e84c

Please sign in to comment.