-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 Pull testuser API keys from AWS secrets (#32)
- Loading branch information
Showing
4 changed files
with
37 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import json | ||
import os | ||
from pathlib import Path | ||
from typing import Dict, Optional | ||
|
@@ -9,20 +10,35 @@ | |
from ._env import get_package_name | ||
|
||
|
||
def login_testuser1(session: Session, env: Optional[Dict[str, str]] = None): | ||
def _login_lamin_user(user_email: str, env: Optional[Dict[str, str]] = None): | ||
import boto3 | ||
import lamindb_setup as ln_setup | ||
|
||
if env is not None: | ||
os.environ.update(env) | ||
ln_setup.login("[email protected]", key="cEvcwMJFX4OwbsYVaMt2Os6GxxGgDUlBGILs2RyS") | ||
session = boto3.session.Session() | ||
client = session.client( | ||
service_name="secretsmanager", | ||
region_name="us-east-1", | ||
) | ||
arn = ( | ||
"arn:aws:secretsmanager:us-east-1:586130067823:secret:laminlabs-internal-sZj1MU" | ||
) | ||
secrets = json.loads(client.get_secret_value(SecretId=arn)["SecretString"]) | ||
if user_email == "[email protected]": | ||
ln_setup.login(user_email, key=secrets["LAMIN_TESTUSER1_API_KEY"]) | ||
elif user_email == "[email protected]": | ||
ln_setup.login(user_email, key=secrets["LAMIN_TESTUSER2_API_KEY"]) | ||
else: | ||
raise NotImplementedError | ||
|
||
|
||
def login_testuser2(session: Session, env: Optional[Dict[str, str]] = None): | ||
import lamindb_setup as ln_setup | ||
def login_testuser1(session: Session, env: Optional[Dict[str, str]] = None): | ||
_login_lamin_user("[email protected]", env=env) | ||
|
||
if env is not None: | ||
os.environ.update(env) | ||
ln_setup.login("[email protected]", key="goeoNJKE61ygbz1vhaCVynGERaRrlviPBVQsjkhz") | ||
|
||
def login_testuser2(session: Session, env: Optional[Dict[str, str]] = None): | ||
_login_lamin_user("[email protected]", env=env) | ||
|
||
|
||
def run_pre_commit(session: Session): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ dev = [ | |
"pre-commit", | ||
"pytest>=6.0", | ||
"pytest-cov", | ||
"boto3", | ||
"lamindb_setup", | ||
] | ||
|
||
[project.scripts] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from laminci.nox import _login_lamin_user | ||
|
||
|
||
def test_login_testuser1(): | ||
_login_lamin_user("[email protected]") |