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(cloudformation-diff): cdk diff throws toUpperCase is not a function when ipProtocol is a number #28023

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SecurityGroupRule {
public readonly peer?: RulePeer;

constructor(ruleObject: any, groupRef?: string) {
this.ipProtocol = ruleObject.IpProtocol || '*unknown*';
this.ipProtocol = ruleObject.IpProtocol?.toString() || '*unknown*';
this.fromPort = ruleObject.FromPort;
this.toPort = ruleObject.ToPort;
this.groupId = ruleObject.GroupId || groupRef || '*unknown*'; // In case of an inline rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,12 @@ test('equality is symmetric', () => {
},
));
});

test('can describe protocol', () => {
expect(new SecurityGroupRule({ IpProtocol: -1 }).describeProtocol()).toEqual('Everything');
expect(new SecurityGroupRule({ IpProtocol: '-1' }).describeProtocol()).toEqual('Everything');
expect(new SecurityGroupRule({ FromPort: -1 }).describeProtocol()).toEqual('All *UNKNOWN*');
expect(new SecurityGroupRule({ IpProtocol: 'tcp', FromPort: -1, ToPort: -1 }).describeProtocol()).toEqual('All TCP');
expect(new SecurityGroupRule({ IpProtocol: 'tcp', FromPort: 10, ToPort: 20 }).describeProtocol()).toEqual('TCP 10-20');
expect(new SecurityGroupRule({ IpProtocol: 'tcp', FromPort: 10, ToPort: 10 }).describeProtocol()).toEqual('TCP 10');
});
Loading