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 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())
Beispiel #3
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())
Beispiel #4
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())
Beispiel #5
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())
 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())