Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions admin/create_secrets_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,34 @@ def _create_and_get_vumark_target_id(
)


def _fetch_inactive_database_details(
def _create_and_get_inactive_database_details(
driver: "WebDriver",
email_address: str,
password: str,
license_name: str,
database_name: str,
) -> "DatabaseDict":
"""Fetch details for an existing inactive database."""
"""Create a cloud database, get its details, then delete the license to
make it inactive.
"""
vws_web_tools.log_in(
driver=driver,
email_address=email_address,
password=password,
)
vws_web_tools.wait_for_logged_in(driver=driver)
return vws_web_tools.get_database_details(
vws_web_tools.create_license(driver=driver, license_name=license_name)
vws_web_tools.create_cloud_database(
driver=driver,
database_name=database_name,
license_name=license_name,
)
database_details = vws_web_tools.get_database_details(
driver=driver,
database_name=database_name,
)
vws_web_tools.delete_license(driver=driver, license_name=license_name)
return database_details
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New function duplicates existing database creation logic

Low Severity

_create_and_get_inactive_database_details duplicates the entire body of _create_and_get_database_details (login, wait, create license, create database, get details), adding only a single delete_license call at the end. The inactive variant could instead delegate to the existing function and then perform the license deletion, avoiding the duplicated logic.

Additional Locations (1)

Fix in Cursor Fix in Web



def _create_vuforia_resource_names() -> tuple[str, str, str, str]:
Expand All @@ -159,16 +170,18 @@ def main() -> None:
email_address = os.environ["VWS_EMAIL_ADDRESS"]
password = os.environ["VWS_PASSWORD"]
new_secrets_dir = Path(os.environ["NEW_SECRETS_DIR"]).expanduser()
inactive_database_name = os.environ[
"INACTIVE_VUFORIA_TARGET_MANAGER_DATABASE_NAME"
]
new_secrets_dir.mkdir(exist_ok=True)

time = datetime.datetime.now(tz=datetime.UTC).strftime(
format="%Y-%m-%d-%H-%M-%S",
)
inactive_driver = vws_web_tools.create_chrome_driver()
inactive_database_details = _fetch_inactive_database_details(
inactive_database_details = _create_and_get_inactive_database_details(
driver=inactive_driver,
email_address=email_address,
password=password,
database_name=inactive_database_name,
license_name=f"my-inactive-license-{time}",
database_name=f"my-inactive-database-{time}",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inactive database shared across files, not per-file as intended

Medium Severity

The PR states "Each secrets file now gets its own freshly-created inactive database" and "Updated main() to create the inactive database within the loop alongside other resources," but the inactive database is created once before the loop (lines 175–186) and the same inactive_database_details is reused for all 100 secrets files. Similarly, _create_vuforia_resource_names still returns 4 values instead of 6, and the documentation removing the "reused across all files" sentence confirms per-file was intended.

Additional Locations (1)

Fix in Cursor Fix in Web

)
inactive_driver.quit()

Expand Down
5 changes: 1 addition & 4 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ To find the environment variables to set in the :file:`vuforia_secrets.env` file

Two Cloud databases are necessary in order to run all the Cloud Target tests.
One of those must be an inactive project.
To create an inactive project, delete the license key associated with a database.
The script creates the inactive project automatically by deleting its license.

VuMark tests require one VuMark database.
When creating multiple credentials files, the same inactive database and the
same VuMark database can be reused across all files.

Targets sometimes get stuck at the "Processing" stage meaning that they cannot be deleted.
When this happens, create a new target database to use for testing.
Expand All @@ -102,7 +100,6 @@ To create databases without using the browser, use :file:`admin/create_secrets_f
$ export VWS_EMAIL_ADDRESS=...
$ export VWS_PASSWORD=...
$ export NEW_SECRETS_DIR=...
$ export INACTIVE_VUFORIA_TARGET_MANAGER_DATABASE_NAME=...
# You may have to run this a few times, but it is idempotent.
$ python admin/create_secrets_files.py
# Each generated file gets its own Cloud database credentials and shares
Expand Down