Skip to content

Commit 6af561c

Browse files
committed
some tweaks to generated
errors
1 parent cb88f89 commit 6af561c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

contentctl/objects/config.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ class AttackDataCache(BaseModel):
266266
"This is the beginning of a URL that the data must begin with to map to this cache object."
267267
)
268268
base_directory_name: str = Field(
269-
"This is the root folder name where the attack data should be downloaded to. Note that this path is releative to the external_repos/ folder."
269+
"This is the root folder name where the attack data should be downloaded to. Note that this path MUST be in the external_repos/ folder",
270+
pattern=r"^external_repos/.+",
270271
)
271272
# suggested checkout information for our attack_data repo
272273
# curl https://attack-range-attack-data.s3.us-west-2.amazonaws.com/attack_data.tar.zstd | zstd --decompress | tar -x -C datasets
@@ -330,7 +331,7 @@ def map_to_attack_data_cache(
330331
# Otherwise, this is a URL. See if its prefix matches one of the
331332
# prefixes in the list of caches
332333
for cache in self.test_data_caches:
333-
root_folder_path = self.external_repos_path / cache.base_directory_name
334+
root_folder_path = self.path / cache.base_directory_name
334335
# See if this data file was in that path
335336

336337
if str(filename).startswith(cache.base_url):
@@ -341,17 +342,29 @@ def map_to_attack_data_cache(
341342
# This has not been checked out. If a cache file was listed in the config AND we hit
342343
# on a prefix, it MUST be checked out
343344
raise ValueError(
344-
f"Expected to find cached test data at '{root_folder_path}', but that directory does not exist. If a test uses attack data and a prefix matches that data, then the the cached data MUST exist."
345+
f"The following directory does not exist: [{root_folder_path}]. "
346+
"You must check out this directory since you have supplied 1 or more test_data_caches in contentctl.yml."
345347
)
346348

347349
if not new_file_path.is_file():
348350
raise ValueError(
349-
f"Expected to find the cached data file '{new_file_name}', but it does not exist in '{root_folder_path}'"
351+
f"The following file does not the test_data_cache {cache.base_directory_name}:\n"
352+
f"\tFile: {new_file_name}"
350353
)
351354
return new_file_path
352355

356+
print("raising here\n")
357+
x = "\n\t".join(
358+
[
359+
f"base_url{index:02}: {url}"
360+
for index, url in enumerate(
361+
[cache.base_url for cache in self.test_data_caches]
362+
)
363+
]
364+
)
353365
raise ValueError(
354-
f"Test data file '{filename}' does not exist in ANY of the following caches. If you are supplying caches, any HTTP file MUST be located in a cache: [{[cache.base_directory_name for cache in self.test_data_caches]}]"
366+
"Test data file does not start with any of the following base_url's. If you are supplying caches, any HTTP file MUST be located in a cache:\n"
367+
f"\tFile : {filename}\n\t{x}"
355368
)
356369

357370
@property

0 commit comments

Comments
 (0)