Skip to content

Commit

Permalink
fix(data): fix library configuration options headers for subscriptions (
Browse files Browse the repository at this point in the history
  • Loading branch information
david-mcafee committed Dec 4, 2023
1 parent 271546d commit e101cea
Show file tree
Hide file tree
Showing 10 changed files with 952 additions and 13 deletions.
28 changes: 28 additions & 0 deletions packages/api-graphql/__tests__/AWSAppSyncRealTimeProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,34 @@ describe('AWSAppSyncRealTimeProvider', () => {
);
});

test('authenticating with userPool / custom library options token', async () => {
expect.assertions(1);

provider
.subscribe({
appSyncGraphqlEndpoint: 'ws://localhost:8080',
authenticationType: 'userPool',
/**
* When Amplify is configured with a `header` function
* that returns an `Authorization` token, the GraphQL
* API will pass this function as the `libraryConfigHeaders`
* option to the AWSAppSyncRealTimeProvider's `subscribe`
* function.
*/
libraryConfigHeaders: async () => ({
Authorization: 'test',
}),
})
.subscribe({ error: () => {} });

await fakeWebSocketInterface?.readyForUse;

expect(loggerSpy).toHaveBeenCalledWith(
'DEBUG',
'Authenticating with "userPool"'
);
});

test('authenticating with AWS_LAMBDA/custom w/ custom header function', async () => {
expect.assertions(1);

Expand Down

0 comments on commit e101cea

Please sign in to comment.