New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ipatests: nested netgroups (intg) #409
Conversation
|
I see there are some issues:
I have PTO now and I will be back in work on Friday. But I hope I find a time to fix it sooner. |
|
Travis: I'm afraid that pylint cannot handle it, so probably you have to disable problematic lines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a few comments. I think that relations and test data should be defined in a python structure and then used instead of doing iterations over range() call
| @@ -0,0 +1,149 @@ | |||
| # Authors: | |||
| # Petr Čech <pcech@redhat.com> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the short form of the header, you can find it in test_dnssec.py
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| from __future__ import print_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this import, print is not used in code
|
|
||
| @pytest.fixture() | ||
| def three_netgroups(request): | ||
| for i in range(1, 4): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have dict of names instead range(1, 4) all the time
test_data = [
{
'user': {
'login': 'testuser1',
'first': 'user1'
},
'netgroup': 'testgroup1',
}
}
]
# this dict can be generated, you don't have to write it manually
and then
for d in test_data:
# user-add d['user']['login'] --first=d['user'][first] ...
# netgroup-add d['netgroup']
# netgroup-add-member d['netgroup'] --users=d['user']['name']
| '--users=testuser%d' % i, | ||
| 'test_netgroup%d' % i]) | ||
|
|
||
| def teardown_three_netgroups(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use test_data from previous comment too here please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and it can be in one cycle
|
|
||
| def teardown_three_netgroups(): | ||
| for i in range(1, 4): | ||
| request.cls.master.run_command(['ipa', 'netgroup-del', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to prevent failures in teardown method.
Please use run_command(['*'], raiseonerr=False) it will not raise an exception when failure occurs
| super(TestNetgroups, cls).install(mh) | ||
|
|
||
| cls.client = cls.clients[0] | ||
| cls.clientname = cls.client.run_command( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need a clientname AFAIK client should contain hostname as attribute.
| cls.clientname = cls.client.run_command( | ||
| ['hostname', '-s']).stdout_text.strip() | ||
|
|
||
| cls.domain = cls.get_domains()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO cls.domain should already contain the domain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove all cls. definitions in install method, you can remove it
| def install(cls, mh): | ||
| super(TestNetgroups, cls).install(mh) | ||
|
|
||
| cls.client = cls.clients[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rather use
client = self.clients[0]
directly in tests? It is more consistent with other tests
| def check_users_in_netgroups(self): | ||
| clear_sssd_cache(self.client) | ||
| for i in range(1, 4): | ||
| result = self.client.run_command(['getent', 'passwd', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have to add raiseonerr=False to receive result, otherwise exception will be raised, or you can remove assert result.returncode == 0
|
|
||
| def check_nested_netgroup_hierarchy(self): | ||
| clear_sssd_cache(self.client) | ||
| for i in range(1, 4): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO nesting hierarchy can be represent similarly as test_data
aa0707a
to
756a7e0
Compare
|
I addressed all comment, I hope. I don't know why due to line 228 and 230 in pylint_plugins.py. Missed I something? |
756a7e0
to
1398edd
Compare
|
I addressed issue in Travis and Quantified. PS: Right way is |
| @@ -0,0 +1,183 @@ | |||
| # | |||
| # Copyright (C) 2015 FreeIPA Contributors see COPYING for license | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017 please
1398edd
to
0b5c152
Compare
|
2015-->2017 addressed. New version pushed. |
| } | ||
| test_data.append(data) | ||
|
|
||
| members = [d['user']['login'] for d in test_data] if test_data else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You dont need, if test_data else [] it behaves the same when test_data == []
| 'last': 'User_{}'.format(i), | ||
| }, | ||
| 'netgroup': 'testgroup_{}'.format(i), | ||
| 'nested_netgroup': 'testgroup_{}'.format(i-1) if i > 1 else '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer None for nothing, instead of empty string
| from ipatests.test_integration.tasks import clear_sssd_cache | ||
|
|
||
|
|
||
| def get_test_data(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be test_data a module variable instead of function, I don't see reason to generate the same data again and again
| Test Netgroups | ||
| """ | ||
|
|
||
| num_clients = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be this tested on server side? Do we need to install extra machine?
0b5c152
to
998fe25
Compare
|
Addressed, pushed. |
Contributors.txt
Outdated
| @@ -98,6 +98,7 @@ Developers: | |||
| Adam Young | |||
| Jan Zelený | |||
| Pavel Zůna | |||
| Petr Čech | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this file is sorted alphabetically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed, thanks.
Adds a test case for issue in SSSD that manifested in an inability to resolve nested membership in netgroups The test case tests for direct and indirect membership. https://fedorahosted.org/freeipa/ticket/6439
998fe25
to
580daa2
Compare
|
Fixed upstream |
Adds a test case for issue in SSSD that manifested in
an inability to resolve nested membership in netgroups
The test case tests for direct and indirect membership.
https://fedorahosted.org/freeipa/ticket/6439