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: deprecated properties not recorded #655

Merged
merged 1 commit into from
Oct 31, 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 @@ -44,7 +44,9 @@ export function importCloudFormationRegistryResource(options: LoadCloudFormation
// AWS::CloudFront::ContinuousDeploymentPolicy recently introduced a change where they're marking deprecatedProperties
// as `/definitions/<Type>/properties/<Prop>` instead of `/properties/<Prop1>/<Prop2>/<Prop3>`. Ignore those, as it's
// out-of-spec
const deprecatedProperties = (resource.deprecatedProperties ?? []).filter((p) => p.startsWith('/properties/'));
const deprecatedProperties = (resource.deprecatedProperties ?? [])
.filter((p) => p.startsWith('/properties/'))
.map(simplePropNameFromJsonPtr);
resourceBuilder.markDeprecatedProperties(...deprecatedProperties);

// Mark everything 'readOnlyProperties` as attributes. However, in the old spec it is possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,51 @@ test('include primaryIdentifier in database', () => {
const primaryIdentifier = db.lookup('resource', 'cloudFormationType', 'equals', 'AWS::Some::Type')[0]?.primaryIdentifier;
expect(primaryIdentifier).toEqual(['id', 'secondId']);
});

test('deprecated properties', () => {
importCloudFormationRegistryResource({
db,
report,
resource: {
typeName: 'AWS::Some::Type',
description: 'resource with PrimaryIdentifier',
properties: {
id: {
type: 'string',
},
},
deprecatedProperties: ['/properties/id'],
},
});

// eslint-disable-next-line prettier/prettier
Copy link
Contributor

@mrgrain mrgrain Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So vain! 😂

const resource = db.lookup('resource', 'cloudFormationType', 'equals', 'AWS::Some::Type').only();
expect(resource.properties.id.deprecated).toBeDefined();
});

test('type definitions in deprecated properties do not fail', () => {
importCloudFormationRegistryResource({
db,
report,
resource: {
typeName: 'AWS::Some::Type',
description: 'resource with PrimaryIdentifier',
properties: {
id: { $ref: '#/definitions/Type' },
},
definitions: {
Type: {
type: 'object',
properties: {
id: {
type: 'string',
},
},
},
},
deprecatedProperties: ['/definitions/Type/properties/id'],
},
});

// THEN: no failure
});