Bug 1256730 - Fail configure when API key files do not exist or are empty. r=chmanchester,mikedeboer

--HG--
extra : rebase_source : 33b182bf0bffefacc408e9b52dd004c987ffc648
This commit is contained in:
Mike Hommey 2016-08-09 18:17:35 +09:00
Родитель dfdaf47766
Коммит c754dd4f3e
2 изменённых файлов: 33 добавлений и 13 удалений

Просмотреть файл

@ -25,10 +25,9 @@ def keyfile(desc, help=None, callback=lambda x: x):
result = fh.read().strip()
if result:
return callback(result)
except FatalCheckError:
raise
except IOError:
pass
raise FatalCheckError("'%s' is empty." % value[0])
except IOError as e:
raise FatalCheckError("'%s': %s." % (value[0], e.strerror))
return no_key
return keyfile

Просмотреть файл

@ -840,13 +840,24 @@ class TestChecksConfigure(unittest.TestCase):
"simple_keyfile('Mozilla API')",
args=['--with-mozilla-api-keyfile=/foo/bar/does/not/exist'],
includes=includes)
self.assertEqual(status, 0)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for the Mozilla API key... no
ERROR: '/foo/bar/does/not/exist': No such file or directory.
'''))
self.assertEqual(config, {
'MOZ_MOZILLA_API_KEY': 'no-mozilla-api-key',
})
self.assertEqual(config, {})
with MockedOpen({'key': ''}):
config, output, status = self.get_result(
"simple_keyfile('Mozilla API')",
args=['--with-mozilla-api-keyfile=key'],
includes=includes)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for the Mozilla API key... no
ERROR: 'key' is empty.
'''))
self.assertEqual(config, {})
with MockedOpen({'key': 'fake-key\n'}):
config, output, status = self.get_result(
@ -879,14 +890,24 @@ class TestChecksConfigure(unittest.TestCase):
"id_and_secret_keyfile('Bing API')",
args=['--with-bing-api-keyfile=/foo/bar/does/not/exist'],
includes=includes)
self.assertEqual(status, 0)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for the Bing API key... no
ERROR: '/foo/bar/does/not/exist': No such file or directory.
'''))
self.assertEqual(config, {
'MOZ_BING_API_CLIENTID': 'no-bing-api-clientid',
'MOZ_BING_API_KEY': 'no-bing-api-key',
})
self.assertEqual(config, {})
with MockedOpen({'key': ''}):
config, output, status = self.get_result(
"id_and_secret_keyfile('Bing API')",
args=['--with-bing-api-keyfile=key'],
includes=includes)
self.assertEqual(status, 1)
self.assertEqual(output, textwrap.dedent('''\
checking for the Bing API key... no
ERROR: 'key' is empty.
'''))
self.assertEqual(config, {})
with MockedOpen({'key': 'fake-id fake-key\n'}):
config, output, status = self.get_result(