Esempio n. 1
0
 'product_features,allowed_actions,disallowed_actions',
 [
     [  # Param Set 1
         [  # product_features
             [['Everything'], False],  # minimal permission
             [['Everything', 'Settings', 'Tasks'], True]
         ],
         {  # allowed_actions
             'tasks':
             lambda appliance: appliance.browser.create_view(TasksView).tabs
             .default.click()
         },
         {  # disallowed actions
             'my services': _go_to(MyService),
             'chargeback': _go_to('server', 'Chargeback'),
             'clouds providers': _go_to(base_types()['cloud']),
             'infrastructure providers': _go_to(base_types()['infra']),
             'control explorer': _go_to('server', 'ControlExplorer'),
             'automate explorer': _go_to('server', 'AutomateExplorer')
         }
     ],
     [  # Param Set 2
         [  # product_features
             [['Everything'], True]  # full permissions
         ],
         {  # allowed_actions
             'my services': _go_to(MyService),
             'chargeback': _go_to('server', 'Chargeback'),
             'clouds providers': _go_to(base_types()['cloud']),
             'infrastructure providers': _go_to(base_types()['infra']),
             'control explorer': _go_to('server', 'ControlExplorer'),
            navigate_to(appliance.server, dest)
        else:
            navigate_to(cls_or_obj, dest)
    return nav


@pytest.mark.tier(3)
@pytest.mark.parametrize(
    'role,allowed_actions,disallowed_actions',
    [[_mk_role(product_features=[[['Everything'], False],  # minimal permission
                                 [['Everything', 'Settings', 'Tasks'], True]]),
      {'tasks': lambda appliance: sel.click(tasks.buttons.default)},  # can only access one thing
      {
          'my services': _go_to(MyService),
          'chargeback': _go_to('server', 'Chargeback'),
          'clouds providers': _go_to(base_types()['cloud']),
          'infrastructure providers': _go_to(base_types()['infra']),
          'control explorer': _go_to('server', 'ControlExplorer'),
          'automate explorer': _go_to('server', 'AutomateExplorer')}],
     [_mk_role(product_features=[[['Everything'], True]]),  # full permissions
      {
          'my services': _go_to(MyService),
          'chargeback': _go_to('server', 'Chargeback'),
          'clouds providers': _go_to(base_types()['cloud']),
          'infrastructure providers': _go_to(base_types()['infra']),
          'control explorer': _go_to('server', 'ControlExplorer'),
          'automate explorer': _go_to('server', 'AutomateExplorer')},
      {}]])
@pytest.mark.meta(blockers=[1262759])
def test_permissions(appliance, role, allowed_actions, disallowed_actions):
    """ Test that that under the specified role the allowed acctions succeed