Skip to content

Commit b96fbda

Browse files
committed
fix(DataStore): dataStore cannot connect to model's sync subscriptions (AWS_LAMBDA auth type) #3549
1 parent 358699c commit b96fbda

File tree

18 files changed

+974
-9
lines changed

18 files changed

+974
-9
lines changed

AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/project.pbxproj

+184-1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,17 @@
353353
97914C1E29558AF2002000EA /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 97914C1D29558AF2002000EA /* README.md */; };
354354
97D4946D2981AF9900397C75 /* AuthSignInHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D4946B2981AF9900397C75 /* AuthSignInHelper.swift */; };
355355
97D4946E2981AF9900397C75 /* TestConfigHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D4946C2981AF9900397C75 /* TestConfigHelper.swift */; };
356+
D86FBA2B2B95FEBA00024BAC /* GraphQLSubscriptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA2A2B95FEBA00024BAC /* GraphQLSubscriptionsTests.swift */; };
357+
D86FBA362B96216000024BAC /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = D86FBA352B96216000024BAC /* README.md */; };
358+
D86FBA382B9624B800024BAC /* schema.graphql in Resources */ = {isa = PBXBuildFile; fileRef = D86FBA372B9624B800024BAC /* schema.graphql */; };
359+
D86FBA562B9634D400024BAC /* TestConfigHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA542B9634D300024BAC /* TestConfigHelper.swift */; };
360+
D86FBA5E2B96350D00024BAC /* Comment+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA572B96350D00024BAC /* Comment+Schema.swift */; };
361+
D86FBA5F2B96350D00024BAC /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA582B96350D00024BAC /* Comment.swift */; };
362+
D86FBA602B96350D00024BAC /* Blog+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA592B96350D00024BAC /* Blog+Schema.swift */; };
363+
D86FBA612B96350D00024BAC /* Blog.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA5A2B96350D00024BAC /* Blog.swift */; };
364+
D86FBA622B96350D00024BAC /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA5B2B96350D00024BAC /* Post.swift */; };
365+
D86FBA632B96350D00024BAC /* Post+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA5C2B96350D00024BAC /* Post+Schema.swift */; };
366+
D86FBA642B96350D00024BAC /* AmplifyModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FBA5D2B96350D00024BAC /* AmplifyModels.swift */; };
356367
/* End PBXBuildFile section */
357368

358369
/* Begin PBXContainerItemProxy section */
@@ -440,6 +451,13 @@
440451
remoteGlobalIDString = 21E73E6A28898D7800D7DB7E;
441452
remoteInfo = APIHostApp;
442453
};
454+
D86FBA2C2B95FEBA00024BAC /* PBXContainerItemProxy */ = {
455+
isa = PBXContainerItemProxy;
456+
containerPortal = 21E73E6328898D7800D7DB7E /* Project object */;
457+
proxyType = 1;
458+
remoteGlobalIDString = 21E73E6A28898D7800D7DB7E;
459+
remoteInfo = APIHostApp;
460+
};
443461
/* End PBXContainerItemProxy section */
444462

445463
/* Begin PBXFileReference section */
@@ -692,6 +710,18 @@
692710
97914C1D29558AF2002000EA /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
693711
97D4946B2981AF9900397C75 /* AuthSignInHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthSignInHelper.swift; sourceTree = "<group>"; };
694712
97D4946C2981AF9900397C75 /* TestConfigHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestConfigHelper.swift; sourceTree = "<group>"; };
713+
D86FBA282B95FEBA00024BAC /* AWSAPIPluginV2Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AWSAPIPluginV2Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
714+
D86FBA2A2B95FEBA00024BAC /* GraphQLSubscriptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphQLSubscriptionsTests.swift; sourceTree = "<group>"; };
715+
D86FBA352B96216000024BAC /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
716+
D86FBA372B9624B800024BAC /* schema.graphql */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = schema.graphql; sourceTree = "<group>"; };
717+
D86FBA542B9634D300024BAC /* TestConfigHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestConfigHelper.swift; sourceTree = "<group>"; };
718+
D86FBA572B96350D00024BAC /* Comment+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Comment+Schema.swift"; sourceTree = "<group>"; };
719+
D86FBA582B96350D00024BAC /* Comment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Comment.swift; sourceTree = "<group>"; };
720+
D86FBA592B96350D00024BAC /* Blog+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Blog+Schema.swift"; sourceTree = "<group>"; };
721+
D86FBA5A2B96350D00024BAC /* Blog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Blog.swift; sourceTree = "<group>"; };
722+
D86FBA5B2B96350D00024BAC /* Post.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = "<group>"; };
723+
D86FBA5C2B96350D00024BAC /* Post+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Post+Schema.swift"; sourceTree = "<group>"; };
724+
D86FBA5D2B96350D00024BAC /* AmplifyModels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmplifyModels.swift; sourceTree = "<group>"; };
695725
/* End PBXFileReference section */
696726

