Skip to content

Commit eed19b2

Browse files
authored
App for TA collector mtls e2e tests (#3120)
* Added app for TA-collecotr mTLS secert transfer e2e tests * Newline * Added change log * Update publish-test-e2e-images.yaml * Delete .chloggen/publish-test-e2e-images.yaml * Added README.md
1 parent dbf9c77 commit eed19b2

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

.github/workflows/publish-test-e2e-images.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ jobs:
5353
with:
5454
path: nodejs
5555
platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
56+
metrics-basic-auth:
57+
uses: ./.github/workflows/reusable-publish-test-e2e-images.yaml
58+
with:
59+
path: metrics-basic-auth
60+
platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11-slim
2+
3+
COPY requirements.txt .
4+
RUN pip install -r requirements.txt
5+
6+
COPY app.py .
7+
8+
EXPOSE 9123
9+
10+
CMD ["python", "app.py"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Metrics Basic Auth E2E Test App
2+
Simple web application used in an end-to-end (E2E) test to verify that the OpenTelemetry collector can retrieve secret authentication details from the target allocator over mTLS.
3+
4+
## Overview
5+
The web app provides a metrics endpoint secured with basic authentication, simulating real-world scenarios where services require secure access to their metrics.
6+
7+
## Usage
8+
This app is used within the E2E test suite to verify the OpenTelemetry operator's handling of mTLS-secured communications.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
os.environ['PROMETHEUS_DISABLE_CREATED_SERIES'] = 'true'
3+
4+
from flask import Flask, Response, request
5+
from prometheus_client import Gauge, generate_latest, REGISTRY, PROCESS_COLLECTOR, PLATFORM_COLLECTOR, GC_COLLECTOR
6+
7+
app = Flask(__name__)
8+
9+
REGISTRY.unregister(PROCESS_COLLECTOR)
10+
REGISTRY.unregister(PLATFORM_COLLECTOR)
11+
REGISTRY.unregister(GC_COLLECTOR)
12+
13+
secure = Gauge('authenticated', 'Client was authenticated')
14+
secure.set(1)
15+
16+
USERNAME = "user"
17+
PASSWORD = "t0p$ecreT"
18+
19+
def check_auth(username, password):
20+
return username == USERNAME and password == PASSWORD
21+
22+
def authenticate():
23+
return Response(
24+
'Could not verify your access level for that URL.\n'
25+
'You have to login with proper credentials', 401,
26+
{'WWW-Authenticate': 'Basic realm="Login Required"'})
27+
28+
@app.route('/metrics')
29+
def metrics():
30+
auth = request.authorization
31+
if not auth or not check_auth(auth.username, auth.password):
32+
return authenticate()
33+
return Response(generate_latest(), mimetype='text/plain')
34+
35+
if __name__ == '__main__':
36+
app.run(host='0.0.0.0', port=9123)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask==2.3.3
2+
prometheus_client==0.20.0

0 commit comments

Comments
 (0)