Revision de959245 test/ganeti.rapi.rlib2_unittest.py

b/test/ganeti.rapi.rlib2_unittest.py
35 35
from ganeti import query
36 36
from ganeti import luxi
37 37
from ganeti import errors
38
from ganeti import rapi
38 39

  
39 40
from ganeti.rapi import rlib2
41
from ganeti.rapi import baserlib
42
from ganeti.rapi import connector
40 43

  
41 44
import testutils
42 45

  
......
1753 1756
                                for inst in body["instances"]]))
1754 1757

  
1755 1758

  
1759
class TestPermissions(unittest.TestCase):
1760
  def testEquality(self):
1761
    self.assertEqual(rlib2.R_2_query.GET_ACCESS, rlib2.R_2_query.PUT_ACCESS)
1762
    self.assertEqual(rlib2.R_2_query.GET_ACCESS,
1763
                     rlib2.R_2_instances_name_console.GET_ACCESS)
1764

  
1765
  def testMethodAccess(self):
1766
    for handler in connector.CONNECTOR.values():
1767
      for method in baserlib._SUPPORTED_METHODS:
1768
        access = getattr(handler, "%s_ACCESS" % method)
1769
        self.assertFalse(set(access) - rapi.RAPI_ACCESS_ALL,
1770
                         msg=("Handler '%s' uses unknown access options for"
1771
                              " method %s" % (handler, method)))
1772
        self.assertTrue(rapi.RAPI_ACCESS_READ not in access or
1773
                        rapi.RAPI_ACCESS_WRITE in access,
1774
                        msg=("Handler '%s' gives query, but not write access"
1775
                             " for method %s (the latter includes query and"
1776
                             " should therefore be given as well)" %
1777
                             (handler, method)))
1778

  
1779

  
1756 1780
if __name__ == "__main__":
1757 1781
  testutils.GanetiTestProgram()

Also available in: Unified diff