Skip to content

Commit b6543e2

Browse files
committed
Add optional test DB credentials to config
1 parent 79ba1cd commit b6543e2

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ ripe:
2525
db_username: "op://vault/item/username"
2626
db_password: "op://vault/item/password"
2727
rpki_api_key: "op://vault/item/rpki-api-key"
28+
test_db_username: "op://vault/item/test-username" # optional
29+
test_db_password: "op://vault/item/test-password" # optional
2830
sso_emails:
2931
- "admin@example.com"
3032
routes:
@@ -49,9 +51,11 @@ Secrets are fetched from 1Password via the `op` CLI. The `credentials` block in
4951

5052
| Field | Used for |
5153
|-------|----------|
52-
| `db_username` | RIPE DB REST API username |
53-
| `db_password` | RIPE DB REST API password |
54+
| `db_username` | RIPE DB REST API username (production) |
55+
| `db_password` | RIPE DB REST API password (production) |
5456
| `rpki_api_key` | RIPE RPKI Management API key |
57+
| `test_db_username` | RIPE test DB username (optional, overrides `db_username` in test mode) |
58+
| `test_db_password` | RIPE test DB password (optional, overrides `db_password` in test mode) |
5559

5660
References use the `op://vault/item/field` format. You must be signed in to the 1Password CLI (`op signin`) before running the tool.
5761

config.example.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ripe:
44
db_username: "op://vault/item/username"
55
db_password: "op://vault/item/password"
66
rpki_api_key: "op://vault/item/rpki-api-key"
7+
test_db_username: "op://vault/item/test-username" # optional: overrides db_username for test DB
8+
test_db_password: "op://vault/item/test-password" # optional: overrides db_password for test DB
79
sso_emails:
810
- "admin1@example.com"
911
- "admin2@example.com"

src/rir_updater/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class RipeCredentials(BaseModel):
7777
db_username: str
7878
db_password: str
7979
rpki_api_key: str
80+
test_db_username: str | None = None
81+
test_db_password: str | None = None
8082

8183

8284
class RipeConfig(BaseModel):

src/rir_updater/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ def _run(args, parser):
5050

5151
if config.ripe:
5252
creds = config.ripe.credentials
53+
use_test_env = not args.production
54+
if use_test_env and creds.test_db_username and creds.test_db_password:
55+
db_auth = get_ripe_db_auth(creds.test_db_username, creds.test_db_password)
56+
else:
57+
db_auth = get_ripe_db_auth(creds.db_username, creds.db_password)
5358
with RipeClient(
54-
db_auth=get_ripe_db_auth(creds.db_username, creds.db_password),
59+
db_auth=db_auth,
5560
rpki_key=get_ripe_rpki_key(creds.rpki_api_key),
5661
maintainer=config.ripe.maintainer,
5762
dry_run=not args.commit,

0 commit comments

Comments
 (0)