def test_last_admin_preservation(self, admin2): """ Create a second admin, disable it. Then try to disable and remove the original one and receive LastMemberError. Last trial are these ops with second admin removed. """ admin2.ensure_exists() admin2.make_admin() admin2.disable() tracker = Tracker() with raises_exact( errors.LastMemberError(key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_disable', admin1) with raises_exact( errors.LastMemberError(key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_del', admin1) admin2.delete() with raises_exact( errors.LastMemberError(key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_disable', admin1) with raises_exact( errors.LastMemberError(key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_del', admin1)
def test_validation_disabled_on_show(self): """ Test that validation is disabled on user retrieves """ tracker = Tracker() command = tracker.make_command('user_show', invaliduser1) with raises_exact( errors.NotFound(reason=u'%s: user not found' % invaliduser1)): command()
def test_validation_disabled_on_show(self): """ Test that validation is disabled on user retrieves """ tracker = Tracker() command = tracker.make_command('user_show', invaliduser1) with raises_exact(errors.NotFound( reason=u'%s: user not found' % invaliduser1)): command()
def test_disable_original_admin(self): """ Try to disable the only admin """ tracker = Tracker() command = tracker.make_command('user_disable', admin1) with raises_exact(errors.LastMemberError( key=admin1, label=u'group', container=admin_group)): command()
class TestParamFindAndShowCommand(XMLRPC_test): """Test functionality of the ipa param-{find,show} command""" tracker = Tracker() def test_param_find(self): """Test param-find command""" # right command without criteria result = self.tracker.run_command('param_find', u'user-add') assert len(result['result']) != 0, result assert result['result'][0]['name'] == 'uid', result assert result['result'][0]['cli_name'] == 'login', result assert result['result'][0]['label'] == 'User login', result # right command, right criteria criteria = u'postalcode' result = self.tracker.run_command('param_find', u'user-add', criteria) assert len(result['result']) != 0, result for item in result['result']: assert (criteria in item['name'].lower() or criteria in item['doc'].lower()), item # right command, wrong criteria result = self.tracker.run_command('param_find', u'user-add', u'fake') assert len(result['result']) == 0, result # wrong command, wrong criteria result = self.tracker.run_command('param_find', u'fake', u'fake') assert len(result['result']) == 0, result def test_param_show(self): """Test param-show command""" # right command, right criteria criteria = u'uid' result = self.tracker.run_command('param_show', u'user-add', criteria) assert result['result'] is not None, result assert result['result']['name'] == 'uid', result assert result['result']['cli_name'] == 'login', result assert result['result']['label'] == 'User login', result # right command without criteria with pytest.raises(errors.RequirementError): self.tracker.run_command('param_show', u'user-add') # right command, wrong criteria with pytest.raises(errors.NotFound): self.tracker.run_command('param_show', u'user-add', u'fake') # wrong command, wrong criteria with pytest.raises(errors.NotFound): self.tracker.run_command('param_show', u'fake', u'fake')
class TestOutputFindAndShowCommand(XMLRPC_test): """Test functionality of the ipa output-{find,show} command""" tracker = Tracker() def test_output_find(self): """Test output-find command""" # right command without criteria result = self.tracker.run_command('output_find', u'user-add') assert len(result['result']) != 0, result assert result['result'][0]['name'] == 'summary', result assert result['result'][0]['doc'] == \ 'User-friendly description of action performed', result # right command, right criteria criteria = u'result' result = self.tracker.run_command('output_find', u'user-add', criteria) assert len(result['result']) == 1, result assert criteria in result['result'][0]['name'].lower(), result # right command, wrong criteria result = self.tracker.run_command('output_find', u'user-add', u'fake') assert len(result['result']) == 0, result # wrong command, wrong criteria result = self.tracker.run_command('output_find', u'fake', u'fake') assert len(result['result']) == 0, result def test_output_show(self): """Test output-show command""" # right command, right criteria criteria = u'value' result = self.tracker.run_command('output_show', u'user-add', criteria) assert len(result['result']) != 0, result assert criteria in result['result']['name'].lower(), result assert result['result']['doc'] == \ "The primary_key value of the entry, e.g. 'jdoe' for a user", result # right command without criteria with pytest.raises(errors.RequirementError): self.tracker.run_command('output_show', u'user-add') # right command, wrong criteria with pytest.raises(errors.NotFound): self.tracker.run_command('output_show', u'user-add', u'fake') # wrong command, wrong criteria with pytest.raises(errors.NotFound): self.tracker.run_command('output_show', u'fake', u'fake')
def test_last_admin_preservation(self, admin2): """ Create a second admin, disable it. Then try to disable and remove the original one and receive LastMemberError. Last trial are these ops with second admin removed. """ admin2.ensure_exists() admin2.make_admin() admin2.disable() tracker = Tracker() with raises_exact(errors.LastMemberError( key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_disable', admin1) with raises_exact(errors.LastMemberError( key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_del', admin1) admin2.delete() with raises_exact(errors.LastMemberError( key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_disable', admin1) with raises_exact(errors.LastMemberError( key=admin1, label=u'group', container=admin_group)): tracker.run_command('user_del', admin1)
class TestPing(XMLRPC_test): """Test functionality of the `ipalib/plugins/ping.py` module.""" tracker = Tracker() def test_ping(self): """Ping the server.""" result = self.tracker.run_command('ping') exp = {'summary': Fuzzy('IPA server version .*. API version .*')} assert_equal(result, exp) def test_ping_with_argument(self): """Try to ping with an argument.""" with raises_exact(errors.ZeroArgumentError(name='ping')): self.tracker.run_command('ping', ['argument']) def test_ping_with_option(self): """Try to ping with an option.""" with raises_exact( errors.OptionError(_('Unknown option: %(option)s'), option='bad_arg')): self.tracker.run_command('ping', bad_arg=True)