Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f316f03
refactor feature testing fw
sktimalsina Oct 27, 2022
2831773
documentation and move verify to test
sktimalsina Oct 30, 2022
aeaf9b2
added fetchAuthSession test case generator
Nov 2, 2022
0a8911e
add new default serializer and fix options
sktimalsina Nov 2, 2022
6401b4f
fix serializer for AuthSessionResult and success test case
sktimalsina Nov 3, 2022
b339cd3
add generated test case
sktimalsina Nov 3, 2022
1f5040e
Merge branch 'dev-preview' into feature/banji/test-case-generator
sktimalsina Nov 3, 2022
c9537ff
added fetchAuthSession test case generator
Nov 4, 2022
ef1474c
Merge remote-tracking branch 'origin/dev-preview' into feature/banji/…
Nov 4, 2022
6b68575
Merge branch 'dev-preview' into feature/banji/test-case-generator
sktimalsina Nov 4, 2022
10cc6e1
Merge branch 'dev-preview' into feature/banji/test-case-generator
div5yesh Nov 4, 2022
f1791cf
added fetchAuthSession test case generator for different auth flow types
Nov 4, 2022
2d6586a
Merge remote-tracking branch 'origin/feature/banji/test-case-generato…
Nov 4, 2022
26305a2
Merge branch 'dev-preview' into feature/banji/test-case-generator
banji180 Nov 7, 2022
03d2d0b
added fetchAuthSession test case generator for different auth flow types
Nov 7, 2022
429ac40
Merge remote-tracking branch 'origin/feature/banji/test-case-generato…
Nov 7, 2022
d083490
Merge remote-tracking branch 'origin/dev-preview' into feature/banji/…
Nov 7, 2022
80d2e33
Merge branch 'main' into feature/banji/test-case-generator
sktimalsina Nov 8, 2022
ebddbd4
added GetCurrentUserTestCaseGenerator
Nov 9, 2022
a083f50
Merge branch 'main' into feature/banji/test-case-generator
div5yesh Nov 9, 2022
e31feda
added GetCurrentUserTestCaseGenerator
Nov 9, 2022
11b3b54
Merge remote-tracking branch 'origin/feature/banji/test-case-generato…
Nov 9, 2022
3eba5a4
added GetCurrentUserTestCaseGenerator
Nov 10, 2022
294cb4e
fix(auth): Fix State Machine token race condition (#2100)
mattcreaser Nov 10, 2022
a87e9ad
Update release_pr.yml (#2105)
div5yesh Nov 10, 2022
9d6a48d
chore: add retries to identify flaky tests (#2099)
sktimalsina Nov 11, 2022
175c3a4
fix: Errors across storage and analytics category (#2096)
sdhuka Nov 11, 2022
af1693d
fix(auth): Fix authFlowType getter annotation and correct for null sa…
tylerjroach Nov 14, 2022
5c63566
fix(auth): add missing client and analytics metadata (#2110)
div5yesh Nov 15, 2022
acf8930
fix: callbacks not invoked when attached using getTransfer api (#2111)
sdhuka Nov 15, 2022
1bbdc48
Prevent attempting to read backed up EncryptedSharedPreferences that …
tylerjroach Nov 15, 2022
e69c425
fix(auth): device metadata migration (#2114)
div5yesh Nov 15, 2022
17ca43a
Number of attributes being too high is not retryable (#2112)
tjleing Nov 16, 2022
d57749f
Change errors returned on some apis while federated (#2116)
tylerjroach Nov 16, 2022
b4b539b
release: Amplify Android 2.0.0 (#2115)
sktimalsina Nov 16, 2022
cb8b1f8
Merge remote-tracking branch 'origin/main' into feature/banji/test-ca…
Nov 22, 2022
ab549ff
Merge remote-tracking branch 'origin/main' into feature/banji/test-ca…
Nov 28, 2022
de8631b
added test case generators for forgot and remember device auth calls
Dec 7, 2022
2eeab44
fixed test issue with overloaded auth api functions
Dec 12, 2022
476b22f
Merge branch 'main' into feature/banji/test-case-generator
banji180 Dec 12, 2022
3470e9e
Added tests to captor factory
Dec 12, 2022
a0ac6a7
Added license to classes
Dec 15, 2022
2378ba7
Added error case to reset password test case generator
Dec 15, 2022
00e8316
Merge branch 'main' into feature/banji/test-case-generator
banji180 Dec 15, 2022
fa75c11
Merge branch 'main' into feature/banji/test-case-generator
gpanshu Dec 15, 2022
715e075
Merge branch 'main' into feature/banji/test-case-generator
banji180 Dec 17, 2022
5cc1ec4
fixed lint issue
Dec 17, 2022
2622d8c
added json files
Dec 22, 2022
aaffd84
Merge branch 'main' into feature/banji/test-case-generator
banji180 Dec 22, 2022
4cdedf6
added missing json files
Dec 22, 2022
55ab30d
added missing json files
Dec 22, 2022
a5939c1
Merge branch 'main' into feature/banji/test-case-generator
banji180 Jan 3, 2023
e254c3f
Merge branch 'main' into feature/banji/test-case-generator
banji180 Jan 4, 2023
15aeba1
Merge branch 'main' into feature/banji/test-case-generator
banji180 Jan 5, 2023
a951cb3
empty
Jan 5, 2023
b93fa7c
empty commit
Jan 9, 2023
91bb45a
Merge branch 'main' into feature/banji/test-case-generator
awsmobilesdk Jan 26, 2023
75771ff
Merge branch 'main' into feature/banji/test-case-generator
banji180 Jan 31, 2023
67e1dc6
Merge branch 'main' into feature/banji/test-case-generator
banji180 Jan 31, 2023
074e708
Merge remote-tracking branch 'origin/main' into feature/banji/test-ca…
Jan 31, 2023
4272a44
Updated year in new files
Feb 1, 2023
5467d68
Merge branch 'main' into feature/banji/test-case-generator
banji180 Feb 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import com.amplifyframework.auth.cognito.featuretest.generators.authstategenerat
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.ConfirmSignInTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.DeleteUserTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.FetchAuthSessionTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.FetchDevicesTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.FetchUserAttributesTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.ForgetDeviceTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.RememberDeviceTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.ResetPasswordTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.SignInTestCaseGenerator
import com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators.SignOutTestCaseGenerator
Expand All @@ -43,6 +47,10 @@ object JsonGenerator {
ConfirmSignInTestCaseGenerator,
DeleteUserTestCaseGenerator,
FetchAuthSessionTestCaseGenerator,
RememberDeviceTestCaseGenerator,
ForgetDeviceTestCaseGenerator,
FetchDevicesTestCaseGenerator,
FetchUserAttributesTestCaseGenerator,
)

fun generate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators

import com.amplifyframework.auth.AWSCredentials
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators

import aws.sdk.kotlin.services.cognitoidentityprovider.model.AttributeType
import aws.sdk.kotlin.services.cognitoidentityprovider.model.DeviceType
import aws.smithy.kotlin.runtime.time.Instant
import com.amplifyframework.auth.AuthDevice
import com.amplifyframework.auth.cognito.featuretest.API
import com.amplifyframework.auth.cognito.featuretest.AuthAPI
import com.amplifyframework.auth.cognito.featuretest.CognitoType
import com.amplifyframework.auth.cognito.featuretest.ExpectationShapes
import com.amplifyframework.auth.cognito.featuretest.FeatureTestCase
import com.amplifyframework.auth.cognito.featuretest.MockResponse
import com.amplifyframework.auth.cognito.featuretest.PreConditions
import com.amplifyframework.auth.cognito.featuretest.ResponseType
import com.amplifyframework.auth.cognito.featuretest.generators.SerializableProvider
import com.amplifyframework.auth.cognito.featuretest.generators.toJsonElement
import com.amplifyframework.auth.exceptions.SignedOutException
import kotlinx.serialization.json.JsonObject

object FetchDevicesTestCaseGenerator : SerializableProvider {

private val expectedSuccess = listOf<AuthDevice>(AuthDevice.fromId("deviceKey")).toJsonElement()

private val mockCognitoResponse = MockResponse(
CognitoType.CognitoIdentityProvider,
"listDevices",
ResponseType.Success,
mapOf(
"devices" to listOf<DeviceType>(
DeviceType.invoke {
deviceAttributes = listOf<AttributeType>(
AttributeType.invoke {
name = "name"
value = "value"
}
)
deviceKey = "deviceKey"
deviceCreateDate = Instant.now()
deviceLastAuthenticatedDate = Instant.now()
deviceLastModifiedDate = Instant.now()
}
)
).toJsonElement()
)

private val apiReturnValidation = ExpectationShapes.Amplify(
AuthAPI.fetchDevices,
ResponseType.Success,
expectedSuccess,
)

private val baseCase = FeatureTestCase(
description = "Test that Cognito is called with given payload and returns successful data",
preConditions = PreConditions(
"authconfiguration.json",
"SignedIn_SessionEstablished.json",
mockedResponses = listOf(mockCognitoResponse)
),
api = API(
AuthAPI.fetchDevices,
JsonObject(emptyMap()),
JsonObject(emptyMap()),
),
validations = listOf(apiReturnValidation)
)

private val successCase: FeatureTestCase = baseCase.copy(
description = "List of devices returned when fetch devices API succeeds",
preConditions = baseCase.preConditions.copy(mockedResponses = listOf(mockCognitoResponse)),
validations = baseCase.validations.plus(apiReturnValidation)
)

private val errorCase: FeatureTestCase
get() {
val errorResponse = SignedOutException()
return baseCase.copy(
description = "AuthException is thrown when forgetDevice API is called without signing in",
preConditions = baseCase.preConditions.copy(
state = "SignedOut_Configured.json",
mockedResponses = listOf(
MockResponse(
CognitoType.CognitoIdentityProvider,
"forgetDevice",
ResponseType.Failure,
errorResponse.toJsonElement()
)
)
),
validations = listOf(
ExpectationShapes.Amplify(
AuthAPI.forgetDevice,
ResponseType.Failure,
com.amplifyframework.auth.exceptions.SignedOutException().toJsonElement(),
)
)
)
}

override val serializables: List<Any> = listOf(baseCase, errorCase, successCase)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators
import aws.sdk.kotlin.services.cognitoidentityprovider.model.AttributeType
import com.amplifyframework.auth.AuthUserAttribute
import com.amplifyframework.auth.AuthUserAttributeKey
import com.amplifyframework.auth.cognito.featuretest.API
import com.amplifyframework.auth.cognito.featuretest.AuthAPI
import com.amplifyframework.auth.cognito.featuretest.CognitoType
import com.amplifyframework.auth.cognito.featuretest.ExpectationShapes
import com.amplifyframework.auth.cognito.featuretest.FeatureTestCase
import com.amplifyframework.auth.cognito.featuretest.MockResponse
import com.amplifyframework.auth.cognito.featuretest.PreConditions
import com.amplifyframework.auth.cognito.featuretest.ResponseType
import com.amplifyframework.auth.cognito.featuretest.generators.SerializableProvider
import com.amplifyframework.auth.cognito.featuretest.generators.toJsonElement
import com.amplifyframework.auth.exceptions.SignedOutException
import kotlinx.serialization.json.JsonObject

object FetchUserAttributesTestCaseGenerator : SerializableProvider {

private val expectedSuccess = listOf<AuthUserAttribute>(
AuthUserAttribute(AuthUserAttributeKey.email(), "[email protected]"),
AuthUserAttribute(AuthUserAttributeKey.phoneNumber(), "000-000-0000")
).toJsonElement()

private val mockCognitoResponse = MockResponse(
CognitoType.CognitoIdentityProvider,
"getUser",
ResponseType.Success,
mapOf(
"userAttributes" to listOf<AttributeType>(
AttributeType.invoke {
name = "email"
value = "[email protected]"
},
AttributeType.invoke {
name = "phone"
value = "000-000-0000"
}
)
).toJsonElement()
)

private val apiReturnValidation = ExpectationShapes.Amplify(
AuthAPI.fetchUserAttributes,
ResponseType.Success,
expectedSuccess,
)

private val baseCase = FeatureTestCase(
description = "Test that Cognito is called with given payload and returns successful data",
preConditions = PreConditions(
"authconfiguration.json",
"SignedIn_SessionEstablished.json",
mockedResponses = listOf(mockCognitoResponse)
),
api = API(
AuthAPI.fetchUserAttributes,
JsonObject(emptyMap()),
JsonObject(emptyMap()),
),
validations = listOf(apiReturnValidation)
)

private val successCase: FeatureTestCase = baseCase.copy(
description = "List of user attributes returned when fetch user attributes API succeeds",
preConditions = baseCase.preConditions.copy(mockedResponses = listOf(mockCognitoResponse)),
validations = baseCase.validations.plus(apiReturnValidation)
)

private val errorCase: FeatureTestCase
get() {
val errorResponse = SignedOutException()
return baseCase.copy(
description = "AuthException is thrown when fetchUserAttributes API is called without signing in",
preConditions = baseCase.preConditions.copy(
state = "SignedOut_Configured.json",
mockedResponses = listOf(
MockResponse(
CognitoType.CognitoIdentityProvider,
"getUser",
ResponseType.Failure,
errorResponse.toJsonElement()
)
)
),
validations = listOf(
ExpectationShapes.Amplify(
AuthAPI.fetchUserAttributes,
ResponseType.Failure,
SignedOutException().toJsonElement(),
)
)
)
}

override val serializables: List<Any> = listOf(baseCase, errorCase, successCase)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators

import com.amplifyframework.auth.AuthDevice
import com.amplifyframework.auth.cognito.featuretest.API
import com.amplifyframework.auth.cognito.featuretest.AuthAPI
import com.amplifyframework.auth.cognito.featuretest.CognitoType
import com.amplifyframework.auth.cognito.featuretest.ExpectationShapes
import com.amplifyframework.auth.cognito.featuretest.FeatureTestCase
import com.amplifyframework.auth.cognito.featuretest.MockResponse
import com.amplifyframework.auth.cognito.featuretest.PreConditions
import com.amplifyframework.auth.cognito.featuretest.ResponseType
import com.amplifyframework.auth.cognito.featuretest.generators.SerializableProvider
import com.amplifyframework.auth.cognito.featuretest.generators.toJsonElement
import com.amplifyframework.auth.exceptions.SignedOutException
import kotlinx.serialization.json.JsonObject

object ForgetDeviceTestCaseGenerator : SerializableProvider {
private val mockCognitoResponse = MockResponse(
CognitoType.CognitoIdentityProvider,
"updateDeviceStatus",
ResponseType.Success,
JsonObject(emptyMap())
)

private val apiReturnValidation = ExpectationShapes.Amplify(
AuthAPI.forgetDevice,
ResponseType.Success,
JsonObject(emptyMap()),
)

private val baseCase = FeatureTestCase(
description = "Test that Cognito is called with given payload and returns successful data",
preConditions = PreConditions(
"authconfiguration.json",
"SignedIn_SessionEstablished.json",
mockedResponses = listOf(mockCognitoResponse)
),
api = API(
AuthAPI.forgetDevice,
mapOf(
"device" to AuthDevice.fromId("id", "test")
).toJsonElement(),
JsonObject(emptyMap()),
),
validations = listOf(apiReturnValidation)
)

private val successCase: FeatureTestCase = baseCase.copy(
description = "Nothing is returned when forget device succeeds",
preConditions = baseCase.preConditions.copy(mockedResponses = listOf(mockCognitoResponse)),
validations = baseCase.validations.plus(apiReturnValidation)
)

private val errorCase: FeatureTestCase
get() {
val errorResponse = SignedOutException()
return baseCase.copy(
description = "AuthException is thrown when forgetDevice API is called without signing in",
preConditions = baseCase.preConditions.copy(
state = "SignedOut_Configured.json",
mockedResponses = listOf(
MockResponse(
CognitoType.CognitoIdentityProvider,
"forgetDevice",
ResponseType.Failure,
errorResponse.toJsonElement()
)
)
),
validations = listOf(
ExpectationShapes.Amplify(
AuthAPI.forgetDevice,
ResponseType.Failure,
SignedOutException().toJsonElement(),
)
)
)
}

override val serializables: List<Any> = listOf(baseCase, errorCase, successCase)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.featuretest.generators.testcasegenerators

import aws.sdk.kotlin.services.cognitoidentityprovider.model.NotAuthorizedException
Expand Down
Loading