-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow testing without gssapi and ipaclient
Make tests pass without presence of requests_gssapi or ipaclient package. Signed-off-by: Christian Heimes <[email protected]>
- Loading branch information
Showing
7 changed files
with
57 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,19 +8,27 @@ | |
from cryptography.hazmat.backends import default_backend | ||
from cryptography.hazmat.primitives import serialization | ||
|
||
import ipaclient.plugins.vault | ||
|
||
import ipalib | ||
from ipalib.errors import NotFound | ||
|
||
import pkg_resources | ||
|
||
import pytest | ||
|
||
from custodia.compat import configparser | ||
from custodia.ipa.certrequest import IPACertRequest | ||
from custodia.ipa.interface import IPAInterface, IPA_SECTIONNAME | ||
from custodia.ipa.vault import IPAVault, krb5_unparse_principal_name | ||
|
||
try: | ||
import ipaclient.plugins.vault | ||
import ipalib | ||
except ImportError: | ||
HAS_IPA = False | ||
NotFound = None | ||
IPACertRequest = None | ||
IPAInterface = IPA_SECTIONNAME = None | ||
IPAVault = krb5_unparse_principal_name = None | ||
else: | ||
HAS_IPA = True | ||
from ipalib.errors import NotFound | ||
from custodia.ipa.certrequest import IPACertRequest | ||
from custodia.ipa.interface import IPAInterface, IPA_SECTIONNAME | ||
from custodia.ipa.vault import IPAVault, krb5_unparse_principal_name | ||
|
||
try: | ||
from unittest import mock | ||
|
@@ -172,6 +180,7 @@ | |
|
||
|
||
@pytest.mark.skipif(mock is None, reason='requires mock') | ||
@pytest.mark.skipif(not HAS_IPA, reason='requires ipaclient package') | ||
class BaseTest(object): | ||
def setup_method(self, method): | ||
# pylint: disable=attribute-defined-outside-init | ||
|
@@ -399,6 +408,7 @@ def test_get(self): | |
certreq.get('keys/HTTP/client1.ipa.example') | ||
|
||
|
||
@pytest.mark.skipif(not HAS_IPA, reason='requires ipaclient package') | ||
@pytest.mark.parametrize('group,name,cls', [ | ||
('custodia.stores', 'IPAVault', IPAVault), | ||
('custodia.stores', 'IPACertRequest', IPACertRequest), | ||
|
@@ -415,6 +425,7 @@ def test_plugins(group, name, cls, dist='custodia'): | |
assert resolved is cls | ||
|
||
|
||
@pytest.mark.skipif(not HAS_IPA, reason='requires ipaclient package') | ||
@pytest.mark.parametrize('principal,result', [ | ||
('[email protected]', | ||
(None, 'john', 'IPA.EXAMPLE')), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters