def test_open_webkit_committers_file(self): auth = CommitterAuth('path/to/auth.json') auth.webkit_committers_filename = lambda: 'webkit committers filename' self.fake_open_was_called = False with open_override( self.fake_open_function(auth.webkit_committers_filename())): auth.open_webkit_committers_file() self.assertTrue(self.fake_open_was_called)
def test_open_trac_credentials_file(self): auth = CommitterAuth('path/to/auth.json') auth.trac_credentials_filename = lambda: 'trac credentials filename' self.fake_open_was_called = False with open_override( self.fake_open_function(auth.trac_credentials_filename())): auth.open_trac_credentials_file() self.assertTrue(self.fake_open_was_called)
def test_invalid_auth_json_file(self): auth = CommitterAuth('path/to/auth.json') auth.open_auth_json_file = self.invalid_auth_json_file self.assertFalse( auth.authenticate('*****@*****.**', 'committerpassword')) self.assertEqual( 'Error parsing auth.json file: No JSON object could be decoded', auth.errmsg())
def test_fail_to_open_auth_json_file(self): def raise_IOError(): raise IOError(2, 'No such file or directory', 'path/to/auth.json') auth = CommitterAuth('path/to/auth.json') auth.open_auth_json_file = raise_IOError self.assertFalse( auth.authenticate('*****@*****.**', 'committerpassword')) self.assertEqual( 'Error opening auth.json file: No such file or directory', auth.errmsg())
def test_missing_auth_json_keys(self): auth = CommitterAuth('path/to/auth.json') auth.open_auth_json_file = lambda: CMStringIO( '{ "trac_credentials": "path/to/trac/credentials" }') self.assertFalse( auth.authenticate('*****@*****.**', 'committerpassword')) self.assertEqual('auth.json file is missing "webkit_committers" key', auth.errmsg()) auth.open_auth_json_file = lambda: CMStringIO( '{ "webkit_committers": "path/to/webkit/committers" }') auth.open_webkit_committers_file = self.fake_committers_file self.assertFalse( auth.authenticate('*****@*****.**', 'committerpassword')) self.assertEqual('auth.json file is missing "trac_credentials" key', auth.errmsg())
def setUp(self): self.auth = CommitterAuth('path/to/auth.json') self.auth.open_auth_json_file = self.fake_auth_json_file self.auth.open_webkit_committers_file = self.fake_committers_file self.auth.open_trac_credentials_file = self.fake_htdigest_file
def test_open_auth_json_file(self): auth = CommitterAuth('path/to/auth.json') self.fake_open_was_called = False with open_override(self.fake_open_function(auth.auth_json_filename())): auth.open_auth_json_file() self.assertTrue(self.fake_open_was_called)