tools/bdconfig/lib/google_hadoop/bdconfig_lib/config_commands_test.py
def testServiceAccountRequiresClientIdAndSecret(self):
    """Setting enable_service_account_auth adds extra validators."""
    self._SetDefaultValidFlags()
    self._flag_values_copy.dry_run = False

    # If we set enable_service_account_auth to False, we now require client_id
    # and client_secret.
    self._flag_values_copy.enable_service_account_auth = False
    self.assertRaises(flags.IllegalFlagValue, self._test_cmd.Run, None)
    self.assertRaises(
        flags.IllegalFlagValue, self._flag_values_copy.__setattr__,
        'client_id', None)
    self._flag_values_copy.client_id = 'my-client-id'

    self.assertRaises(flags.IllegalFlagValue, self._test_cmd.Run, None)
    self.assertRaises(
        flags.IllegalFlagValue, self._flag_values_copy.__setattr__,
        'client_secret', None)
    self._flag_values_copy.client_secret = 'my-client-secret'

    self._test_cmd.Run(None)
    conf = xml_configuration.Configuration.FromFile(self._core_site_filename)
    self.assertEqual(8, conf.GetNumProperties())
    self.assertEquals('false', conf.GetPropertyValue(
        'fs.gs.auth.service.account.enable'))
    self.assertEquals('my-client-id', conf.GetPropertyValue(
        'fs.gs.auth.client.id'))
    self.assertEquals('my-client-secret', conf.GetPropertyValue(
        'fs.gs.auth.client.secret'))
Setting enable_service_account_auth adds extra validators.
Setting enable_service_account_auth adds extra validators.
Setting enable_service_account_auth adds extra validators .
def testServiceAccountRequiresClientIdAndSecret(self):
    self._SetDefaultValidFlags()
    self._flag_values_copy.dry_run = False
    self._flag_values_copy.enable_service_account_auth = False
    self.assertRaises(flags.IllegalFlagValue, self._test_cmd.Run, None)
    self.assertRaises(
        flags.IllegalFlagValue, self._flag_values_copy.__setattr__,
        'client_id', None)
    self._flag_values_copy.client_id = 'my-client-id'
    self.assertRaises(flags.IllegalFlagValue, self._test_cmd.Run, None)
    self.assertRaises(
        flags.IllegalFlagValue, self._flag_values_copy.__setattr__,
        'client_secret', None)
    self._flag_values_copy.client_secret = 'my-client-secret'
    self._test_cmd.Run(None)
    conf = xml_configuration.Configuration.FromFile(self._core_site_filename)
    self.assertEqual(8, conf.GetNumProperties())
    self.assertEquals('false', conf.GetPropertyValue(
        'fs.gs.auth.service.account.enable'))
    self.assertEquals('my-client-id', conf.GetPropertyValue(
        'fs.gs.auth.client.id'))
    self.assertEquals('my-client-secret', conf.GetPropertyValue(
        'fs.gs.auth.client.secret'))
def testServiceAccountRequiresClientIdAndSecret ( self ) : self . _SetDefaultValidFlags ( ) self . _flag_values_copy . dry_run = False self . _flag_values_copy . enable_service_account_auth = False self . assertRaises ( flags . IllegalFlagValue , self . _test_cmd . Run , None ) self . assertRaises ( flags . IllegalFlagValue , self . _flag_values_copy . __setattr__ , 'client_id' , None ) self . _flag_values_copy . client_id = 'my-client-id' self . assertRaises ( flags . IllegalFlagValue , self . _test_cmd . Run , None ) self . assertRaises ( flags . IllegalFlagValue , self . _flag_values_copy . __setattr__ , 'client_secret' , None ) self . _flag_values_copy . client_secret = 'my-client-secret' self . _test_cmd . Run ( None ) conf = xml_configuration . Configuration . FromFile ( self . _core_site_filename ) self . assertEqual ( 8 , conf . GetNumProperties ( ) ) self . assertEquals ( 'false' , conf . GetPropertyValue ( 'fs.gs.auth.service.account.enable' ) ) self . assertEquals ( 'my-client-id' , conf . GetPropertyValue ( 'fs.gs.auth.client.id' ) ) self . assertEquals ( 'my-client-secret' , conf . GetPropertyValue ( 'fs.gs.auth.client.secret' ) )
Setting enable_service_account_auth adds extra validators.
Setting enable_service_account_auth adds extra validators .
"""Setting enable_service_account_auth adds extra validators.""" # If we set enable_service_account_auth to False, we now require client_id # and client_secret.
self