def test_remove_all_permissions(self, kwargs, kdreyer): session = kwargs['session'] session.users['kdreyer'] = kdreyer session.permissions['kdreyer'] = ['admin'] result = ensure_user(**kwargs) assert result == {'changed': True, 'stdout_lines': ['revoke admin']} assert session.permissions['kdreyer'] == []
def test_add_permission(self, kwargs, kdreyer): session = kwargs['session'] session.users['kdreyer'] = kdreyer kwargs['permissions'] = ['admin'] result = ensure_user(**kwargs) assert result == {'changed': True, 'stdout_lines': ['grant admin']} assert session.permissions['kdreyer'] == ['admin']
def test_create(self, kwargs, kdreyer): session = kwargs['session'] result = ensure_user(**kwargs) assert result == { 'changed': True, 'stdout_lines': ['created kdreyer user'] } assert session.users['kdreyer'] == kdreyer
def test_remove_krb_principal(self, kwargs, kdreyer): session = kwargs['session'] session.users['kdreyer'] = kdreyer kwargs['krb_principals'] = [] result = ensure_user(**kwargs) expected_line = 'remove [email protected] krb principal' assert result == {'changed': True, 'stdout_lines': [expected_line]} result_princs = session.users['kdreyer']['krb_principals'] assert set(result_princs) == set()
def test_enable_user(self, kwargs, kdreyer): session = kwargs['session'] session.users['kdreyer'] = kdreyer session.users['kdreyer']['status'] = USER_STATUS['BLOCKED'], result = ensure_user(**kwargs) assert result == { 'changed': True, 'stdout_lines': ['enabled kdreyer user'] } assert session.users['kdreyer']['status'] == USER_STATUS['NORMAL']
def test_unchanged(self, kwargs, kdreyer): session = kwargs['session'] session.users['kdreyer'] = kdreyer result = ensure_user(**kwargs) assert result == {'changed': False, 'stdout_lines': []} assert session.users['kdreyer'] == kdreyer