Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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())
Ejemplo n.º 4
0
    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())
Ejemplo n.º 5
0
    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())
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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)