697727
/* Begin PBXFrameworksBuildPhase section */
@@ -810,6 +840,13 @@
810840
);
811841
runOnlyForDeploymentPostprocessing = 0;
812842
};
843+
D86FBA252B95FEBA00024BAC /* Frameworks */ = {
844+
isa = PBXFrameworksBuildPhase;
845+
buildActionMask = 2147483647;
846+
files = (
847+
);
848+
runOnlyForDeploymentPostprocessing = 0;
849+
};
813850
/* End PBXFrameworksBuildPhase section */
814851

815852
/* Begin PBXGroup section */
@@ -1164,8 +1201,10 @@
11641201
395906C128AC63A9004B96B1 /* AWSAPIPluginRESTUserPoolTests */,
11651202
97914BC429558714002000EA /* GraphQLAPIStressTests */,
11661203
21EA887428F9BC600000BA75 /* AWSAPIPluginLazyLoadTests */,
1204+
D86FBA292B95FEBA00024BAC /* AWSAPIPluginV2Tests */,
11671205
21E73E6C28898D7900D7DB7E /* Products */,
11681206
21698BD728899EBB004BD994 /* Frameworks */,
1207+
39AC502FEC3F482AF1545BE2 /* AmplifyConfig */,
11691208
);
11701209
sourceTree = "<group>";
11711210
};
@@ -1186,6 +1225,7 @@
11861225
681B35892A43962D0074F369 /* AWSAPIPluginFunctionalTestsWatch.xctest */,
11871226
681B35A12A4396CF0074F369 /* AWSAPIPluginGraphQLLambdaAuthTestsWatch.xctest */,
11881227
681B35C52A43970A0074F369 /* AWSAPIPluginRESTIAMTestsWatch.xctest */,
1228+
D86FBA282B95FEBA00024BAC /* AWSAPIPluginV2Tests.xctest */,
11891229
);
11901230
name = Products;
11911231
sourceTree = "<group>";
@@ -1405,6 +1445,40 @@
14051445
path = Base;
14061446
sourceTree = "<group>";
14071447
};
1448+
D86FBA292B95FEBA00024BAC /* AWSAPIPluginV2Tests */ = {
1449+
isa = PBXGroup;
1450+
children = (
1451+
D86FBA532B9634D300024BAC /* Base */,
1452+
D86FBA552B9634D400024BAC /* Models */,
1453+
D86FBA372B9624B800024BAC /* schema.graphql */,
1454+
D86FBA352B96216000024BAC /* README.md */,
1455+
D86FBA2A2B95FEBA00024BAC /* GraphQLSubscriptionsTests.swift */,
1456+
);
1457+
path = AWSAPIPluginV2Tests;
1458+
sourceTree = "<group>";
1459+
};
1460+
D86FBA532B9634D300024BAC /* Base */ = {
1461+
isa = PBXGroup;
1462+
children = (
1463+
D86FBA542B9634D300024BAC /* TestConfigHelper.swift */,
1464+
);
1465+
path = Base;
1466+
sourceTree = "<group>";
1467+
};
1468+
D86FBA552B9634D400024BAC /* Models */ = {
1469+
isa = PBXGroup;
1470+
children = (
1471+
D86FBA5D2B96350D00024BAC /* AmplifyModels.swift */,
1472+
D86FBA5A2B96350D00024BAC /* Blog.swift */,
1473+
D86FBA592B96350D00024BAC /* Blog+Schema.swift */,
1474+
D86FBA582B96350D00024BAC /* Comment.swift */,
1475+
D86FBA572B96350D00024BAC /* Comment+Schema.swift */,
1476+
D86FBA5B2B96350D00024BAC /* Post.swift */,
1477+
D86FBA5C2B96350D00024BAC /* Post+Schema.swift */,
1478+
);
1479+
path = Models;
1480+
sourceTree = "<group>";
1481+
};
14081482
/* End PBXGroup section */
14091483

