Skip to content

Commit 8d213de

Browse files
authored
test(Auth): UserAttributes unit tests (#985)
* user attributes unit tests * fixed some errors Co-authored-by: Guo <[email protected]>
1 parent 6cc6a4d commit 8d213de

File tree

8 files changed

+1469
-81
lines changed

8 files changed

+1469
-81
lines changed

AmplifyPlugins/Auth/AWSCognitoAuthPlugin.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
B4F3EA4F243A782700F23296 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F3EA4C243A782700F23296 /* ViewController.swift */; };
150150
B4F3EA50243A782700F23296 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F3EA4D243A782700F23296 /* AppDelegate.swift */; };
151151
B4F3EA51243A782700F23296 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F3EA4E243A782700F23296 /* SceneDelegate.swift */; };
152+
D828362C2590527F0016173F /* BaseUserBehaviorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D828362B2590527F0016173F /* BaseUserBehaviorTest.swift */; };
152153
D87D5864257EF27E004617B3 /* BaseAuthDeviceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D87D5863257EF27E004617B3 /* BaseAuthDeviceTest.swift */; };
153154
FA1C817D25868C46006160E9 /* AWSCognitoAuthPluginAmplifyVersionableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA1C817C25868C46006160E9 /* AWSCognitoAuthPluginAmplifyVersionableTests.swift */; };
154155
FA6B0EA8249443C90062AA59 /* AWSCognitoAuthPluginConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6B0EA7249443C90062AA59 /* AWSCognitoAuthPluginConfigTests.swift */; };
@@ -350,6 +351,7 @@
350351
B4F3EA4E243A782700F23296 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
351352
C49A4C812B0F973F5536DCC8 /* Pods-AWSAuthPlugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AWSAuthPlugin.release.xcconfig"; path = "Target Support Files/Pods-AWSAuthPlugin/Pods-AWSAuthPlugin.release.xcconfig"; sourceTree = "<group>"; };
352353
C5E50D8021B9740CB511898D /* Pods-AWSAuthPlugin.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AWSAuthPlugin.debug.xcconfig"; path = "Target Support Files/Pods-AWSAuthPlugin/Pods-AWSAuthPlugin.debug.xcconfig"; sourceTree = "<group>"; };
354+
D828362B2590527F0016173F /* BaseUserBehaviorTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseUserBehaviorTest.swift; sourceTree = "<group>"; };
353355
D87D5863257EF27E004617B3 /* BaseAuthDeviceTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseAuthDeviceTest.swift; sourceTree = "<group>"; };
354356
E9289652B314AA0AA1F31BC8 /* Pods-HostApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HostApp.release.xcconfig"; path = "Target Support Files/Pods-HostApp/Pods-HostApp.release.xcconfig"; sourceTree = "<group>"; };
355357
FA1C817C25868C46006160E9 /* AWSCognitoAuthPluginAmplifyVersionableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSCognitoAuthPluginAmplifyVersionableTests.swift; sourceTree = "<group>"; };
@@ -537,6 +539,7 @@
537539
B4136E6B256D7AF30011210B /* UserBehaviorFetchAttributeTests.swift */,
538540
B4136E7B256D7B240011210B /* UserBehaviorResendCodeTests.swift */,
539541
B4136E75256D7B090011210B /* UserBehaviorUpdateAttributeTests.swift */,
542+
D828362B2590527F0016173F /* BaseUserBehaviorTest.swift */,
540543
);
541544
path = AuthUserBehaviorTests;
542545
sourceTree = "<group>";
@@ -1529,6 +1532,7 @@
15291532
B4136E20256D757C0011210B /* AuthenticationProviderConfirmSignupTests.swift in Sources */,
15301533
B4136E3E256D76960011210B /* AuthenticationProviderSignoutTests.swift in Sources */,
15311534
B4136E5E256D7A690011210B /* AuthorizationProviderSessionSignInTests.swift in Sources */,
1535+
D828362C2590527F0016173F /* BaseUserBehaviorTest.swift in Sources */,
15321536
B43B4E242565FEC3008F345D /* AWSCognitoAuthUserBehaviorTests.swift in Sources */,
15331537
);
15341538
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright 2018-2020 Amazon.com,
3+
// Inc. or its affiliates. All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import XCTest
9+
@testable import Amplify
10+
@testable import AWSCognitoAuthPlugin
11+
@testable import AWSMobileClient
12+
13+
class BaseUserBehaviorTest: XCTestCase {
14+
15+
let apiTimeout = 2.0
16+
var authUserService: AuthUserServiceAdapter!
17+
var mockAWSMobileClient: MockAWSMobileClient!
18+
var plugin: AWSCognitoAuthPlugin!
19+
20+
override func setUp() {
21+
mockAWSMobileClient = MockAWSMobileClient()
22+
authUserService = AuthUserServiceAdapter(awsMobileClient: mockAWSMobileClient!)
23+
plugin = AWSCognitoAuthPlugin()
24+
plugin?.configure(authenticationProvider: MockAuthenticationProviderBehavior(),
25+
authorizationProvider: MockAuthorizationProviderBehavior(),
26+
userService: authUserService,
27+
deviceService: MockAuthDeviceServiceBehavior(),
28+
hubEventHandler: MockAuthHubEventBehavior())
29+
}
30+
31+
override func tearDown() {
32+
plugin = nil
33+
mockAWSMobileClient = nil
34+
authUserService = nil
35+
}
36+
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginTests/AuthUserBehaviorTests/UserBehaviorChangePasswordTests.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ import XCTest
1212
@testable import AWSCognitoAuthPlugin
1313
@testable import AWSMobileClient
1414

15-
class UserBehaviorChangePasswordTests: XCTestCase {
15+
class UserBehaviorChangePasswordTests: BaseUserBehaviorTest {
1616

17-
var authenticationProvider: AuthenticationProviderAdapter!
18-
var mockAWSMobileClient: MockAWSMobileClient!
19-
var plugin: AWSCognitoAuthPlugin!
20-
21-
override func setUp() {
22-
mockAWSMobileClient = MockAWSMobileClient()
23-
authenticationProvider = AuthenticationProviderAdapter(awsMobileClient: mockAWSMobileClient!)
24-
plugin = AWSCognitoAuthPlugin()
25-
plugin?.configure(authenticationProvider: authenticationProvider,
26-
authorizationProvider: MockAuthorizationProviderBehavior(),
27-
userService: MockAuthUserServiceBehavior(),
28-
deviceService: MockAuthDeviceServiceBehavior(),
29-
hubEventHandler: MockAuthHubEventBehavior())
30-
}
3117
}

0 commit comments

Comments
 (0)