-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(DataStore): dataStore cannot connect to model's sync subscription…
…s (AWS_LAMBDA auth type) #3549
- Loading branch information
Showing
18 changed files
with
974 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginV2Tests/Base/TestConfigHelper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
@testable import Amplify | ||
|
||
class TestConfigHelper { | ||
|
||
static func retrieveAmplifyConfiguration(forResource: String) throws -> AmplifyConfiguration { | ||
|
||
let data = try retrieve(forResource: forResource) | ||
return try AmplifyConfiguration.decodeAmplifyConfiguration(from: data) | ||
} | ||
|
||
static func retrieveCredentials(forResource: String) throws -> [String: String] { | ||
let data = try retrieve(forResource: forResource) | ||
|
||
let jsonOptional = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] | ||
guard let json = jsonOptional else { | ||
throw "Could not deserialize `\(forResource)` into JSON object" | ||
} | ||
|
||
return json | ||
} | ||
|
||
static func retrieve(forResource: String) throws -> Data { | ||
guard let path = Bundle(for: self).path(forResource: forResource, ofType: "json") else { | ||
throw "Could not retrieve configuration file: \(forResource)" | ||
} | ||
|
||
let url = URL(fileURLWithPath: path) | ||
return try Data(contentsOf: url) | ||
} | ||
} | ||
|
||
extension String { | ||
var withUUID: String { | ||
"\(self)-\(UUID().uuidString)" | ||
} | ||
} |
Oops, something went wrong.