Skip to content

Commit 439f343

Browse files
authored
Added integration test to check that the API will return 401 error if invalid api key is used. (aws#131)
1 parent 526bc1a commit 439f343

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/TestCases/Case05/Case05.02.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { checkFolderContainsFiles, executeAppSyncQuery, unzipAndGetContents } from '../../testLib';
1+
import { checkFolderContainsFiles, executeAppSyncQuery, executeGraphQLQuery, unzipAndGetContents } from '../../testLib';
22
import fs from "fs";
33
import path from "path";
44

@@ -44,4 +44,15 @@ describe('Validate pipeline with http resolver output content', () => {
4444
const codes = results.data.getContinents.map(continent => continent.code).sort();
4545
expect(codes).toEqual(['AF', 'AN', 'AS', 'EU', 'NA', 'OC', 'SA']);
4646
}, 600000);
47+
48+
test('Should throw error if api key is invalid', async () => {
49+
const awsResources = JSON.parse(fs.readFileSync(path.join(outputFolderPath, 'AirportsJestTest-resources.json'), 'utf8'));
50+
const apiId = awsResources.AppSyncAPI;
51+
const region = awsResources.region;
52+
53+
await expect(executeGraphQLQuery(apiId, 'invalidKey', 'query {getContinents {code}}', {}, region))
54+
.rejects
55+
.toThrow('status code 401');
56+
57+
}, 600000);
4758
});

0 commit comments

Comments
 (0)