Skip to content

Commit

Permalink
Update to match enum changes in the schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcreaser committed Apr 15, 2024
1 parent e9e6044 commit 6ae0bbb
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ data class AuthConfiguration internal constructor(
}

private fun AmplifyOutputsData.Auth.UsernameAttributes.toConfigType() = when (this) {
AmplifyOutputsData.Auth.UsernameAttributes.EMAIL -> UsernameAttribute.Email
AmplifyOutputsData.Auth.UsernameAttributes.PHONE -> UsernameAttribute.PhoneNumber
AmplifyOutputsData.Auth.UsernameAttributes.USERNAME -> UsernameAttribute.Username
AmplifyOutputsData.Auth.UsernameAttributes.Email -> UsernameAttribute.Email
AmplifyOutputsData.Auth.UsernameAttributes.PhoneNumber -> UsernameAttribute.PhoneNumber
AmplifyOutputsData.Auth.UsernameAttributes.Username -> UsernameAttribute.Username
}

private fun AmplifyOutputsData.Auth.UserVerificationTypes.toConfigType() = when (this) {
AmplifyOutputsData.Auth.UserVerificationTypes.EMAIL -> VerificationMechanism.Email
AmplifyOutputsData.Auth.UserVerificationTypes.PHONE -> VerificationMechanism.PhoneNumber
AmplifyOutputsData.Auth.UserVerificationTypes.Email -> VerificationMechanism.Email
AmplifyOutputsData.Auth.UserVerificationTypes.PhoneNumber -> VerificationMechanism.PhoneNumber
}

private fun AmplifyOutputsData.Auth.PasswordPolicy.toConfigType() = PasswordProtectionSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class AuthConfigurationTest {
scopes += listOf("myScope", "myScope2")
redirectSignInUri += "https://test.com/signin"
redirectSignOutUri += "https://test.com/signout"
responseType = AmplifyOutputsData.Auth.Oauth.ResponseType.TOKEN
responseType = AmplifyOutputsData.Auth.Oauth.ResponseType.Token
}
standardRequiredAttributes += AuthUserAttributeKey.email()
usernameAttributes += AmplifyOutputsData.Auth.UsernameAttributes.EMAIL
userVerificationTypes += AmplifyOutputsData.Auth.UserVerificationTypes.EMAIL
usernameAttributes += AmplifyOutputsData.Auth.UsernameAttributes.Email
userVerificationTypes += AmplifyOutputsData.Auth.UserVerificationTypes.Email
mfaConfiguration = AmplifyOutputsData.Auth.MfaConfiguration.REQUIRED
mfaMethods += AmplifyOutputsData.Auth.MfaMethods.SMS
}
Expand Down
12 changes: 12 additions & 0 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,18 @@ public final class com/amplifyframework/core/configuration/AmplifyOutputs$Compan
public final fun fromString (Ljava/lang/String;)Lcom/amplifyframework/core/configuration/AmplifyOutputs;
}

public final class com/amplifyframework/core/configuration/AmplifyOutputsData$Auth$Oauth$ResponseType$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class com/amplifyframework/core/configuration/AmplifyOutputsData$Auth$UserVerificationTypes$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class com/amplifyframework/core/configuration/AmplifyOutputsData$Auth$UsernameAttributes$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public final class com/amplifyframework/core/configuration/AmplifyOutputsKt {
public static final synthetic fun AmplifyOutputs (I)Lcom/amplifyframework/core/configuration/AmplifyOutputs;
public static final synthetic fun AmplifyOutputs (Ljava/lang/String;)Lcom/amplifyframework/core/configuration/AmplifyOutputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,41 @@ interface AmplifyOutputsData {
}

@InternalAmplifyApi
@Serializable
enum class ResponseType {
@SerialName("code")
CODE,
Code,

@SerialName("token")
TOKEN
Token
}
}