14101484
/* Begin PBXNativeTarget section */
@@ -1696,14 +1770,32 @@
16961770
productReference = 97914C182955872A002000EA /* GraphQLAPIStressTests.xctest */;
16971771
productType = "com.apple.product-type.bundle.unit-test";
16981772
};
1773+
D86FBA272B95FEBA00024BAC /* AWSAPIPluginV2Tests */ = {
1774+
isa = PBXNativeTarget;
1775+
buildConfigurationList = D86FBA302B95FEBA00024BAC /* Build configuration list for PBXNativeTarget "AWSAPIPluginV2Tests" */;
1776+
buildPhases = (
1777+
D86FBA242B95FEBA00024BAC /* Sources */,
1778+
D86FBA252B95FEBA00024BAC /* Frameworks */,
1779+
D86FBA262B95FEBA00024BAC /* Resources */,
1780+
);
1781+
buildRules = (
1782+
);
1783+
dependencies = (
1784+
D86FBA2D2B95FEBA00024BAC /* PBXTargetDependency */,
1785+
);
1786+
name = AWSAPIPluginV2Tests;
1787+
productName = AWSAPIPluginV2Tests;
1788+
productReference = D86FBA282B95FEBA00024BAC /* AWSAPIPluginV2Tests.xctest */;
1789+
productType = "com.apple.product-type.bundle.unit-test";
1790+
};
16991791
/* End PBXNativeTarget section */
17001792

17011793
/* Begin PBXProject section */
17021794
21E73E6328898D7800D7DB7E /* Project object */ = {
17031795
isa = PBXProject;
17041796
attributes = {
17051797
BuildIndependentTargetsInParallel = 1;
1706-
LastSwiftUpdateCheck = 1430;
1798+
LastSwiftUpdateCheck = 1520;
17071799
LastUpgradeCheck = 1340;
17081800
TargetAttributes = {
17091801
213DBC7428A6C47000B30280 = {
@@ -1755,6 +1847,10 @@
17551847
681B35B62A43970A0074F369 = {
17561848
TestTargetID = 681B35282A4395730074F369;
17571849
};
1850+
D86FBA272B95FEBA00024BAC = {
1851+
CreatedOnToolsVersion = 15.2;
1852+
TestTargetID = 21E73E6A28898D7800D7DB7E;
1853+
};
17581854
};
17591855
};
17601856
buildConfigurationList = 21E73E6628898D7800D7DB7E /* Build configuration list for PBXProject "APIHostApp" */;
@@ -1787,6 +1883,7 @@
17871883
681B353E2A43962D0074F369 /* AWSAPIPluginFunctionalTestsWatch */,
17881884
681B35912A4396CF0074F369 /* AWSAPIPluginGraphQLLambdaAuthTestsWatch */,
17891885
681B35B62A43970A0074F369 /* AWSAPIPluginRESTIAMTestsWatch */,
1886+
D86FBA272B95FEBA00024BAC /* AWSAPIPluginV2Tests */,
17901887
);
17911888
};
17921889
/* End PBXProject section */
@@ -1893,6 +1990,15 @@
18931990
);
18941991
runOnlyForDeploymentPostprocessing = 0;
18951992
};
1993+
D86FBA262B95FEBA00024BAC /* Resources */ = {
1994+
isa = PBXResourcesBuildPhase;
1995+
buildActionMask = 2147483647;
1996+
files = (
1997+
D86FBA382B9624B800024BAC /* schema.graphql in Resources */,
1998+
D86FBA362B96216000024BAC /* README.md in Resources */,
1999+
);
2000+
runOnlyForDeploymentPostprocessing = 0;
2001+
};
18962002
/* End PBXResourcesBuildPhase section */
18972003

