Skip to content

Commit

Permalink
Merge pull request #32 from dolevf/add-unit-tests
Browse files Browse the repository at this point in the history
add unit tests
  • Loading branch information
dolevf authored Sep 15, 2024
2 parents f6cddcf + 01afe9d commit 8271953
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ jobs:
run: |
sleep 45 && sudo make test
working-directory: ./lab


- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Run Python Unit Tests
run: |
pip3 install pytest requests
python3 -m pytest tests/*
- name: Slack Notification Success
id: notify_success

Expand Down
6 changes: 6 additions & 0 deletions tests/test_c-backup-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import requests

def test_port_8080():
response = requests.get('http://10.1.0.13:8080')
assert response.ok

8 changes: 8 additions & 0 deletions tests/test_c-db-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import requests
import socket

def test_port_80():
response = requests.get('http://10.1.0.15/adminer.php')
assert response.ok
assert 'Adminer' in response.text

8 changes: 8 additions & 0 deletions tests/test_c-db-02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import requests
import socket

def test_port_3306():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('10.1.0.16', 3306))
assert result == 0

12 changes: 12 additions & 0 deletions tests/test_c-redis-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import socket

def test_port_6379():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('10.1.0.14', 6379))
assert result == 0

def test_port_22():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('10.1.0.14', 22))
assert result == 0

13 changes: 13 additions & 0 deletions tests/test_p-ftp-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import socket
import requests

def check_port_80():
response = requests.get('http://172.16.10.11/backup')
assert response.ok
assert 'index of /backup' in response.text

def test_port_21():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('172.16.10.11', 21))
assert result == 0

7 changes: 7 additions & 0 deletions tests/test_p-jumpbox-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import socket

def test_port_22():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('172.16.10.13', 22))
assert result == 0

13 changes: 13 additions & 0 deletions tests/test_p-web-01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests

def test_port_8081():
response = requests.get('http://172.16.10.10:8081')
assert response.ok
assert 'ACME Hyper Branding' in response.text

def test_upload_page():
response = requests.get('http://172.16.10.10:8081/upload')
assert response.ok
assert 'Upload any image!' in response.text


6 changes: 6 additions & 0 deletions tests/test_p-web-02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import requests

def test_wordpress_accessible():
response = requests.get('http://172.16.10.12')
assert response.ok
assert 'ACME Impact Alliance' in response.text

0 comments on commit 8271953

Please sign in to comment.