Skip to content

test curl

test curl #36

Workflow file for this run

name: Test Build and Call With Fake Register
on: [push]
jobs:
fakeRegister:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y openssl
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install requests
- name: Docker Build
run: |
docker-compose build
- name: Create Dummy Certificates
run: |
mkdir -p ./data/certs
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ./data/certs/local-ca.key
openssl req -x509 -new -nodes -key ./data/certs/local-ca.key -sha256 -days 3650 -out ./data/certs/local-ca.pem -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
openssl req -x509 -new -nodes -key ./data/certs/local-ca.key -sha256 -days 3650 -out ./data/certs/factory_ca.pem -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ./data/certs/server.key
openssl req -new -key ./data/certs/server.key -out ./data/certs/server.csr -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
openssl x509 -req -in ./data/certs/server.csr -CA ./data/certs/local-ca.pem -CAkey ./data/certs/local-ca.key -CAcreateserial -out ./data/certs/tls-crt -days 365 -sha256
rm -rf ./data/certs/server.key
rm -rf ./data/certs/server.csr
chmod +r ./data/certs/*
ls -la ./data/certs
- name: Run Docker Compose Up
run: |
docker-compose up --force-recreate --detach
sleep 60
- name: Test Endpoint with curl
run: |
curl -X POST http://localhost:80/sign || true
- name: Execute Script
run: |
python3 fake-lmp-device-register --registration-url "http://localhost:80/sign" --factory fake-test-sample
- name: Check relative /var/sota directory and pkey.pem file
run: |
if [[ -d "var/sota" && -f "var/sota/pkey.pem" ]]; then
echo "Relative /var/sota directory exists and pkey.pem is present"
else
echo "Relative /var/sota directory or pkey.pem is missing"
exit 1
fi
ls -la var/sota/
- name: Output Docker Compose Logs
if: always()
run: |
echo "Docker Compose Logs:"
docker-compose logs
- name: Shutdown Docker Compose
if: always()
run: |
docker-compose ps
docker-compose down