18982004
/* Begin PBXShellScriptBuildPhase section */
@@ -2539,6 +2645,22 @@
25392645
);
25402646
runOnlyForDeploymentPostprocessing = 0;
25412647
};
2648+
D86FBA242B95FEBA00024BAC /* Sources */ = {
2649+
isa = PBXSourcesBuildPhase;
2650+
buildActionMask = 2147483647;
2651+
files = (
2652+
D86FBA2B2B95FEBA00024BAC /* GraphQLSubscriptionsTests.swift in Sources */,
2653+
D86FBA562B9634D400024BAC /* TestConfigHelper.swift in Sources */,
2654+
D86FBA602B96350D00024BAC /* Blog+Schema.swift in Sources */,
2655+
D86FBA612B96350D00024BAC /* Blog.swift in Sources */,
2656+
D86FBA642B96350D00024BAC /* AmplifyModels.swift in Sources */,
2657+
D86FBA5E2B96350D00024BAC /* Comment+Schema.swift in Sources */,
2658+
D86FBA622B96350D00024BAC /* Post.swift in Sources */,
2659+
D86FBA632B96350D00024BAC /* Post+Schema.swift in Sources */,
2660+
D86FBA5F2B96350D00024BAC /* Comment.swift in Sources */,
2661+
);
2662+
runOnlyForDeploymentPostprocessing = 0;
2663+
};
25422664
/* End PBXSourcesBuildPhase section */
25432665

25442666
/* Begin PBXTargetDependency section */
@@ -2602,6 +2724,11 @@
26022724
target = 21E73E6A28898D7800D7DB7E /* APIHostApp */;
26032725
targetProxy = 97914BCE2955872A002000EA /* PBXContainerItemProxy */;
26042726
};
2727+
D86FBA2D2B95FEBA00024BAC /* PBXTargetDependency */ = {
2728+
isa = PBXTargetDependency;
2729+
target = 21E73E6A28898D7800D7DB7E /* APIHostApp */;
2730+
targetProxy = D86FBA2C2B95FEBA00024BAC /* PBXContainerItemProxy */;
2731+
};
26052732
/* End PBXTargetDependency section */
26062733

26072734
/* Begin XCBuildConfiguration section */
@@ -3409,6 +3536,53 @@
34093536
};
34103537
name = Release;
34113538
};
3539+
D86FBA2E2B95FEBA00024BAC /* Debug */ = {
3540+
isa = XCBuildConfiguration;
3541+
buildSettings = {
3542+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
3543+
BUNDLE_LOADER = "$(TEST_HOST)";
3544+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
3545+
CODE_SIGN_STYLE = Automatic;
3546+
CURRENT_PROJECT_VERSION = 1;
3547+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
3548+
GCC_C_LANGUAGE_STANDARD = gnu17;
3549+
GENERATE_INFOPLIST_FILE = YES;
3550+
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
3551+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
3552+
MARKETING_VERSION = 1.0;
3553+
PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.api.AWSAPIPluginV2Tests;
3554+
PRODUCT_NAME = "$(TARGET_NAME)";
3555+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
3556+
SWIFT_EMIT_LOC_STRINGS = NO;
3557+
SWIFT_VERSION = 5.0;
3558+
TARGETED_DEVICE_FAMILY = "1,2";
3559+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/APIHostApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/APIHostApp";
3560+
};
3561+
name = Debug;
3562+
};
3563+
D86FBA2F2B95FEBA00024BAC /* Release */ = {
3564+
isa = XCBuildConfiguration;
3565+
buildSettings = {
3566+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
3567+
BUNDLE_LOADER = "$(TEST_HOST)";
3568+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
3569+
CODE_SIGN_STYLE = Automatic;
3570+
CURRENT_PROJECT_VERSION = 1;
3571+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
3572+
GCC_C_LANGUAGE_STANDARD = gnu17;
3573+
GENERATE_INFOPLIST_FILE = YES;
3574+
IPHONEOS_DEPLOYMENT_TARGET = 15.5;
3575+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
3576+
MARKETING_VERSION = 1.0;
3577+
PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.api.AWSAPIPluginV2Tests;
3578+
PRODUCT_NAME = "$(TARGET_NAME)";
3579+
SWIFT_EMIT_LOC_STRINGS = NO;
3580+
SWIFT_VERSION = 5.0;
3581+
TARGETED_DEVICE_FAMILY = "1,2";
3582+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/APIHostApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/APIHostApp";
3583+
};
3584+
name = Release;
3585+
};
34123586
/* End XCBuildConfiguration section */
34133587

