Commit dde21627 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

refactor: ping -> health

parent 97e80c14
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -71,13 +71,13 @@ variables:
  before_script:
    - *test-scripts

test-ping:
test-health:
  extends: .test-base
  script:
    # test: ping responds pong
    - response_status=`curl -s -o "resp.txt" -w "%{http_code}" http://aws-auth-provider/ping`
    # test: GET /health responds 200 / "ok"
    - response_status=`curl -s -o "resp.txt" -w "%{http_code}" http://aws-auth-provider/health`
    - assert_eq "200" $response_status
    - assert_eq "pong" $(cat resp.txt)
    - assert_eq "ok" $(cat resp.txt)

# test: get token with implicit env detection fails if no credentials are passed (error 401)
test-token-no-creds-fails:
+4 −3
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@ import logging
import os
import re
import tempfile
from functools import cache
from http import HTTPStatus
from typing import Optional

import boto3
from botocore.config import Config
from fastapi import FastAPI, HTTPException, Query, Request, Response
from fastapi.encoders import jsonable_encoder
from fastapi.exceptions import RequestValidationError
@@ -101,9 +101,9 @@ def getenv_checked(name: str) -> Optional[str]:
    return None if value == f"${name}" else value


@app.get("/ping", response_class=PlainTextResponse)
@app.get("/health", response_class=PlainTextResponse)
def ping():
    return "pong"
    return "ok"


@app.exception_handler(Exception)
@@ -133,6 +133,7 @@ async def request_validation_exception_handler(


@app.get("/ecr/token", response_class=PlainTextResponse)
@cache
def get_ecr_token(
    env_ctx: str = Query(default=None, alias="env_ctx"),
    region: str = Query(default=None, alias="region"),