def testWarnEnvironmentProperty(self):
        self.StartEnvPatch({'CLOUDSDK_CORE_ENABLE_GRI': 'True'})
        hidden_prop_checker = property_diagnostics.HiddenPropertiesChecker(
            False)

        expected_result = CheckFailResult(['core/enable_gri'])
        actual_result, actual_fixer = hidden_prop_checker.Check()
        self.AssertResultEqual(expected_result, actual_result)
        self.assertIsNone(actual_fixer)
    def testIgnoreInternalProperty(self):
        self.StartEnvPatch({'CLOUDSDK_METRICS_COMMAND_NAME': 'MOCK'})
        hidden_prop_checker = property_diagnostics.HiddenPropertiesChecker(
            False)

        expected_result = check_base.Result(
            passed=True, message='Hidden Property Check passed.')
        actual_result, actual_fixer = hidden_prop_checker.Check()
        self.AssertResultEqual(expected_result, actual_result)
        self.assertIsNone(actual_fixer)
    def testIgnoreWhitelistedProperty(self):
        self.StartEnvPatch({'CLOUDSDK_CORE_ENABLE_GRI': 'MOCK'})
        self.StartPropertyPatch(property_diagnostics.HiddenPropertiesChecker,
                                '_WHITELIST',
                                return_value={'core/enable_gri'})
        hidden_prop_checker = property_diagnostics.HiddenPropertiesChecker(
            False)

        expected_result = check_base.Result(
            passed=True, message='Hidden Property Check passed.')
        actual_result, actual_fixer = hidden_prop_checker.Check()
        self.AssertResultEqual(expected_result, actual_result)
        self.assertIsNone(actual_fixer)
    def testWarnInstallationConfigurationProperty(self):
        self.StartPropertyPatch(config.Paths,
                                'sdk_root',
                                return_value=self.temp_path)
        prop = properties.VALUES.core.enable_gri
        properties.PersistProperty(prop, 'True', properties.Scope.INSTALLATION)
        hidden_prop_checker = property_diagnostics.HiddenPropertiesChecker(
            False)

        expected_result = CheckFailResult(['core/enable_gri'])
        actual_result, actual_fixer = hidden_prop_checker.Check()
        self.AssertResultEqual(expected_result, actual_result)
        self.assertIsNone(actual_fixer)
    def testIgnoreWhitelist(self):
        self.StartEnvPatch({
            'CLOUDSDK_CORE_ENABLE_GRI':
            'MOCK',
            'CLOUDSDK_DIAGNOSTICS_HIDDEN_PROPERTY_WHITELIST':
            'core/enable_gri'
        })
        hidden_prop_checker = property_diagnostics.HiddenPropertiesChecker(
            True)

        expected_result = CheckFailResult(['core/enable_gri'])
        actual_result, actual_fixer = hidden_prop_checker.Check()
        self.AssertResultEqual(expected_result, actual_result)
        self.assertIsNone(actual_fixer)
    def testIgnoreUserWhitelistedProperty(self):
        self.StartEnvPatch({
            'CLOUDSDK_CORE_ENABLE_GRI':
            'MOCK',
            'CLOUDSDK_DIAGNOSTICS_HIDDEN_PROPERTY_WHITELIST':
            'core/enable_gri'
        })
        hidden_prop_checker = property_diagnostics.HiddenPropertiesChecker(
            False)

        expected_result = check_base.Result(
            passed=True, message='Hidden Property Check passed.')
        actual_result, actual_fixer = hidden_prop_checker.Check()
        self.AssertResultEqual(expected_result, actual_result)
        self.assertIsNone(actual_fixer)