This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
430 additions
and
64 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: sicz/dockerspec:17.04.24 | ||
working_directory: ~/docker-simple-ca | ||
environment: | ||
- MAKEFLAGS=--no-print-directory | ||
steps: | ||
- run: | ||
name: Set up Environment | ||
command: | | ||
curl -sSL https://github.com/SICZ/Mk/archive/master.tar.gz | tar -xzf - | ||
mv Mk-master ~/Mk | ||
- checkout | ||
- setup_remote_docker | ||
- run: | ||
name: Remote Docker engine version | ||
command: | | ||
docker version | ||
- run: | ||
name: Build Docker image | ||
command: | | ||
make rebuild | ||
- run: | ||
name: Run Docker container | ||
command: | | ||
make secrets | ||
make run | ||
make logs | ||
- run: | ||
name: Run tests | ||
command: | | ||
env DOCKER_CONTAINER_ID=$(cat .container_id) rspec --format doc |
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,2 @@ | ||
--color | ||
--require spec_helper |
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,20 +1,15 @@ | ||
FROM sicz/lighttpd:3.5 | ||
|
||
ENV \ | ||
org.label-schema.schema-version="1.0" \ | ||
org.label-schema.name="sicz/simple-ca" \ | ||
org.label-schema.description="A simple automated Certificate Authority." \ | ||
org.label-schema.build-date="2017-04-18T20:36:03Z" \ | ||
org.label-schema.url="https://github.com/sicz/docker-simple-ca" \ | ||
org.label-schema.vcs-url="https://github.com/sicz/docker-simple-ca" | ||
|
||
ENV \ | ||
LIGHTTPD_PORT=9443 \ | ||
SIMPLE_CA_DIR=/var/lib/simple-ca | ||
ENV org.label-schema.schema-version="1.0" | ||
ENV org.label-schema.name="sicz/simple-ca" | ||
ENV org.label-schema.description="A simple automated Certificate Authority." | ||
ENV org.label-schema.build-date="2017-04-18T20:36:03Z" | ||
ENV org.label-schema.url="https://github.com/sicz/docker-simple-ca" | ||
ENV org.label-schema.vcs-url="https://github.com/sicz/docker-simple-ca" | ||
|
||
COPY config /etc | ||
COPY docker-entrypoint.d /docker-entrypoint.d | ||
COPY www ${LIGHTTPD_DIR} | ||
RUN set -x && chmod +x ${LIGHTTPD_DIR}/*.cgi | ||
COPY www /var/www | ||
RUN set -x && chmod +x /var/www/simple-ca.cgi | ||
|
||
EXPOSE ${LIGHTTPD_PORT} | ||
EXPOSE 443 |
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,20 +1,15 @@ | ||
FROM sicz/lighttpd:%%BASE_IMAGE_TAG%% | ||
|
||
ENV \ | ||
org.label-schema.schema-version="1.0" \ | ||
org.label-schema.name="%%DOCKER_PROJECT%%/%%DOCKER_NAME%%" \ | ||
org.label-schema.description="A simple automated Certificate Authority." \ | ||
org.label-schema.build-date="%%REFRESHED_AT%%" \ | ||
org.label-schema.url="https://github.com/sicz/docker-simple-ca" \ | ||
org.label-schema.vcs-url="https://github.com/%%DOCKER_PROJECT%%/docker-%%DOCKER_NAME%%" | ||
|
||
ENV \ | ||
LIGHTTPD_PORT=9443 \ | ||
SIMPLE_CA_DIR=/var/lib/simple-ca | ||
ENV org.label-schema.schema-version="1.0" | ||
ENV org.label-schema.name="%%DOCKER_PROJECT%%/%%DOCKER_NAME%%" | ||
ENV org.label-schema.description="A simple automated Certificate Authority." | ||
ENV org.label-schema.build-date="%%REFRESHED_AT%%" | ||
ENV org.label-schema.url="https://github.com/sicz/docker-simple-ca" | ||
ENV org.label-schema.vcs-url="https://github.com/%%DOCKER_PROJECT%%/docker-%%DOCKER_NAME%%" | ||
|
||
COPY config /etc | ||
COPY docker-entrypoint.d /docker-entrypoint.d | ||
COPY www ${LIGHTTPD_DIR} | ||
RUN set -x && chmod +x ${LIGHTTPD_DIR}/*.cgi | ||
COPY www /var/www | ||
RUN set -x && chmod +x /var/www/simple-ca.cgi | ||
|
||
EXPOSE ${LIGHTTPD_PORT} | ||
EXPOSE 443 |
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
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,39 @@ | ||
# encoding: UTF-8 | ||
require "docker_helper" | ||
|
||
describe "Package" do | ||
[ | ||
"bash", | ||
"curl", | ||
"jq", | ||
"libressl", | ||
"lighttpd", | ||
"lighttpd-mod_auth", | ||
].each do |package| | ||
context package do | ||
it "is installed" do | ||
expect(package(package)).to be_installed | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "Docker entrypoint file" do | ||
context "/docker-entrypoint.sh" do | ||
it "has set permissions" do | ||
expect(file("/docker-entrypoint.sh")).to exist | ||
expect(file("/docker-entrypoint.sh")).to be_executable | ||
end | ||
end | ||
[ | ||
"/docker-entrypoint.d/30-environment-certs.sh", | ||
"/docker-entrypoint.d/40-server-certs.sh", | ||
].each do |file| | ||
context file do | ||
it "exists" do | ||
expect(file(file)).to exist | ||
expect(file(file)).to be_readable | ||
end | ||
end | ||
end | ||
end |
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,71 @@ | ||
# encoding: UTF-8 | ||
require "docker_helper" | ||
|
||
describe "Web server" do | ||
|
||
context "configuration file" do | ||
[ | ||
"/etc/lighttpd/lighttpd.conf", | ||
"/etc/lighttpd/logs.conf", | ||
"/etc/lighttpd/server.conf", | ||
"/etc/ssl/openssl.cnf", | ||
].each do |file| | ||
context file do | ||
it "exists" do | ||
expect(file(file)).to exist | ||
expect(file(file)).to be_readable.by_user("lighttpd") | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "user 'lighttpd'" do | ||
it "has uid 1000" do | ||
expect(user("lighttpd")).to exist | ||
expect(user("lighttpd")).to have_uid(1000) | ||
end | ||
it "belongs to primary group 'lighttpd'" do | ||
expect(user("lighttpd")).to belong_to_primary_group "lighttpd" | ||
end | ||
end | ||
|
||
context "group 'lighttpd'" do | ||
it "has gid 1000" do | ||
expect(group("lighttpd")).to exist | ||
expect(group("lighttpd")).to have_gid(1000) | ||
end | ||
end | ||
|
||
context "server certificate" do | ||
key = "/var/lib/simple-ca/secrets/ca_server.pem" | ||
crt = "/var/lib/simple-ca/secrets/ca_server.pem" | ||
it "has set permissions" do | ||
expect(file(key)).to be_owned_by("lighttpd") | ||
expect(file(key)).to be_grouped_into("lighttpd") | ||
expect(file(key)).not_to be_readable.by("others") | ||
# crt and key are the same file | ||
# expect(file(crt)).to be_owned_by("lighttpd") | ||
# expect(file(crt)).to be_grouped_into("lighttpd") | ||
# expect(file(crt)).not_to be_readable.by("others") | ||
end | ||
it "is valid" do | ||
expect(x509_private_key(key)).to be_valid | ||
expect(x509_certificate(crt)).to be_certificate | ||
expect(x509_certificate(crt)).to be_valid | ||
expect(x509_certificate(crt).subject).to eq "/CN=sicz_simple_ca" | ||
expect(x509_certificate(crt).issuer).to eq "/CN=Docker Simple CA" | ||
expect(x509_certificate(crt).validity_in_days).to be > 3650 | ||
expect(x509_certificate(crt).subject_alt_names).to include "DNS:localhost" | ||
expect(x509_certificate(crt).subject_alt_names).to include "IP Address:127.0.0.1" | ||
expect(x509_private_key(key)).to have_matching_certificate(crt) | ||
end | ||
end | ||
|
||
context "daemon" do | ||
it "is listening on TCP port 443" do | ||
expect(process("lighttpd")).to be_running | ||
expect(port(80)).not_to be_listening.with("tcp") | ||
expect(port(443)).to be_listening.with("tcp") | ||
end | ||
end | ||
end |
Oops, something went wrong.