示例#1
0
    def test_dir_attribs_with_sudo_updates_perms_recursively(self,
                                                             *args,
                                                             **kwargs):
        # make sure we have a user1 and group1 on our docker instance
        sudo('/usr/sbin/useradd user1')
        sudo('/usr/sbin/groupadd group1')
        sudo('mkdir /tmp/temp1')
        sudo('echo > /tmp/temp1/file1')

        os_helpers.dir_attribs(location='/tmp/temp1',
                                        mode='755',
                                        owner='user1',
                                        group='group1',
                                        recursive=True,
                                        use_sudo=True)

        perms, x, owner, group = sudo('ls -ld /tmp/temp1').split(' ')[0:4]
        self.assertEquals(perms, 'drwxr-xr-x')
        self.assertEquals(owner, 'user1')
        self.assertEquals(group, 'group1')

        perms, x, owner, group = sudo('ls -l /tmp/temp1/file1').split(' ')[0:4]
        self.assertEquals(perms, '-rwxr-xr-x')
        self.assertEquals(owner, 'user1')
        self.assertEquals(group, 'group1')
示例#2
0
 def test_dir_attribs_raises_exception_on_failure(self, *args, **kwargs):
     with self.assertRaises(SystemExit) as cm:
         os_helpers.dir_attribs(location='/tmp/no-valid-path',
                                mode='755',
                                owner='not-a-valid-user',
                                group='not-a-valid-group',
                                recursive=True,
                                use_sudo=False)
     self.assertEqual(cm.exception.code, 1)
示例#3
0
 def test_dir_attribs_raises_exception_on_failure(self, *args,
                                                  **kwargs):
     with self.assertRaises(SystemExit) as cm:
         os_helpers.dir_attribs(location='/tmp/no-valid-path',
                                         mode='755',
                                         owner='not-a-valid-user',
                                         group='not-a-valid-group',
                                         recursive=True,
                                         use_sudo=False)
     self.assertEqual(cm.exception.code, 1)
示例#4
0
    def test_dir_attribs_without_sudo_updates_perms(self, *args, **kwargs):
        # make sure we have a user1 and group1 on our docker instance
        sudo('/usr/sbin/useradd user1')
        sudo('/usr/sbin/groupadd group1')
        sudo('echo > /tmp/temp1')

        os_helpers.dir_attribs(location='/tmp/temp1',
                               mode='755',
                               owner='user1',
                               group='group1',
                               recursive=False,
                               use_sudo=False)

        perms, x, owner, group = sudo('ls -l /tmp/temp1').split(' ')[0:4]
        self.assertEquals(perms, '-rwxr-xr-x')
        self.assertEquals(owner, 'user1')
        self.assertEquals(group, 'group1')
示例#5
0
    def test_dir_attribs_returns_True_on_sucess(self, *args, **kwargs):
        # make sure we have a user1 and group1 on our docker instance
        sudo('/usr/sbin/useradd user1')
        sudo('/usr/sbin/groupadd group1')
        sudo('mkdir /tmp/temp1')
        sudo('echo > /tmp/temp1/file1')

        result = os_helpers.dir_attribs(location='/tmp/temp1',
                                        mode='755',
                                        owner='user1',
                                        group='group1',
                                        recursive=True,
                                        use_sudo=True)

        self.assertTrue(result)
示例#6
0
    def test_dir_attribs_returns_True_on_sucess(self, *args, **kwargs):
        # make sure we have a user1 and group1 on our docker instance
        sudo('/usr/sbin/useradd user1')
        sudo('/usr/sbin/groupadd group1')
        sudo('mkdir /tmp/temp1')
        sudo('echo > /tmp/temp1/file1')

        result = os_helpers.dir_attribs(location='/tmp/temp1',
                                        mode='755',
                                        owner='user1',
                                        group='group1',
                                        recursive=True,
                                        use_sudo=True)

        self.assertTrue(result)