Skip to content

Commit

Permalink
chore: limit test scope (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzing authored Oct 4, 2024
1 parent 835e798 commit 9350f36
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 43 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ jobs:
- name: Pytest
run: poetry run pytest

integration:
name: Integretion test
vault:
name: Integretion test (Vault)
runs-on: ubuntu-latest

env:
VAULT_ADDR: http://localhost:8200
VAULT_TOKEN: "sample-token"

services:
vault:
image: public.ecr.aws/hashicorp/vault:latest
Expand All @@ -57,17 +55,14 @@ jobs:
VAULT_DEV_ROOT_TOKEN_ID: ${{ env.VAULT_TOKEN }}
ports:
- 8200:8200

steps:
- name: Get Vault CLI
run: |
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vault
- name: Install poetry
run: pipx install poetry

- name: Setup secrets
run: |
vault secrets enable -path kv1 -version=1 kv
Expand All @@ -87,16 +82,12 @@ jobs:
}
}
EoS
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: poetry

- name: Install dependencies
run: poetry install --all-extras

- name: Run pytest
run: poetry run pytest
run: poetry run pytest tests/providers/vault
4 changes: 2 additions & 2 deletions tests/providers/vault/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@pytest.fixture
def intl_provider() -> VaultKvProvider:
if "VAULT_ADDR" not in os.environ:
raise pytest.skip("VAULT_ADDR is not set")
pytest.skip("VAULT_ADDR is not set")
if "VAULT_TOKEN" not in os.environ:
raise pytest.skip("VAULT_TOKEN is not set")
pytest.skip("VAULT_TOKEN is not set")
return VaultKvProvider(auth="token")
29 changes: 0 additions & 29 deletions tests/test_secrets_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from pathlib import Path

import pytest
Expand All @@ -8,34 +7,6 @@


class TestReadValues:
def test_vault(self, tmp_path: Path, caplog: pytest.LogCaptureFixture):
if "VAULT_ADDR" not in os.environ:
raise pytest.skip("VAULT_ADDR is not set")
if "VAULT_TOKEN" not in os.environ:
raise pytest.skip("VAULT_TOKEN is not set")

config_file = tmp_path / "config.toml"
config_file.write_text(
"""
[[sources]]
name = "strongbox"
type = "vault"
auth = "token"
[[secrets]]
name = "DEMO"
path = "kv2/test"
field = ["test", "name.with-dot"]
"""
)

with caplog.at_level("DEBUG"):
values = read_values(config=config_file, strict=True)

assert values == {"DEMO": "sample-value"}
assert "Loaded <data>DEMO</data>" in caplog.text
assert "<mark>1</mark> secrets loaded" in caplog.text

def test_plain_text(self, tmp_path: Path, caplog: pytest.LogCaptureFixture):
config_file = tmp_path / "config.yaml"
config_file.write_text(
Expand Down

0 comments on commit 9350f36

Please sign in to comment.