index_tests.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:c-bastion 作者: ImmobilienScout24 项目源码 文件源码
def test_store_pubkey(self, chown_mock):
        store_pubkey('foo', self.tempdir, 'abc')
        chown_mock.assert_called_once_with('-R', 'foo:foo', self.tempdir)
        authorized_keys_file = os.path.join(self.tempdir,
                                            '.ssh/authorized_keys')
        authorized_keys = open(authorized_keys_file).read()
        self.assertEqual(authorized_keys, 'abc\n')
        file_stat = os.stat(authorized_keys_file).st_mode
        access = file_stat & (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
        self.assertEqual(access, 0o0600)

        ssh_dir = os.path.join(self.tempdir, '.ssh')
        filestat_ssh = os.stat(ssh_dir).st_mode
        access = filestat_ssh & (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
        self.assertEqual(access, 0o0700)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号