Skip to content

Commit

Permalink
enhances convention to use pytest style, as currently our tests runs …
Browse files Browse the repository at this point in the history
…on it rather than unittest.Testcase
  • Loading branch information
luispresuelVenafi committed Dec 6, 2024
1 parent a7d1d25 commit 6b700d6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
9 changes: 3 additions & 6 deletions tests/test_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@


class TestParsers(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(TestParsers, self).__init__(*args, **kwargs)
def setUp(self):
self.json_file = POLICY_SPEC_JSON
self.yaml_file = POLICY_SPEC_YAML

Expand Down Expand Up @@ -98,13 +97,12 @@ def _assert_policy_spec(self, ps):


class TestTPPPolicyManagement(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.tpp_conn = TPPTokenConnection(url=TPP_TOKEN_URL, http_request_kwargs={'verify': "/tmp/chain.pem"})
auth = Authentication(user=TPP_USER, password=TPP_PASSWORD, scope=SCOPE_PM)
self.tpp_conn.get_access_token(auth)
self.json_file = POLICY_SPEC_JSON
self.yaml_file = POLICY_SPEC_YAML
super(TestTPPPolicyManagement, self).__init__(*args, **kwargs)

prefixed_universal = None
username = "osstestuser"
Expand Down Expand Up @@ -166,11 +164,10 @@ def _create_policy_tpp(self, policy_spec=None, policy=None, defaults=None):


class TestVaaSPolicyManagement(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.cloud_conn = CloudConnection(token=CLOUD_APIKEY, url=CLOUD_URL)
self.json_file = POLICY_SPEC_JSON
self.yaml_file = POLICY_SPEC_YAML
super(TestVaaSPolicyManagement, self).__init__(*args, **kwargs)

def test_create_policy_from_json(self):
# ps = json_parser.parse_file(self.json_file)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@


class TestTPPTokenSSHCertificate(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.tpp_conn = TPPTokenConnection(url=TPP_TOKEN_URL, http_request_kwargs={'verify': "/tmp/chain.pem"})
auth = Authentication(user=TPP_USER, password=TPP_PASSWORD, scope=SCOPE_SSH)
self.tpp_conn.get_access_token(auth)
super(TestTPPTokenSSHCertificate, self).__init__(*args, **kwargs)

def test_enroll_local_generated_keypair(self):
keypair = SSHKeyPair()
Expand Down Expand Up @@ -83,9 +82,8 @@ def test_retrieve_ca_public_key_and_principals(self):


class TestTPPSSHCertificate(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.tpp_conn = TPPConnection(TPP_USER, TPP_PASSWORD, TPP_URL, http_request_kwargs={'verify': "/tmp/chain.pem"})
super(TestTPPSSHCertificate, self).__init__(*args, **kwargs)

def test_retrieve_ca_public_key_and_principals(self):
ssh_config = _retrieve_ssh_config(self.tpp_conn)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_tpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ def test_fake_enroll(self):


class TestTPPMethods(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.tpp_zone = TPP_ZONE
self.tpp_zone_ecdsa = TPP_ZONE_ECDSA
self.tpp_conn = TPPConnection(TPP_USER, TPP_PASSWORD, TPP_URL, http_request_kwargs={'verify': "/tmp/chain.pem"})
super(TestTPPMethods, self).__init__(*args, **kwargs)

def test_tpp_enroll(self):
cn = f"{random_word(10)}.venafi.example.com"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_tpp_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@


class TestTPPTokenMethods(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.tpp_zone = TPP_ZONE
self.tpp_zone_ecdsa = TPP_ZONE_ECDSA
self.tpp_conn = TPPTokenConnection(url=TPP_TOKEN_URL, user=TPP_USER, password=TPP_PASSWORD,
http_request_kwargs={'verify': "/tmp/chain.pem"})
super(TestTPPTokenMethods, self).__init__(*args, **kwargs)

def test_tpp_token_enroll(self):
cn = f"{random_word(10)}.venafi.example.com"
Expand Down
4 changes: 1 addition & 3 deletions tests/test_vaas.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
from test_utils import random_word, enroll, renew, renew_by_thumbprint, renew_without_key_reuse, simple_enroll, \
get_vaas_zone
from vcert import CloudConnection, KeyType, CertificateRequest, CustomField, logger, CSR_ORIGIN_SERVICE
from vcert.policy import KeyPair, DefaultKeyPair, PolicySpecification
from vcert.common import RetireRequest

log = logger.get_child("test-vaas")


class TestVaaSMethods(unittest.TestCase):
def __init__(self, *args, **kwargs):
def setUp(self):
self.cloud_zone = CLOUD_ZONE
self.vaas_zone_ec = VAAS_ZONE_ONLY_EC
self.cloud_conn = CloudConnection(token=CLOUD_APIKEY, url=CLOUD_URL)
super(TestVaaSMethods, self).__init__(*args, **kwargs)

def test_cloud_enroll(self):
cn = f"{random_word(10)}.venafi.example.com"
Expand Down
1 change: 0 additions & 1 deletion vcert/connection_tpp_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
KEY_REFRESH_TOKEN = 'refresh_token' # nosec
KEY_EXPIRATION_DATE = 'expiration_date'


class TPPTokenConnection(AbstractTPPConnection):
def __init__(self, url, user=None, password=None, access_token=None, refresh_token=None, http_request_kwargs=None):
"""
Expand Down

0 comments on commit 6b700d6

Please sign in to comment.