|
28 | 28 | PolicySpecification) |
29 | 29 | from vcert.policy.pm_cloud import CA_TYPE_DIGICERT, CA_TYPE_ENTRUST |
30 | 30 |
|
31 | | -POLICY_SPEC_JSON = 'resources/policy_specification.json' |
32 | | -POLICY_SPEC_YAML = 'resources/policy_specification.yaml' |
| 31 | +# This values are loaded from the project root which is vcert-python, not tests folder |
| 32 | +POLICY_SPEC_JSON = './tests/resources/policy_specification.json' |
| 33 | +POLICY_SPEC_YAML = './tests/resources/policy_specification.yaml' |
33 | 34 | CA_TYPE_TPP = 'TPP' |
34 | 35 |
|
35 | 36 | log = logger.get_child("test-pm") |
|
38 | 39 | class TestParsers(unittest.TestCase): |
39 | 40 | def __init__(self, *args, **kwargs): |
40 | 41 | super(TestParsers, self).__init__(*args, **kwargs) |
41 | | - self.json_file = _resolve_resources_path(POLICY_SPEC_JSON) |
42 | | - self.yaml_file = _resolve_resources_path(POLICY_SPEC_YAML) |
| 42 | + self.json_file = POLICY_SPEC_JSON |
| 43 | + self.yaml_file = POLICY_SPEC_YAML |
43 | 44 |
|
44 | 45 | def test_json_parsing(self): |
45 | 46 | ps = json_parser.parse_file(self.json_file) |
@@ -86,8 +87,8 @@ def __init__(self, *args, **kwargs): |
86 | 87 | self.tpp_conn = TPPTokenConnection(url=TPP_TOKEN_URL, http_request_kwargs={'verify': "/tmp/chain.pem"}) |
87 | 88 | auth = Authentication(user=TPP_USER, password=TPP_PASSWORD, scope=SCOPE_PM) |
88 | 89 | self.tpp_conn.get_access_token(auth) |
89 | | - self.json_file = _resolve_resources_path(POLICY_SPEC_JSON) |
90 | | - self.yaml_file = _resolve_resources_path(POLICY_SPEC_YAML) |
| 90 | + self.json_file = POLICY_SPEC_JSON |
| 91 | + self.yaml_file = POLICY_SPEC_YAML |
91 | 92 | super(TestTPPPolicyManagement, self).__init__(*args, **kwargs) |
92 | 93 |
|
93 | 94 | def test_create_policy_from_json(self): |
@@ -124,8 +125,8 @@ def _create_policy_tpp(self, policy_spec=None, policy=None, defaults=None): |
124 | 125 | class TestCloudPolicyManagement(unittest.TestCase): |
125 | 126 | def __init__(self, *args, **kwargs): |
126 | 127 | self.cloud_conn = CloudConnection(token=CLOUD_APIKEY, url=CLOUD_URL) |
127 | | - self.json_file = _resolve_resources_path(POLICY_SPEC_JSON) |
128 | | - self.yaml_file = _resolve_resources_path(POLICY_SPEC_YAML) |
| 128 | + self.json_file = POLICY_SPEC_JSON |
| 129 | + self.yaml_file = POLICY_SPEC_YAML |
129 | 130 | super(TestCloudPolicyManagement, self).__init__(*args, **kwargs) |
130 | 131 |
|
131 | 132 | def test_create_policy_from_json(self): |
@@ -262,10 +263,12 @@ def _get_tpp_policy_name(): |
262 | 263 | time = timestamp() |
263 | 264 | return f"{_get_app_name().format(time)}" |
264 | 265 |
|
265 | | - |
266 | | -def _resolve_resources_path(path): |
267 | | - resources_dir = os.path.dirname(__file__) |
268 | | - log.debug(f"Testing root folder: [{resources_dir}]") |
269 | | - resolved_path = f"./{path}" if resources_dir.endswith('tests') else f"./tests/{path}" |
270 | | - log.debug(f"resolved path: [{resolved_path}]") |
271 | | - return resolved_path |
| 266 | +# def _resolve_resources_path(path): |
| 267 | +# resources_dir = os.path.dirname(__file__) |
| 268 | +# log.debug(f"Testing root folder: [{resources_dir}]") |
| 269 | +# if resources_dir.endswith('tests'): |
| 270 | +# resolved_path = f"./{path}" |
| 271 | +# else: |
| 272 | +# resolved_path = f"./tests/{path}" |
| 273 | +# log.debug(f"resolved path: [{resolved_path}]") |
| 274 | +# return resolved_path |
0 commit comments