Skip to content

Commit

Permalink
Fix vault auth
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Dec 2, 2024
1 parent 22951f7 commit e9fbb49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config/ci/montagu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ vault:
## a list, which is currently
##
## azure, github, gcp, kubernetes, ldap, mfa, okta
method: github
method: token

## Prefix for container names; we'll use {container_prefix}-(container_name)
container_prefix: montagu
Expand Down
29 changes: 7 additions & 22 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ def test_task_queue():
cfg = MontaguConfig(path)
try:
youtrack_token = os.environ["YOUTRACK_TOKEN"]
os.environ["VAULT_AUTH_GITHUB_TOKEN"] = os.environ["VAULT_TOKEN"]
with vault_dev.server() as s:
with vault_dev.Server(export_token=True) as s:
cl = s.client()
enable_github_login(cl)
cl.write("secret/youtrack/token", value=youtrack_token)
vault_addr = f"http://localhost:{s.port}"

orderly_web.start(orderly_config_path)
cli.main(["start", path, f"--option=vault.addr={vault_addr}"])
cli.main([
"start",
path,
f"--option=vault.addr={vault_addr}",
f"--option=vault.auth.args.token={s.token}",
])

# wait for API to be ready
http_get("https://localhost/api/v1")
Expand Down Expand Up @@ -101,21 +104,3 @@ def add_task_queue_user(cfg, orderly_config_path):
orderly_web.admin.grant(
orderly_config_path, "[email protected]", ["*/reports.run", "*/reports.review", "*/reports.read"]
)


def enable_github_login(cl, path="github"):
cl.sys.enable_auth_method(method_type="github", path=path)
policy = """
path "secret/*" {
capabilities = ["read", "list"]
}
"""

cl.sys.create_or_update_policy(
name="secret-reader",
policy=policy,
)

cl.auth.github.map_team(team_name="robots", policies=["secret-reader"], mount_point=path)

cl.auth.github.configure(organization="vimc", mount_point=path)

0 comments on commit e9fbb49

Please sign in to comment.