-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move subscription headers to protocol
- Loading branch information
1 parent
32c5043
commit 9ad62cd
Showing
5 changed files
with
160 additions
and
31 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
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
37 changes: 37 additions & 0 deletions
37
packages/api/amplify_api_dart/test/web_socket/web_socket_service_test.dart
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,37 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'dart:convert'; | ||
|
||
import 'package:amplify_api_dart/src/graphql/providers/app_sync_api_key_auth_provider.dart'; | ||
import 'package:amplify_api_dart/src/graphql/web_socket/services/web_socket_service.dart'; | ||
import 'package:amplify_core/amplify_core.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../util.dart'; | ||
|
||
void main() { | ||
group('AmplifyWebSocketService', () { | ||
group('generateProtocols', () {}); | ||
const apiKey = 'fake-key'; | ||
test('should generate a protocol that includes the appropriate headers', | ||
() async { | ||
final (outputs, repo) = createOutputsAndRepo( | ||
AppSyncApiKeyAuthProvider(), | ||
APIAuthorizationType.apiKey, | ||
apiKey, | ||
); | ||
final service = AmplifyWebSocketService(); | ||
final protocols = await service.generateProtocols(outputs, repo); | ||
final encodedHeaders = protocols[1].replaceFirst('header-', ''); | ||
final headers = json.decode( | ||
String.fromCharCodes(base64Url.decode(encodedHeaders)), | ||
) as Map<String, dynamic>; | ||
expect(headers[xApiKey], apiKey); | ||
expect(headers.containsKey(AWSHeaders.accept), true); | ||
expect(headers.containsKey(AWSHeaders.contentEncoding), true); | ||
expect(headers.containsKey(AWSHeaders.contentType), true); | ||
expect(headers.containsKey(AWSHeaders.host), true); | ||
}); | ||
}); | ||
} |