Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .atmos/cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
installation_id: f67dcc7a-7060-475c-8933-19f2620f819b
last_checked: 0
telemetry_disclosure_shown: false
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ test:

cleantest:
cd test && docker compose down

readme:
@atmos readme

readme/build:
@atmos readme
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

<!-- markdownlint-disable -->
<a href="https://cpco.io/homepage"><img src="https://github.com/cloudposse/bastion/blob/main/.github/banner.png?raw=true" alt="Project Banner"/></a><br/>
<p align="right">
<a href="https://github.com/cloudposse/bastion/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/bastion.svg" alt="Latest Release"/></a><a href="https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml"><img src="https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml/badge.svg" alt="Build & Test Status"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/badge.svg" alt="Slack Community"/></a></p>


<p align="right"><a href="https://github.com/cloudposse/bastion/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/bastion.svg" alt="Latest Release"/></a><a href="https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml"><img src="https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml/badge.svg" alt="Build & Test Status"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/badge.svg" alt="Slack Community"/></a>

</p>
<!-- markdownlint-restore -->

<!--
Expand All @@ -15,8 +18,8 @@
**
** This file was automatically generated by the `cloudposse/build-harness`.
** 1) Make all changes to `README.yaml`
** 2) Run `make init` (you only need to do this once)
** 3) Run`make readme` to rebuild this file.
** 2) Install [atmos](https://atmos.tools/install/) (you only need to do this once)
** 3) Run`atmos readme` to rebuild this file.
**
** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.)
**
Expand Down Expand Up @@ -207,6 +210,10 @@ The first time you connect, you'll be asked to setup your MFA device. Subsequent







## ✨ Contributing

This project is under active development, and we encourage contributions from our community.
Expand Down
2 changes: 2 additions & 0 deletions atmos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import:
- https://raw.githubusercontent.com/cloudposse/.github/refs/heads/main/.github/atmos/github-action.yaml
6 changes: 3 additions & 3 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ services:
MFA_PROVIDER: "google-authenticator"
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "22"]
interval: 10s
timeout: 5s
retries: 3
interval: 20s
timeout: 10s
retries: 10

test:
build: "."
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/client_scripts/google_auth_test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#!/bin/sh
ping -c 1 -w 5 bastion > /dev/null

# Wait for SSH to be available on port 22
max_attempts=10
attempt=1
while [ $attempt -le $max_attempts ]; do
if nc -z -w 2 bastion 22 2>/dev/null; then
break
fi
if [ $attempt -eq $max_attempts ]; then
echo "Error: SSH port 22 not available on bastion after $max_attempts attempts" >&2
exit 1
fi
attempt=$((attempt + 1))
sleep 1
done

# Add -vv for debugging.
sshpass \
-P 'Verification code:' \
-f ./code \
ssh bastion@bastion \
-i /root/.ssh/id_rsa \
-o StrictHostKeyChecking=no \
-o IdentitiesOnly=yes \
-- echo 'this is a test.'

18 changes: 17 additions & 1 deletion test/fixtures/client_scripts/sshrc_kill_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/bin/sh
ping -c 1 -w 5 bastion
ping -c 1 -w 5 bastion > /dev/null

# Wait for SSH to be available on port 22
max_attempts=10
attempt=1
while [ $attempt -le $max_attempts ]; do
if nc -z -w 2 bastion 22 2>/dev/null; then
break
fi
if [ $attempt -eq $max_attempts ]; then
echo "Error: SSH port 22 not available on bastion after $max_attempts attempts" >&2
exit 1
fi
attempt=$((attempt + 1))
sleep 1
done


# Add -vv for debugging.
sshpass \
Expand Down
17 changes: 13 additions & 4 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ green=`tput setaf 2`
reset=`tput sgr0`

# Generating temp keys
echo "Generating test ssh keys..."
rm -rf fixtures/auth/ida_rsa*
ssh-keygen -q -f fixtures/auth/ida_rsa -N ""
chmod 600 fixtures/auth/ida_rsa
echo "ssh keys generated."

docker compose down
docker compose up -d --build bastion
docker compose up --wait -d --build bastion
docker compose build test

# wait until bastion is up
Expand All @@ -22,7 +24,6 @@ echo "Bastion sshd service started."

docker compose exec bastion /scripts/setup.sh


# greping for the first line of the left alignment square in the generated QR Code
docker compose exec bastion /scripts/google_auth_qr_code_generator_test.sh |grep -F " " > /dev/null

Expand All @@ -36,12 +37,17 @@ else
fi


docker compose run --remove-orphans test /scripts/google_auth_test.sh
# Ensure bastion is running before running test
docker compose up -d --no-recreate bastion

docker compose run --no-deps --rm test /scripts/google_auth_test.sh

retVal=$?

if [ $retVal -ne 0 ]; then
echo "${red}* Google Authenticator/SSH Test Failed${reset}"
echo "Logs from bastion (executed before the failure):"
docker logs test-bastion-1
exit $retVal
else
echo "${green}* Google Authenticator/SSH Test Succeeded${reset}"
Expand Down Expand Up @@ -70,7 +76,10 @@ else
echo "${green}* Slack API Connection Test Succeeded${reset}"
fi

export SSHRC_KILL_OUTPUT=`docker compose run --remove-orphans test /scripts/sshrc_kill_test.sh`
# Ensure bastion is running before running test
docker compose up -d --no-recreate bastion

export SSHRC_KILL_OUTPUT=`docker compose run --no-deps --rm test /scripts/sshrc_kill_test.sh`

if [[ "$SSHRC_KILL_OUTPUT" == *"this output should never print"* ]]; then
echo "${red}* Failure to quit after non-zero exit code in sshrc${reset}"
Expand Down