Skip to content

Commit

Permalink
Emit an error when an enterprise add-on defines an update_url in th…
Browse files Browse the repository at this point in the history
…e manifest (#5356)
  • Loading branch information
willdurand committed Jun 18, 2024
1 parent 64565fe commit 47cf339
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/parsers/manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,8 @@ export default class ManifestJSONParser extends JSONParser {
}

if (
!this.selfHosted &&
this.parsedJSON.applications &&
this.parsedJSON.applications.gecko &&
this.parsedJSON.applications.gecko.update_url
(!this.selfHosted || this.isEnterpriseAddon) &&
this.parsedJSON.applications?.gecko?.update_url
) {
if (this.isPrivilegedAddon) {
// We cannot know whether a privileged add-on will be listed or
Expand Down
51 changes: 51 additions & 0 deletions tests/unit/parsers/test.manifestjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,57 @@ describe('ManifestJSONParser', () => {
expect(manifestJSONParser.isValid).toEqual(true);
expect(addonLinter.collector.warnings.length).toBe(0);
});

it('emits an error when the update_url is defined in an enterprise add-on', () => {
const linter = new Linter({ _: ['bar'] });

const manifestJSONParser = new ManifestJSONParser(
JSON.stringify({
manifest_version: 2,
name: 'some enterprise add-on',
version: '1',
browser_specific_settings: {
gecko: {
id: '@test-id',
admin_install_only: true,
update_url: 'https://example.org',
},
},
}),
linter.collector,
{ isEnterprise: true }
);

expect(manifestJSONParser.isValid).toEqual(false);
expect(linter.collector.warnings).toEqual([]);
expect(linter.collector.errors).toEqual([
expect.objectContaining(messages.MANIFEST_UPDATE_URL),
]);
});

it('does not emit an error when the update_url is defined in a self-hosted add-on', () => {
const linter = new Linter({ _: ['bar'] });

const manifestJSONParser = new ManifestJSONParser(
JSON.stringify({
manifest_version: 2,
name: 'some unlisted add-on',
version: '1',
browser_specific_settings: {
gecko: {
id: '@test-id',
update_url: 'https://example.org',
},
},
}),
linter.collector,
{ selfHosted: true }
);

expect(manifestJSONParser.isValid).toEqual(true);
expect(linter.collector.warnings).toEqual([]);
expect(linter.collector.errors).toEqual([]);
});
});

describe('schema error overrides', () => {
Expand Down

0 comments on commit 47cf339

Please sign in to comment.