Skip to content

Commit

Permalink
SHIBUI-2575: Telemetry integration Testing with Docker Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
credman committed Jul 13, 2023
1 parent eece9db commit 45dd507
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 0 deletions.
52 changes: 52 additions & 0 deletions testbed/mock-beacon/beacon/http_echo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python3

# https://gist.github.com/gsauthof/276a6ca1bd28231dce20f60159f1f569

# SPDX-FileCopyrightText: © 2022 Georg Sauthoff <mail@gms.tf>
# SPDX-License-Identifier: BSL-1.0

import argparse
import http.server
import json
import sys
from datetime import datetime


class Dumper(http.server.BaseHTTPRequestHandler):
def do_GET(self, method='GET'):
print(f'\n{datetime.now()}\n{self.client_address[0]}\n{method} {self.path}\n{self.headers}')
self.send_response(200)
self.end_headers()

def do_DELETE(self):
return self.do_get('DELETE')

def do_POST(self, method='POST'):
n = int(self.headers.get('content-length', 0))
body = self.rfile.read(n)
print(f'\n{datetime.now()}\n{self.client_address[0]}\n{method} {self.path}\n{self.headers}{body}\n')
if self.headers.get('content-type') == 'application/json':
d = json.loads(body)
print(json.dumps(d, indent=4, sort_keys=True))
print()
self.send_response(200)
self.end_headers()

def do_PUT(self):
return self.do_post('PUT')

def log_message(self, _, *args):
pass


def main():
p = argparse.ArgumentParser(description='Dump HTTP requests to stdout')
p.add_argument('address', help='bind address')
p.add_argument('port', type=int, help='bind port')
xs = p.parse_args()
s = http.server.HTTPServer((xs.address, xs.port), Dumper)
s.serve_forever()


if __name__ == '__main__':
sys.exit(main())
47 changes: 47 additions & 0 deletions testbed/mock-beacon/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3.8"

services:

db:
image: "postgres:15"
restart: always
ports:
- '5432:5432'
environment:
- POSTGRES_USER=shibui
- POSTGRES_PASSWORD=shibui
- POSTGRES_DB=shibui

beacon:
image: python:3
volumes:
- ./beacon:/src
ports:
- "5678:5678"
command: ["python", "-u", "/src/http_echo.py", "0.0.0.0", "5678"]
shibui:
image: gcr.io/distroless/java
depends_on:
- db
volumes:
- ./shibui/war/shibui-1.18.0-SNAPSHOT.war:/app.war:ro
- ./shibui/conf/application.yml:/application.yml:ro
- ./shibui/var:/var/shibui
ports:
#- "5005:5005"
- "8080:8080"
#entrypoint: ["/usr/bin/java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-jar", "/app.war"]
entrypoint: ["/usr/bin/java", "-jar", "/app.war"]

shibui2:
image: gcr.io/distroless/java
depends_on:
- shibui
- db
volumes:
- ./shibui/war/shibui-1.18.0-SNAPSHOT.war:/app.war:ro
- ./shibui/conf/application.yml:/application.yml:ro
- ./shibui/var2:/var/shibui
ports:
- "8081:8080"
entrypoint: ["/usr/bin/java", "-jar", "/app.war"]
31 changes: 31 additions & 0 deletions testbed/mock-beacon/shibui/conf/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
spring:
profiles:
include:
- dev
- very-dangerous
datasource:
platform: postgres
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://db:5432/shibui
username: shibui
password: shibui
jpa:
show-sql: false
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQL95Dialect
format_sql: true

shibui:
default-password: "{noop}letmein7"
beacon:
enabled: true
productName: ShibUi
installationID: UNICON-SHIBUI-TESTING
url: http://beacon:5678/beacon-endpoint
send:
cron: 0 1/10 * * * ?

logging:
level:
edu.internet2.tier.shibboleth.admin.ui.scheduled.BeaconReportingTask: "DEBUG"
Empty file.
Empty file.

0 comments on commit 45dd507

Please sign in to comment.