Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database: enable TLS with postgres tests #439

Merged
merged 1 commit into from
Sep 30, 2024
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
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testcerts/server.key
testcerts/client.key:private-key:1
testcerts/root.key:private-key:1
testcerts/server.key:private-key:1
2 changes: 0 additions & 2 deletions database/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func TestPostgres_Basic(t *testing.T) {
}

func TestPostgres_TLS(t *testing.T) {
t.Skip()

if testing.Short() {
t.Skip("-short flag enabled")
}
Expand Down
3 changes: 1 addition & 2 deletions database/testdata/gencerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ openssl req -newkey rsa:2048 -nodes -keyout client.key -subj "/C=CN/ST=GD/L=SZ/O
openssl x509 -req -extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1") -days 365 -in client.csr -CA root.crt -CAkey root.key -CAcreateserial -out client.crt

rm -f server.csr client.csr
chmod 600 *.key
chmod 644 *.crt
ls -l

echo "FINIHSED Generating test certificates"
12 changes: 0 additions & 12 deletions database/testdata/owncerts.sh

This file was deleted.

13 changes: 7 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ services:
restart: always
ports:
- "5432:5432"
# command: -c ssl=on -c ssl_cert_file=/opt/moov/certs/server.crt -c ssl_key_file=/opt/moov/certs/server.key -c ssl_ca_file=/opt/moov/certs/root.crt
# https://github.com/docker-library/postgres/issues/1059#issuecomment-1467077098
command: |
sh -c 'chown postgres:postgres /opt/moov/certs/*.key && chmod 0644 /opt/moov/certs/*.crt && ls -l /opt/moov/certs/ && exec docker-entrypoint.sh -c ssl=on -c ssl_cert_file=/opt/moov/certs/server.crt -c ssl_key_file=/opt/moov/certs/server.key -c ssl_ca_file=/opt/moov/certs/root.crt'
healthcheck:
test: ["CMD-SHELL", "pg_isready -U moov"]
interval: 5s
Expand All @@ -45,11 +47,10 @@ services:
- POSTGRES_PASSWORD=moov
networks:
- intranet
# volumes:
# - ./testcerts/root.crt:/opt/moov/certs/root.crt
# - ./testcerts/server.crt:/opt/moov/certs/server.crt
# - ./testcerts/server.key:/opt/moov/certs/server.key
# - ./database/testdata/owncerts.sh:/docker-entrypoint-initdb.d/owncerts.sh
volumes:
- ./testcerts/root.crt:/opt/moov/certs/root.crt
- ./testcerts/server.crt:/opt/moov/certs/server.crt
- ./testcerts/server.key:/opt/moov/certs/server.key

networks:
intranet:
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ifeq ($(OS),Windows_NT)
else
@wget -O lint-project.sh https://raw.githubusercontent.com/moov-io/infra/master/go/lint-project.sh
@chmod +x ./lint-project.sh
GOCYCLO_LIMIT=26 COVER_THRESHOLD=50.0 GOLANGCI_LINTERS=gosec ./lint-project.sh
GOCYCLO_LIMIT=26 COVER_THRESHOLD=50.0 GOLANGCI_LINTERS=gosec GITLEAKS_EXCLUDE=testcerts ./lint-project.sh
endif

.PHONY: clean
Expand Down
Loading