34143588
/* Begin XCConfigurationList section */
@@ -3547,6 +3721,15 @@
35473721
defaultConfigurationIsVisible = 0;
35483722
defaultConfigurationName = Release;
35493723
};
3724+
D86FBA302B95FEBA00024BAC /* Build configuration list for PBXNativeTarget "AWSAPIPluginV2Tests" */ = {
3725+
isa = XCConfigurationList;
3726+
buildConfigurations = (
3727+
D86FBA2E2B95FEBA00024BAC /* Debug */,
3728+
D86FBA2F2B95FEBA00024BAC /* Release */,
3729+
);
3730+
defaultConfigurationIsVisible = 0;
3731+
defaultConfigurationName = Release;
3732+
};
35503733
/* End XCConfigurationList section */
35513734

35523735
/* Begin XCRemoteSwiftPackageReference section */

AmplifyPlugins/API/Tests/APIHostApp/APIHostApp.xcodeproj/xcshareddata/xcschemes/APIHostApp.xcscheme

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@
4949
ReferencedContainer = "container:APIHostApp.xcodeproj">
5050
</BuildableReference>
5151
</TestableReference>
52+
<TestableReference
53+
skipped = "NO"
54+
parallelizable = "YES">
55+
<BuildableReference
56+
BuildableIdentifier = "primary"
57+
BlueprintIdentifier = "D86FBA272B95FEBA00024BAC"
58+
BuildableName = "AWSAPIPluginV2Tests.xctest"
59+
BlueprintName = "AWSAPIPluginV2Tests"
60+
ReferencedContainer = "container:APIHostApp.xcodeproj">
61+
</BuildableReference>
62+
</TestableReference>
5263
</Testables>
5364
</TestAction>
5465
<LaunchAction
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
@testable import Amplify
10+
11+
class TestConfigHelper {
12+
13+
static func retrieveAmplifyConfiguration(forResource: String) throws -> AmplifyConfiguration {
14+
15+
let data = try retrieve(forResource: forResource)
16+
return try AmplifyConfiguration.decodeAmplifyConfiguration(from: data)
17+
}
18+
19+
static func retrieveCredentials(forResource: String) throws -> [String: String] {
20+
let data = try retrieve(forResource: forResource)
21+
22+
let jsonOptional = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String]
23+
guard let json = jsonOptional else {
24+
throw "Could not deserialize `\(forResource)` into JSON object"
25+
}
26+
27+
return json
28+
}
29+
30+
static func retrieve(forResource: String) throws -> Data {
31+
guard let path = Bundle(for: self).path(forResource: forResource, ofType: "json") else {
32+
throw "Could not retrieve configuration file: \(forResource)"
33+
}
34+
35+
let url = URL(fileURLWithPath: path)
36+
return try Data(contentsOf: url)
37+
}
38+
}
39+
40+
extension String {
41+
var withUUID: String {
42+
"\(self)-\(UUID().uuidString)"
43+
}
44+
}

0 commit comments

Comments
 (0)