def testHostedAppsCantUseAllowlistedFeatures_ComplexFeature(self): c = feature_compiler.FeatureCompiler(None, None, 'PermissionFeature', None, None, None, None) c._CompileFeature( 'invalid_feature', [{ 'extension_types': ['extension'], 'channel': 'beta', }, { 'channel': 'beta', 'extension_types': ['hosted_app'], 'allowlist': ['0123456789ABCDEF0123456789ABCDEF01234567'], }]) c._CompileFeature( 'valid_feature', [{ 'extension_types': ['extension'], 'channel': 'beta', 'allowlist': ['0123456789ABCDEF0123456789ABCDEF01234567'], }, { 'channel': 'beta', 'extension_types': ['hosted_app'], }]) valid_feature = c._features.get('valid_feature') self.assertTrue(valid_feature) self.assertFalse(valid_feature.GetErrors()) invalid_feature = c._features.get('invalid_feature') self.assertTrue(invalid_feature) self._hasError( invalid_feature, 'Hosted apps are not allowed to use restricted features')
def testComplexParentWithoutDefaultParent(self): c = feature_compiler.FeatureCompiler(None, None, 'APIFeature', None, None, None) c._CompileFeature('bookmarks', [{ 'contexts': ['blessed_extension'], }, { 'channel': 'stable', 'contexts': ['webui'], }]) with self.assertRaisesRegexp(AssertionError, 'No default parent found for bookmarks'): c._CompileFeature('bookmarks.export', {"whitelist": ["asdf"]})
def testHostedAppsCantUseAllowlistedFeatures_ChildFeature(self): c = feature_compiler.FeatureCompiler(None, None, 'PermissionFeature', None, None, None, None) c._CompileFeature('parent', { 'extension_types': ['hosted_app'], 'channel': 'beta', }) c._CompileFeature( 'parent.child', {'allowlist': ['0123456789ABCDEF0123456789ABCDEF01234567']}) feature = c._features.get('parent.child') self.assertTrue(feature) self._hasError( feature, 'Hosted apps are not allowed to use restricted features')
def _createTestFeatureCompiler(self, feature_class): return feature_compiler.FeatureCompiler('chrome_root', [], feature_class, 'provider_class', 'out_root', 'out_base_filename')