Skip to content

Commit 6b700d6

Browse files
enhances convention to use pytest style, as currently our tests runs on it rather than unittest.Testcase
1 parent a7d1d25 commit 6b700d6

6 files changed

Lines changed: 8 additions & 18 deletions

File tree

tests/test_pm.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040

4141

4242
class TestParsers(unittest.TestCase):
43-
def __init__(self, *args, **kwargs):
44-
super(TestParsers, self).__init__(*args, **kwargs)
43+
def setUp(self):
4544
self.json_file = POLICY_SPEC_JSON
4645
self.yaml_file = POLICY_SPEC_YAML
4746

@@ -98,13 +97,12 @@ def _assert_policy_spec(self, ps):
9897

9998

10099
class TestTPPPolicyManagement(unittest.TestCase):
101-
def __init__(self, *args, **kwargs):
100+
def setUp(self):
102101
self.tpp_conn = TPPTokenConnection(url=TPP_TOKEN_URL, http_request_kwargs={'verify': "/tmp/chain.pem"})
103102
auth = Authentication(user=TPP_USER, password=TPP_PASSWORD, scope=SCOPE_PM)
104103
self.tpp_conn.get_access_token(auth)
105104
self.json_file = POLICY_SPEC_JSON
106105
self.yaml_file = POLICY_SPEC_YAML
107-
super(TestTPPPolicyManagement, self).__init__(*args, **kwargs)
108106

109107
prefixed_universal = None
110108
username = "osstestuser"
@@ -166,11 +164,10 @@ def _create_policy_tpp(self, policy_spec=None, policy=None, defaults=None):
166164

167165

168166
class TestVaaSPolicyManagement(unittest.TestCase):
169-
def __init__(self, *args, **kwargs):
167+
def setUp(self):
170168
self.cloud_conn = CloudConnection(token=CLOUD_APIKEY, url=CLOUD_URL)
171169
self.json_file = POLICY_SPEC_JSON
172170
self.yaml_file = POLICY_SPEC_YAML
173-
super(TestVaaSPolicyManagement, self).__init__(*args, **kwargs)
174171

175172
def test_create_policy_from_json(self):
176173
# ps = json_parser.parse_file(self.json_file)

tests/test_ssh.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@
3232

3333

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

4140
def test_enroll_local_generated_keypair(self):
4241
keypair = SSHKeyPair()
@@ -83,9 +82,8 @@ def test_retrieve_ca_public_key_and_principals(self):
8382

8483

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

9088
def test_retrieve_ca_public_key_and_principals(self):
9189
ssh_config = _retrieve_ssh_config(self.tpp_conn)

tests/test_tpp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ def test_fake_enroll(self):
4242

4343

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

5150
def test_tpp_enroll(self):
5251
cn = f"{random_word(10)}.venafi.example.com"

tests/test_tpp_token.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@
3434

3535

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

4443
def test_tpp_token_enroll(self):
4544
cn = f"{random_word(10)}.venafi.example.com"

tests/test_vaas.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@
3030
from test_utils import random_word, enroll, renew, renew_by_thumbprint, renew_without_key_reuse, simple_enroll, \
3131
get_vaas_zone
3232
from vcert import CloudConnection, KeyType, CertificateRequest, CustomField, logger, CSR_ORIGIN_SERVICE
33-
from vcert.policy import KeyPair, DefaultKeyPair, PolicySpecification
3433
from vcert.common import RetireRequest
3534

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

3837

3938
class TestVaaSMethods(unittest.TestCase):
40-
def __init__(self, *args, **kwargs):
39+
def setUp(self):
4140
self.cloud_zone = CLOUD_ZONE
4241
self.vaas_zone_ec = VAAS_ZONE_ONLY_EC
4342
self.cloud_conn = CloudConnection(token=CLOUD_APIKEY, url=CLOUD_URL)
44-
super(TestVaaSMethods, self).__init__(*args, **kwargs)
4543

4644
def test_cloud_enroll(self):
4745
cn = f"{random_word(10)}.venafi.example.com"

vcert/connection_tpp_token.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
KEY_REFRESH_TOKEN = 'refresh_token' # nosec
3131
KEY_EXPIRATION_DATE = 'expiration_date'
3232

33-
3433
class TPPTokenConnection(AbstractTPPConnection):
3534
def __init__(self, url, user=None, password=None, access_token=None, refresh_token=None, http_request_kwargs=None):
3635
"""

0 commit comments

Comments
 (0)