'A ``PathError`` is raised if the key file path given to
``RootCredential.from_path`` cannot be opened for reading.'

@not_root
@skip_on_broken_permissions
def test_load_error_on_unreadable_key_file(self):

    path = FilePath(self.mktemp())
    path.makedirs()
    temp_path = FilePath(self.mktemp())
    temp_path.makedirs()
    ca = RootCredential.initialize(temp_path, 'mycluster')
    crt_path = path.child(AUTHORITY_CERTIFICATE_FILENAME)
    crt_file = crt_path.open('w')
    crt_file.write(ca.credential.certificate.dumpPEM())
    crt_file.close()
    key_path = path.child(AUTHORITY_KEY_FILENAME)
    key_file = key_path.open('w')
    key_file.write('dummy')
    key_file.close()
    key_path.chmod(64)
    e = self.assertRaises(PathError, RootCredential.from_path, path)
    expected = 'Unable    to    load    certificate    authority    file.    Permission    denied    {path}'.format(path=key_path.path)
    self.assertEqual(str(e), expected)
