-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from keybase/david/integration-tests
Add Dockerfile and integration tests
- Loading branch information
Showing
27 changed files
with
474 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
bin/ | ||
keybaseca.config | ||
nohup.out | ||
env.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This dockerfile builds a container capable of running the SSH CA bot. Note that a lot of this code is duplicated | ||
# between this file and Dockerfile-kssh. | ||
FROM ubuntu:18.04 | ||
|
||
RUN apt-get -qq update | ||
RUN apt-get -qq install curl software-properties-common -y | ||
RUN useradd -ms /bin/bash keybase | ||
USER keybase | ||
WORKDIR /home/keybase | ||
RUN curl --remote-name https://prerelease.keybase.io/keybase_amd64.deb | ||
USER root | ||
|
||
# Silence the error from dpkg about failing to configure keybase since `apt-get install -f` fixes it | ||
RUN dpkg -i keybase_amd64.deb || true | ||
RUN apt-get install -fy | ||
USER keybase | ||
|
||
# Install go | ||
USER root | ||
RUN add-apt-repository ppa:gophers/archive -y | ||
RUN apt-get update | ||
RUN apt-get install golang-1.11-go git sudo -y | ||
USER keybase | ||
|
||
# Install go dependencies (speeds up future builds) | ||
COPY --chown=keybase go.mod . | ||
COPY --chown=keybase go.sum . | ||
RUN /usr/lib/go-1.11/bin/go mod download | ||
|
||
COPY --chown=keybase ./ /home/keybase/ | ||
RUN /usr/lib/go-1.11/bin/go build -o bin/keybaseca cmd/keybaseca/keybaseca.go | ||
|
||
USER root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
SHELL := /bin/bash | ||
|
||
.PHONY: generate serve generatekey | ||
|
||
generate: | build generatekey | ||
|
||
serve: | ||
source env.sh && cat keybaseca.config.gen | envsubst > ../example-keybaseca-volume/keybaseca.config | ||
source env.sh && docker run -e KEYBASE_USERNAME -e PAPERKEY -v $(PWD)/../example-keybaseca-volume:/mnt:rw ca:latest docker/entrypoint-server.sh | ||
|
||
build: | ||
docker build -t ca -f Dockerfile-ca .. | ||
|
||
generatekey: | ||
source env.sh && cat keybaseca.config.gen | envsubst > ../example-keybaseca-volume/keybaseca.config | ||
source env.sh && docker run -e FORCE_WRITE -e KEYBASE_USERNAME -e PAPERKEY -v $(PWD)/../example-keybaseca-volume:/mnt:rw ca:latest docker/entrypoint-generate.sh | ||
@echo -e '\nFor each server that you wish to make accessible to the CA bot:\n\n1. Place the public key in `/etc/ssh/ca.pub`\n2. Add the line `TrustedUserCAKeys /etc/ssh/ca.pub` to `/etc/ssh/sshd_config`\n3. Restart ssh `service ssh restart`' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# chown as root | ||
chown keybase:keybase /mnt | ||
|
||
# Run everything else as the keybase user | ||
sudo -i -u keybase bash << EOF | ||
export "FORCE_WRITE=$FORCE_WRITE" | ||
nohup bash -c "run_keybase -g &" | ||
sleep 3 | ||
keybase oneshot --username $KEYBASE_USERNAME --paperkey "$PAPERKEY" | ||
bin/keybaseca -c /mnt/keybaseca.config generate | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# chown as root | ||
chown keybase:keybase /mnt | ||
|
||
# Run everything else as the keybase user | ||
sudo -i -u keybase bash << EOF | ||
nohup bash -c "run_keybase -g &" | ||
sleep 3 | ||
keybase oneshot --username $KEYBASE_USERNAME --paperkey "$PAPERKEY" | ||
bin/keybaseca -c /mnt/keybaseca.config service | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# The subteam that will be used to grant SSH access | ||
export SUBTEAM="teamname.subteam_for_ssh" | ||
export KEYBASE_USERNAME="username_of_ca_bot" | ||
export PAPERKEY="paper key for the ca bot" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Note that you do not need to edit this file. It is used with env.sh and envsubst in order to generate a config file | ||
ca_key_location: /mnt/keybase-ca-key | ||
key_expiration: "+1h" | ||
ssh_user: root | ||
teams: | ||
- $SUBTEAM | ||
keybase_paper_key: $PAPERKEY | ||
keybase_username: $KEYBASE_USERNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This directory is used with the docker instructions as an example volume used to store the CA key. Do not override the gitignore in this file in order to commit any files in this directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# Some colors for pretty output | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' | ||
|
||
# A function used to indent the log output from the tests | ||
indent() { sed 's/^/ /'; } | ||
|
||
cd tests/ | ||
./reset.sh | ||
source env.sh | ||
cat keybaseca.config.gen | envsubst > keybaseca.config | ||
echo "Building containers..." | ||
docker-compose build 2>&1 > /dev/null | ||
echo "Running integration tests..." | ||
docker-compose up -d | ||
|
||
TEST_EXIT_CODE=`docker wait tests_kssh_1` | ||
|
||
docker logs tests_kssh_1 | indent | ||
|
||
if [ -z ${TEST_EXIT_CODE+x} ] || [ "$TEST_EXIT_CODE" -ne 0 ] ; then | ||
printf "${RED}Tests Failed${NC} - Exit Code: $TEST_EXIT_CODE\n" | ||
else | ||
printf "${GREEN}Tests Passed${NC}\n" | ||
fi | ||
|
||
docker-compose stop 2>&1 > /dev/null | ||
docker-compose kill 2>&1 > /dev/null | ||
docker-compose rm -f | ||
./reset.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.