Skip to content

Commit

Permalink
fix(api-status): add API URL to api-status
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Nov 2, 2021
1 parent 2795c3c commit 5024f35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions ggshield/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ def status(ctx: click.Context, json_output: bool) -> int:
response.to_json()
if json_output
else (
f"{format_text('status:', STYLE['key'])} {format_healthcheck_status(response)}\n"
f"{format_text('app version:', STYLE['key'])} {response.app_version or 'Unknown'}\n"
f"{format_text('secrets engine version:', STYLE['key'])} "
f"{format_text('API URL:', STYLE['key'])} {client.base_uri}\n"
f"{format_text('Status:', STYLE['key'])} {format_healthcheck_status(response)}\n"
f"{format_text('App version:', STYLE['key'])} {response.app_version or 'Unknown'}\n"
f"{format_text('Secrets engine version:', STYLE['key'])} "
f"{response.secrets_engine_version or 'Unknown'}\n"
)
)
Expand Down
14 changes: 8 additions & 6 deletions tests/snapshots/snap_test_status_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@

snapshots = Snapshot()

snapshots['test_api_status[test_health_check-False] 1'] = '''\x1b[97m\x1b[1m\x1b[22mstatus:\x1b[0m \x1b[32m\x1b[22m\x1b[22mhealthy\x1b[0m
\x1b[97m\x1b[1m\x1b[22mapp version:\x1b[0m 1.26.0-rc.4
\x1b[97m\x1b[1m\x1b[22msecrets engine version:\x1b[0m 2.43.0
snapshots['test_api_status[test_health_check-False] 1'] = '''\x1b[97m\x1b[1m\x1b[22mAPI URL:\x1b[0m https://api.gitguardian.com/
\x1b[97m\x1b[1m\x1b[22mStatus:\x1b[0m \x1b[32m\x1b[22m\x1b[22mhealthy\x1b[0m
\x1b[97m\x1b[1m\x1b[22mApp version:\x1b[0m 1.26.0-rc.4
\x1b[97m\x1b[1m\x1b[22mSecrets engine version:\x1b[0m 2.43.0
'''

snapshots['test_api_status[test_health_check-True] 1'] = '''{"detail": "Valid API key.", "status_code": 200, "app_version": "1.26.0-rc.4", "secrets_engine_version": "2.43.0"}
'''

snapshots['test_api_status[test_health_check_error-False] 1'] = '''\x1b[97m\x1b[1m\x1b[22mstatus:\x1b[0m \x1b[31m\x1b[22m\x1b[22munhealthy (Configuration error.)\x1b[0m
\x1b[97m\x1b[1m\x1b[22mapp version:\x1b[0m 1.26.0-rc.4
\x1b[97m\x1b[1m\x1b[22msecrets engine version:\x1b[0m 2.43.0
snapshots['test_api_status[test_health_check_error-False] 1'] = '''\x1b[97m\x1b[1m\x1b[22mAPI URL:\x1b[0m https://api.gitguardian.com/
\x1b[97m\x1b[1m\x1b[22mStatus:\x1b[0m \x1b[31m\x1b[22m\x1b[22munhealthy (Configuration error.)\x1b[0m
\x1b[97m\x1b[1m\x1b[22mApp version:\x1b[0m 1.26.0-rc.4
\x1b[97m\x1b[1m\x1b[22mSecrets engine version:\x1b[0m 2.43.0
'''

Expand Down

0 comments on commit 5024f35

Please sign in to comment.