-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed CDK lambda function bugs which were causing timeout and unautho…
…rized errors when using the deployed GraphQL API app: -VPC config now has the appropriate subnets and security group configured -policy actions now reference the correct aws service depending on the neptune type -environment now references the correct region when the neptune type is neptune-graph -refactored endpoint parsing to use new util function so that the logic is contained in place and parsing is done in one function call instead of sprinkled throughout the code -added unit tests for endpoint parsing -added integration test verification for CDK deployment to check that the generated CDK js file contains some expected content
- Loading branch information
1 parent
909ed51
commit 5f41c81
Showing
9 changed files
with
178 additions
and
138 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
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 |
---|---|---|
@@ -1,37 +1,46 @@ | ||
import {parseNeptuneDomainFromEndpoint, parseNeptuneDomainFromHost, parseNeptuneGraphName} from '../util.js'; | ||
import {parseNeptuneDomainFromHost, parseNeptuneEndpoint} from '../util.js'; | ||
|
||
test('parse domain from neptune cluster host', () => { | ||
expect(parseNeptuneDomainFromHost('db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com')).toBe('neptune.amazonaws.com'); | ||
expect(parseNeptuneDomainFromHost('db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com')) | ||
.toBe('neptune.amazonaws.com'); | ||
}); | ||
|
||
test('parse domain from neptune analytics host', () => { | ||
expect(parseNeptuneDomainFromHost('g-abcdef.us-west-2.neptune-graph.amazonaws.com')).toBe('neptune-graph.amazonaws.com'); | ||
expect(parseNeptuneDomainFromHost('g-abcdef.us-west-2.neptune-graph.amazonaws.com')) | ||
.toBe('neptune-graph.amazonaws.com'); | ||
}); | ||
|
||
test('parse domain from host without enough parts throws error', () => { | ||
expect(() => parseNeptuneDomainFromHost('invalid.com')).toThrow('Cannot parse neptune host invalid.com because it has 2 part(s) delimited by . but expected at least 5'); | ||
expect(() => parseNeptuneDomainFromHost('invalid.com')) | ||
.toThrow('Cannot parse neptune host invalid.com because it has 2 part(s) delimited by . but expected at least 5'); | ||
}); | ||
|
||
test('parse domain from neptune cluster endpoint', () => { | ||
expect(parseNeptuneDomainFromEndpoint('db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com:8182')).toBe('neptune.amazonaws.com'); | ||
test('parse neptune db endpoint', () => { | ||
let neptuneInfo = parseNeptuneEndpoint('db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com:8182'); | ||
expect(neptuneInfo).toHaveProperty('port', '8182'); | ||
expect(neptuneInfo).toHaveProperty('host', 'db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com'); | ||
expect(neptuneInfo).toHaveProperty('domain', 'neptune.amazonaws.com'); | ||
expect(neptuneInfo).toHaveProperty('region', 'us-west-2'); | ||
expect(neptuneInfo).toHaveProperty('graphName', 'db-neptune-abc-def'); | ||
expect(neptuneInfo).toHaveProperty('neptuneType', 'neptune-db'); | ||
}); | ||
|
||
test('parse domain from neptune analytics endpoint', () => { | ||
expect(parseNeptuneDomainFromEndpoint('g-abcdef.us-west-2.neptune-graph.amazonaws.com:8182')).toBe('neptune-graph.amazonaws.com'); | ||
test('parse neptune analytics endpoint', () => { | ||
let neptuneInfo = parseNeptuneEndpoint('g-abcdef.us-east-1.neptune-graph.amazonaws.com:8183'); | ||
expect(neptuneInfo).toHaveProperty('port', '8183'); | ||
expect(neptuneInfo).toHaveProperty('host', 'g-abcdef.us-east-1.neptune-graph.amazonaws.com'); | ||
expect(neptuneInfo).toHaveProperty('domain', 'neptune-graph.amazonaws.com'); | ||
expect(neptuneInfo).toHaveProperty('region', 'us-east-1'); | ||
expect(neptuneInfo).toHaveProperty('graphName', 'g-abcdef'); | ||
expect(neptuneInfo).toHaveProperty('neptuneType', 'neptune-graph'); | ||
}); | ||
|
||
test('parse domain from endpoint without enough parts throws error', () => { | ||
expect(() => parseNeptuneDomainFromEndpoint('g-abcdef.us-west-2.neptune-graph.amazonaws.com')).toThrow('Cannot parse domain from neptune endpoint g-abcdef.us-west-2.neptune-graph.amazonaws.com because it has 1 part(s) delimited by : but expected 2'); | ||
test('parse neptune endpoint without port throws error', () => { | ||
expect(() => parseNeptuneEndpoint('db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com')) | ||
.toThrow('Cannot parse neptune endpoint db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com because it is not in expected format of host:port'); | ||
}); | ||
|
||
test('parse name from neptune cluster host', () => { | ||
expect(parseNeptuneGraphName('db-neptune-abc-def.cluster-xyz.us-west-2.neptune.amazonaws.com')).toBe('db-neptune-abc-def'); | ||
}); | ||
|
||
test('parse name from neptune analytics host', () => { | ||
expect(parseNeptuneGraphName('g-abcdef.us-west-2.neptune-graph.amazonaws.com')).toBe('g-abcdef'); | ||
}); | ||
|
||
test('parse name from host without enough parts throws error', () => { | ||
expect(() => parseNeptuneGraphName('invalid.com')).toThrow('Cannot parse neptune host invalid.com because it has 2 part(s) delimited by . but expected at least 5'); | ||
test('parse neptune endpoint not enough parts in domain throws error', () => { | ||
expect(() => parseNeptuneEndpoint('invalid.com:1234')) | ||
.toThrow('Cannot parse neptune host invalid.com because it has 2 part(s) delimited by . but expected at least 5'); | ||
}); |
Oops, something went wrong.