@InternalAmplifyApi
enum class AuthenticationFlowType { USER_SRP_AUTH, CUSTOM_AUTH }

@InternalAmplifyApi
enum class UsernameAttributes { USERNAME, EMAIL, PHONE }
@Serializable
enum class UsernameAttributes {
@SerialName("username")
Username,

@SerialName("email")
Email,

@SerialName("phone_number")
PhoneNumber
}

@InternalAmplifyApi
enum class UserVerificationTypes { EMAIL, PHONE }
@Serializable
enum class UserVerificationTypes {
@SerialName("email")
Email,

@SerialName("phone_number")
PhoneNumber
}

@InternalAmplifyApi
enum class MfaConfiguration { NONE, OPTIONAL, REQUIRED }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ class AmplifyOutputsDataTest {
AuthUserAttributeKey.gender().keyString
),
Keys.usernameAttributes to listOf(
AmplifyOutputsData.Auth.UsernameAttributes.USERNAME.name,
AmplifyOutputsData.Auth.UsernameAttributes.EMAIL.name
AmplifyOutputsData.Auth.UsernameAttributes.Username.name,
AmplifyOutputsData.Auth.UsernameAttributes.Email.name
),
Keys.userVerificationTypes to listOf(
AmplifyOutputsData.Auth.UserVerificationTypes.EMAIL.name,
AmplifyOutputsData.Auth.UserVerificationTypes.PHONE.name
AmplifyOutputsData.Auth.UserVerificationTypes.Email.name,
AmplifyOutputsData.Auth.UserVerificationTypes.PhoneNumber.name
),
Keys.unauthenticatedIdentitiesEnabled to true,
Keys.mfaConfiguration to AmplifyOutputsData.Auth.MfaConfiguration.OPTIONAL.name,
Expand Down Expand Up @@ -126,19 +126,19 @@ class AmplifyOutputsDataTest {
scopes shouldContainExactly listOf("scope1", "scope2")
redirectSignInUri shouldContainExactly listOf("https://oauth.com/signin")
redirectSignOutUri shouldContainExactly listOf("https://oauth.com/signout")
responseType shouldBe AmplifyOutputsData.Auth.Oauth.ResponseType.CODE
responseType shouldBe AmplifyOutputsData.Auth.Oauth.ResponseType.Code
}
standardRequiredAttributes shouldContainExactly listOf(
AuthUserAttributeKey.email(),
AuthUserAttributeKey.gender()
)
usernameAttributes shouldContainExactly listOf(
AmplifyOutputsData.Auth.UsernameAttributes.USERNAME,
AmplifyOutputsData.Auth.UsernameAttributes.EMAIL
AmplifyOutputsData.Auth.UsernameAttributes.Username,
AmplifyOutputsData.Auth.UsernameAttributes.Email
)
userVerificationTypes shouldContainExactly listOf(
AmplifyOutputsData.Auth.UserVerificationTypes.EMAIL,
AmplifyOutputsData.Auth.UserVerificationTypes.PHONE
AmplifyOutputsData.Auth.UserVerificationTypes.Email,
AmplifyOutputsData.Auth.UserVerificationTypes.PhoneNumber
)
unauthenticatedIdentitiesEnabled.shouldBeTrue()
mfaConfiguration shouldBe AmplifyOutputsData.Auth.MfaConfiguration.OPTIONAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class OauthBuilder : AmplifyOutputsData.Auth.Oauth {
override val redirectSignInUri: MutableList<String> = mutableListOf()
override val redirectSignOutUri: MutableList<String> = mutableListOf()
override var responseType: AmplifyOutputsData.Auth.Oauth.ResponseType =
AmplifyOutputsData.Auth.Oauth.ResponseType.CODE
AmplifyOutputsData.Auth.Oauth.ResponseType.Code
}

class GeoBuilder : AmplifyOutputsData.Geo {
Expand Down

0 comments on commit 6ae0bbb

Please sign in to comment.