Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data): fix library configuration options headers for subscriptions (#12590) #12659

Merged
merged 17 commits into from
Dec 4, 2023
Merged
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
Loading
Loading