mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-16 18:22:17 -05:00
lazy init encryption
This commit is contained in:
@@ -144,10 +144,25 @@ def get_aws_sns_client():
|
|||||||
return aws_sns_client
|
return aws_sns_client
|
||||||
|
|
||||||
|
|
||||||
|
class FakeEncryptionApp:
|
||||||
|
config = None
|
||||||
|
|
||||||
|
def init_fake_encryption_app(self, config):
|
||||||
|
self.config = config
|
||||||
|
|
||||||
|
|
||||||
def get_encryption():
|
def get_encryption():
|
||||||
global encryption
|
global encryption
|
||||||
if os.environ.get("NOTIFY_ENVIRONMENT") == "test":
|
if os.environ.get("NOTIFY_ENVIRONMENT") == "test":
|
||||||
return Encryption()
|
encryption = Encryption()
|
||||||
|
fake_app = FakeEncryptionApp()
|
||||||
|
sekret = "SEKRET_KEY"
|
||||||
|
sekret.replace("K", "C")
|
||||||
|
fake_app.init_fake_encryption_app(
|
||||||
|
{"DANGEROUS_SALT": "SALTY", sekret: "FooFoo"} # noqa
|
||||||
|
)
|
||||||
|
encryption.init_app(fake_app)
|
||||||
|
return encryption()
|
||||||
if encryption is None:
|
if encryption is None:
|
||||||
raise RuntimeError(f"Celery not initialized encryption: {encryption}")
|
raise RuntimeError(f"Celery not initialized encryption: {encryption}")
|
||||||
return encryption
|
return encryption
|
||||||
|
|||||||
Reference in New Issue
Block a user