Skip to content

Commit

Permalink
Add minimal test
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Sep 20, 2024
1 parent b75d9e9 commit a040002
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
push:
branches: [master,stable]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: test
run: ./test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $ docker run --rm -p 3000:3000 \
-e PORT=3000 \
-e DST=socat-server:4000 \
-v pathToClientCert.pem:/cert.pem \
-v pathToKey.pam:/key.pem \
-v pathToKey.pem:/key.pem \
yadd/socat-client
```

Expand All @@ -16,7 +16,7 @@ $ docker run --rm -p 4000:4000 \
-e PORT=4000 \
-e DST=hidden-server:80 \
-v pathToClientCert.pem:/cert.pem \
-v pathToKey.pam:/key.pem
-v pathToKey.pem:/key.pem
```

Using ̀VERIFY=0`:
Expand Down
34 changes: 34 additions & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
services:
client:
image: socat-client-test
build:
context: client
dockerfile: ./Dockerfile
environment:
- PORT=3000
- "DST=server:4000"
- CAFILE=/cert.pem
volumes:
- ./ssl/cert.pem:/cert.pem
- ./ssl/key.pem:/key.pem
ports:
- 3000:3000

server:
image: socat-server-test
build:
context: server
dockerfile: ./Dockerfile
environment:
- PORT=4000
- "DST=hidden:3000"
- CAFILE=/cert.pem
volumes:
- ./ssl/cert.pem:/cert.pem
- ./ssl/key.pem:/key.pem

hidden:
image: socat-static-server-test
build:
context: test-static
dockerfile: ./Dockerfile
33 changes: 33 additions & 0 deletions ssl/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-----BEGIN CERTIFICATE-----
MIIFszCCA5ugAwIBAgIUDJCfEILFjHAJV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EK0p3+2oneoIt4CG/JAgep+9DSOvUtwIDAQABo1MwUTAdBgNVHQ4EFgQUOG6A
br5MviDpH2mpfPecZHlP+4AwHwYDVR0jBBgwFoAUOG6Abr5MviDpH2mpfPecZHlP
+4AwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAHbLjh1mug2Zb
Q732RW6xGkK8r7J+ZNB/RULiVmyhCflyvd+tHgR7iwxifyingneCJhZpl0U482kG
nV43KWMYqm1hRv3MLoOHdFeC1R8Cciv9k4aTur+mB9lWRcOA5T4XzYqeEu9/h/0I
x/1haHrav+Brn56ZLqsGLKYUGhDPDsIhzTHYmwGSoXpiSQv3eNvR1Mbsk4nmL8A7
wAc9nvHcJR0ZBWVJ+GAT9ucEDn2bG1CmNl4fTR7q5XiwJTlunKsf4Cmoc6jSqkN5
Naz+T4sFjyN46lTJ9tKIdEYR617oDhs5GoMYv6yMI5x0LdXDrnBFRLjhy3izfAc8
bVoG7WWJ6/sftpr7pGt4qDSbRXTu37/802+TaQvSzOmkEc5pMIOL0jyFL4FNnSqB
3Cr0RoSoii8mZNe8OnQ+LXGPyOknQWVxLI42fT9EXj6Vw7KYV6/2Q8CoVbJrUSGK
x/APcSqZN0gufsv2Al9NzKd9iBNQAQcguzimuPAkYAtI4WExnS728qErb8F5HroS
pEUoy0AJ1udVimc4LILPmtCe8cBrxzlYg1B9t1afoo6Rn+zur5OfcJbfD02Yny4B
2D0tA+O3ke/9NA4vGYtaYuq6YUKmEpKebo065gMo5TzWbW2NwJJ/hIwYhMd42yZB
LCRnpP6NUxCFUJZ9UTfW5OSL8c3B1pE=
-----END CERTIFICATE-----
52 changes: 52 additions & 0 deletions ssl/key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCfOQ9WfXNMsqEi
H5NjbNqXgcFiUs/yXojtT6qm1UaAN+vxRsN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GDx8DsURfBtEfq3uy
devrMgxI2NbhwYI4CSFbZLD2uNsT6U3glAaFRi07sEeF+mMd4roAw5xj/qpYz7oL
CdFukQStve5spSq1M188SSwZxAyLENXwjnPvXYuP/IPbT/Z8TPDfFWyG3WY7kKUZ
MPdb4vBxgghNaF9puy/bUn9/OBw+vhjR0iRSopUVrWHJ5K2nUf0UveP6UIqqPRF7
aTfM6jZRBcU2nsNObChFiLfxC3waa6okvo/e0gECggEAQmIUBnVt0aIg2EjEbr1l
Tai2fyIbKy1JlZ0797nscnunnn82hv3QFyP229Nf4UJjrZg3Ld80mCCmmbiEnjdT
2CvoS1iLCnE4zdC+VZ4AX+rOsPdCCus8TryugONUAuXRWpVk9jlO/LPRgWtMlibB
smhafApIjajC9GfHmhQ589GCmyPgGl3YdhxkZR3zBQ4sd12G913mBsMGKXwJ+zj7
N5znr8VX9i6DdL4fPLqtL2SWdOAPSoBjzGA2LII2cgCltiGGmGO0CfCds+LVz/ui
HlhrnayWeoJGY8de/DBA8GGRN51NT1HFysZixKsIah5XGTpASWcQLbIrYOYqJ1vR
6QKCAQEAi5rmq0P2R76bvt80nEuRGhOUrkrevonZ3/Qgm0eAQSsWV0jlFqla4fYJ
YvGkSbWc8iHntRV33xa05i+W7NbmjyZ37UD9Py40RfBvdP6IpcNtSAX++wCBAeB9
WqWBpsetFYL3NJQVlQpoMCr6sMQB2OMgMdWVxxCCxzfeECMyjkEvBxZd40M7vMdf
imi3Uqkxe3/QGsT0Cm390iLf40+josXIsKQV/L+qMOItYu3BjmoRSUigruFFjni4
m4h/xqg8AfxrS30zOV5lnnhNea5jmaB/1lXbgHvcITllLWZv4sI8e6m1nYDKJZQ8
OoJkxusP1YAhh7vU1iWAsIsT8Ng2wA==
-----END PRIVATE KEY-----
17 changes: 17 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

if which docker-compose; then
COMPOSE='docker-compose'
else
COMPOSE='docker compose'
fi

set -e

$COMPOSE -f docker-compose-test.yml up -d

echo 'GET / HTTP/1.0
'|nc localhost 3000|grep 'Hello World' && echo OK

$COMPOSE -f docker-compose-test.yml down
13 changes: 13 additions & 0 deletions test-static/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM busybox:1.35

# Create a non-root user to own the files and run our server
RUN adduser -D static
USER static
WORKDIR /home/static

# Copy the static website
# Use the .dockerignore file to control what ends up inside the image!
COPY . .

# Run BusyBox httpd
CMD ["busybox", "httpd", "-f", "-v", "-p", "3000"]
5 changes: 5 additions & 0 deletions test-static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
Hello World
</body>
</html>

0 comments on commit a040002

Please sign in to comment.