Exemple #1
0
 def test_with_initgroups(self, getpwuid):
     prev, os.initgroups = os.initgroups, Mock()
     try:
         getpwuid.return_value = ["user"]
         initgroups(5001, 50001)
         os.initgroups.assert_called_with("user", 50001)
     finally:
         os.initgroups = prev
Exemple #2
0
    def test_without_initgroups(self, getpwuid, getgrall, setgroups):
        prev = getattr(os, 'initgroups', None)
        try:
            delattr(os, 'initgroups')
        except AttributeError:
            pass
        try:
            getpwuid.return_value = ['user']

            class grent(object):
                gr_mem = ['user']

                def __init__(self, gid):
                    self.gr_gid = gid

            getgrall.return_value = [grent(1), grent(2), grent(3)]
            initgroups(5001, 50001)
            setgroups.assert_called_with([1, 2, 3])
        finally:
            if prev:
                os.initgroups = prev
Exemple #3
0
    def test_without_initgroups(self, getpwuid, getgrall, setgroups):
        prev = getattr(os, 'initgroups', None)
        try:
            delattr(os, 'initgroups')
        except AttributeError:
            pass
        try:
            getpwuid.return_value = ['user']

            class grent(object):
                gr_mem = ['user']

                def __init__(self, gid):
                    self.gr_gid = gid

            getgrall.return_value = [grent(1), grent(2), grent(3)]
            initgroups(5001, 50001)
            setgroups.assert_called_with([1, 2, 3])
        finally:
            if prev:
                os.initgroups = prev
Exemple #4
0
 def test_with_initgroups(self, initgroups_, getpwuid):
     getpwuid.return_value = ['user']
     initgroups(5001, 50001)
     initgroups_.assert_called_with('user', 50001)
Exemple #5
0
 def test_with_initgroups(self, initgroups_, getpwuid):
     getpwuid.return_value = ['user']
     initgroups(5001, 50001)
     initgroups_.assert_called_with('user', 50001)