Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
attilakreiner committed Apr 25, 2024
1 parent 670d07a commit c6c1b91
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test Examples

on: pull_request
#workflow_dispatch

jobs:
test-tcp-echo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: Execute Test
run: |
cd tcp.echo
./setup.sh
./test.sh | tee -a $GITHUB_STEP_SUMMARY
- name: Teardown
if: always()
run: |
cd tcp.echo
./teardown.sh
test-tls-echo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: Execute Test
run: |
cd tls.echo
./setup.sh
./test.sh | tee -a $GITHUB_STEP_SUMMARY
- name: Teardown
if: always()
run: |
cd tls.echo
./teardown.sh
25 changes: 25 additions & 0 deletions tcp.echo/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -x
# GIVEN
PORT="12345"
INPUT="ZZZ Hello, Zilla!"
EXPECTED="Hello, Zilla!"
echo \# Testing tcp.echo
echo PORT=$PORT
echo INPUT=$INPUT
echo EXPECTED=$EXPECTED
echo

# WHEN
OUTPUT=$(echo $INPUT | nc -w 1 localhost $PORT)
RESULT=$?
echo OUTPUT=$OUTPUT
echo RESULT=$RESULT

# THEN
if [ $RESULT -eq 0 ] && [ "$OUTPUT" == "$EXPECTED" ]; then
echo
else
echo
exit 1
fi
25 changes: 25 additions & 0 deletions tls.echo/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# GIVEN
PORT="23456"
INPUT="Hello, Zilla!"
EXPECTED="Hello, Zilla!"
echo \# Testing tls.echo
echo PORT=$PORT
echo INPUT=$INPUT
echo EXPECTED=$EXPECTED
echo

# WHEN
OUTPUT=$(echo $INPUT | timeout 2 openssl s_client -connect localhost:$PORT -CAfile test-ca.crt -quiet -alpn echo)
RESULT=$?
echo OUTPUT=$OUTPUT
echo RESULT=$RESULT

# THEN
if [ $RESULT -eq 124 ] && [ "$OUTPUT" == "$EXPECTED" ]; then
echo
else
echo
exit 1
fi

0 comments on commit c6c1b91

Please sign in to comment.