Skip to content
Closed
9 changes: 4 additions & 5 deletions migrations/versions/0466_add_cypress_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
email_template_id = current_app.config["CYPRESS_SMOKE_TEST_EMAIL_TEMPLATE_ID"]
sms_template_id = current_app.config["CYPRESS_SMOKE_TEST_SMS_TEMPLATE_ID"]
default_category_id = current_app.config["DEFAULT_TEMPLATE_CATEGORY_LOW"]
cypress_user_pw = current_app.config.get(
"CYPRESS_USER_PW_SECRET", uuid.uuid4().hex[:32] # if env var isn't present, use a random password
)
Copy link
Member

Choose a reason for hiding this comment

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

Looks good! I wonder if a log should be printed to the console to warn about the fall back if it occurs. It's good as is though for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah thats a good idea, I'll add that in.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does that look good? Does logging work the same way in a migration as it does in the app?

Copy link
Member Author

Choose a reason for hiding this comment

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



def upgrade():
password = hashpw(
hashlib.sha256(
(current_app.config["CYPRESS_USER_PW_SECRET"] + current_app.config["DANGEROUS_SALT"]).encode("utf-8")
).hexdigest()
)
password = hashpw(hashlib.sha256((cypress_user_pw + current_app.config["DANGEROUS_SALT"]).encode("utf-8")).hexdigest())

Choose a reason for hiding this comment

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

The hashpw function call is missing a closing parenthesis. It should be hashpw(hashlib.sha256((cypress_user_pw + current_app.config["DANGEROUS_SALT"]).encode("utf-8")).hexdigest()).

Copy link
Member

Choose a reason for hiding this comment

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

Funny, the suggestion is exactly what is in the code.

current_year = get_current_financial_year_start_year()
default_limit = 250000

Expand Down
Loading