Skip to content
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

tests: Added basic tests for certs in idoverrides #225

Closed
wants to merge 2 commits into from
Closed

tests: Added basic tests for certs in idoverrides #225

wants to merge 2 commits into from

Conversation

ofayans
Copy link
Contributor

@ofayans ofayans commented Nov 10, 2016

# Create an idview
api.Command.idview_add(cls.idview)
# Create a user
api.Command.user_add(cls.testuser, givenname=u'Bob', sn=u'Dylan')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the User tracker instance to manipulate with test resources.

)

@classmethod
def teardown_class(cls):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is preferable not to use nose styled tests. Using pytest's fixtures for the resource management is the way how other tests are implemented.

super(TestCertManipIdOverride, cls).teardown_class()

@classmethod
def setup_class(cls):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same reasoning as in teardown. Fixtures are a better place for resources needed by the test (and are reusable)

@apophys
Copy link
Contributor

apophys commented Nov 10, 2016

Please address the inline comments.

@apophys apophys self-assigned this Nov 10, 2016
@@ -0,0 +1,95 @@
#
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 2016 now

@@ -11,6 +11,30 @@
from ipatests.util import assert_deepequal, raises
from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
from ipatests.test_xmlrpc.testcert import get_testcert
from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
from ipatests.test_xmlrpc.tracker.idview_plugin import IdviewTracker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit precludes the implementation of IdviewTracker. Please rebase them in the right order.


def test_03_add_the_same_cert_to_idoverride(self, testuser,
idview, cert1, cert2):
raises(errors.ExecutionError,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware that the rest of the test uses this utility function, however I think using pytest.raises context manager adds readability here. That way the add/del cert methods for certificate could be moved to the tracker itself.

def __init__(self, cn, **kwargs):
super(IdviewTracker, self).__init__(default_version=None)
self.cn = cn
self.dn = DN(('cn', cn), 'cn=views', 'cn=accounts', api.env.basedn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use api.env.container_views here.

cn=(self.cn,),
dn=unicode(self.dn),
idoverrideusers=[],
objectclass=(u'ipaIDView', u'top', u'nsContainer')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the objectclasses module for this.

@apophys
Copy link
Contributor

apophys commented Nov 25, 2016

Please address the inline comments

@ofayans
Copy link
Contributor Author

ofayans commented Nov 28, 2016

@apophys done, thank you for review!

@@ -227,3 +227,9 @@
u'top',
u'ipaca',
]

idview = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idview is already in the module on line 185.

cert_add_cmd = api.Command.idoverrideuser_add_cert
cert_del_cmd = api.Command.idoverrideuser_remove_cert

def del_cert_from_idoverride(self, username, view_name, cert):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the method operates on the idview entry, it makes sense to move it to the tracker to be available for other tests as well. Please move it to tracker.

summary=result.get('summary')
)

def add_cert_to_idoverride(self, username, view_name, cert):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above.

@apophys
Copy link
Contributor

apophys commented Nov 29, 2016

Thank you for the change of the order and using the objectclasses module. There are still things I'd like to be changed, though.

@apophys
Copy link
Contributor

apophys commented Nov 29, 2016

Thank you for addressing the issues. The implementation is somehow minimal, however in the future it can be extended as needed.

@apophys apophys added the ack Pull Request approved, can be merged label Nov 29, 2016
@martbab martbab added the pushed Pull Request has already been pushed label Nov 29, 2016
@martbab martbab closed this Nov 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
4 participants