-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tls test for new cert command.
Closes #2615
- Loading branch information
srfrog
committed
Oct 18, 2018
1 parent
7150815
commit e8f2448
Showing
18 changed files
with
100 additions
and
113 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,63 +1,62 @@ | ||
KEYBITS=2048 | ||
PASS=secret | ||
# | ||
# Copyright 2017-2018 Dgraph Labs, Inc. and Contributors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
|
||
KEYS=ca.key server.key client.key server_pass.key client_pass.key server3.key | ||
CERTS=ca.crt server.crt client.crt server_pass.crt client_pass.crt server3.crt | ||
|
||
test: all | ||
@echo -e "\n\n\nTESTING...\n" | ||
@echo "Basic TLS communication, unencrypted keys" | ||
@./test.sh ./server_nopass.sh ./client_nocert.sh 0 | ||
@echo "Basic TLS communication, encrypted keys (with password)" | ||
@./test.sh ./server_pass.sh ./client_pass.sh 0 | ||
@echo "TLS client authentication, unencrypted key" | ||
@./test.sh ./server_nopass_client_auth.sh ./client_nopass.sh 0 | ||
@echo "TLS client authentication, no client cert (failure expected)" | ||
@./test.sh ./server_nopass_client_auth.sh ./client_nocert.sh 1 | ||
@echo "Invalid server name (failure expected)" | ||
@./test.sh ./server_nopass.sh ./client_pass.sh 1 | ||
@echo "TLS protocol versions mismatch (failure expected)" | ||
@./test.sh ./server_11.sh ./client_12.sh 1 | ||
@echo "TLS certificate reloading" | ||
@./test_reload.sh | ||
|
||
all: ca $(KEYS) $(CERTS) | ||
|
||
clean: | ||
git clean -d -f | ||
DGRAPH_PATH = $(GOPATH)/src/github.com/dgraph-io/dgraph/dgraph | ||
DGRAPH_BIN = $(DGRAPH_PATH)/dgraph | ||
|
||
ca: | ||
@mkdir -p newcerts | ||
@touch index.txt | ||
@touch index.txt.attr | ||
@echo 1000 > serial | ||
TARGETS = test1 test2 test3 test4 test5 | ||
KEYBITS = 2048 | ||
|
||
ca.crt: ca.key | ||
openssl req -key ca.key -new -x509 -extensions v3_ca -out ca.crt -nodes -subj "/C=AU/L=Sydney/O=Dgraph/CN=ca.dgraph.io" | ||
.PHONY: all | ||
all: cert $(TARGETS) | ||
|
||
ca.key: | ||
openssl genrsa -out ca.key $(KEYBITS) | ||
test: all | ||
|
||
server.csr server.key: | ||
openssl req -new -newkey rsa:$(KEYBITS) -keyout server.key -out server.csr -nodes -subj "/C=AU/L=Sydney/O=Dgraph/CN=server1.dgraph.io" | ||
cert: | ||
@echo "Generating CA cert in 'tls' dir." | ||
@$(MAKE) -C $(DGRAPH_PATH) all | ||
@$(DGRAPH_BIN) cert --keysize $(KEYBITS) -d $(PWD)/tls -n localhost -c live | ||
|
||
server3.csr server3.key: | ||
openssl req -new -newkey rsa:$(KEYBITS) -keyout server3.key -out server3.csr -nodes -subj "/C=AU/L=Sydney/O=Dgraph/CN=server3.dgraph.io" | ||
test1: cert | ||
@echo "Test 1: Alpha non-TLS, Live non-TLS" | ||
@(DGRAPH_BIN=$(DGRAPH_BIN) ./test.sh ./alpha_notls.sh ./live_notls.sh 0) | ||
|
||
client.csr client.key: | ||
openssl req -new -newkey rsa:$(KEYBITS) -keyout client.key -out client.csr -nodes -subj "/C=AU/L=Sydney/O=Dgraph/CN=client1.dgraph.io" | ||
test2: cert | ||
@echo "Test 2: Alpha non-TLS, Live TLS" | ||
@(DGRAPH_BIN=$(DGRAPH_BIN) ./test.sh ./alpha_notls.sh ./live_tls.sh 1) | ||
|
||
server_pass.key: | ||
openssl genrsa -aes256 -out server_pass.key -passout pass:$(PASS) $(KEYBITS) | ||
test3: cert | ||
@echo "Test 3: Alpha TLS, Live non-TLS" | ||
@(DGRAPH_BIN=$(DGRAPH_BIN) ./test.sh ./alpha_tls.sh ./live_notls.sh 1) | ||
|
||
client_pass.key: | ||
openssl genrsa -aes256 -out client_pass.key -passout pass:$(PASS) $(KEYBITS) | ||
test4: cert | ||
@echo "Test 4: Alpha TLS, Live TLS" | ||
@(DGRAPH_BIN=$(DGRAPH_BIN) ./test.sh ./alpha_tls.sh ./live_tls.sh 0) | ||
|
||
server_pass.csr: server_pass.key | ||
openssl req -new -key server_pass.key -out server_pass.csr -subj "/C=AU/L=Sydney/O=Dgraph/CN=server2.dgraph.io" -passin pass:$(PASS) -passout pass:$(PASS) | ||
test5: cert | ||
@echo "Test 5: Alpha TLS Auth, Live TLS" | ||
@(DGRAPH_BIN=$(DGRAPH_BIN) ./test.sh ./alpha_tls_auth.sh ./live_tls_auth.sh 0) | ||
|
||
client_pass.csr: client_pass.key | ||
openssl req -new -key client_pass.key -out client_pass.csr -subj "/C=AU/L=Sydney/O=Dgraph/CN=client2.dgraph.io" -passin pass:$(PASS) -passout pass:$(PASS) | ||
test6: cert | ||
@echo "Test 6: Alpha TLS reaload, Live TLS" | ||
@(DGRAPH_BIN=$(DGRAPH_BIN) RELOAD_TEST=1 ./test.sh ./alpha_tls.sh ./live_tls.sh 1) | ||
|
||
%.crt: %.csr ca.crt ca.key | ||
openssl ca -config openssl.cnf -days 365 -notext -cert ca.crt -keyfile ca.key -in $< -out $@ -batch | ||
clean: | ||
@echo git clean -d -f |
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 @@ | ||
#!/bin/bash | ||
set -e | ||
$DGRAPH_BIN alpha --lru_mb 2048 --zero 127.0.0.1:5081 &> alpha.log |
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 @@ | ||
#!/bin/bash | ||
set -e | ||
$DGRAPH_BIN alpha --tls_dir $PWD/tls --lru_mb 2048 --zero 127.0.0.1:5081 &> alpha.log |
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 @@ | ||
#!/bin/bash | ||
set -e | ||
$DGRAPH_BIN alpha --tls_dir $PWD/tls --tls_client_auth REQUIREANDVERIFY --lru_mb 2048 --zero 127.0.0.1:5081 &> alpha.log |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
#!/bin/bash | ||
set -e | ||
$DGRAPH_BIN live -d localhost:9080 -r data.rdf.gz -z 127.0.0.1:5081 |
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 @@ | ||
#!/bin/bash | ||
set -e | ||
$DGRAPH_BIN live -d localhost:9080 --tls_dir $PWD/tls -r data.rdf.gz -z 127.0.0.1:5081 |
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 @@ | ||
#!/bin/bash | ||
set -e | ||
$DGRAPH_BIN live -d localhost:9080 --tls_dir $PWD/tls --tls_server_name localhost -r data.rdf.gz -z 127.0.0.1:5081 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,33 +1,34 @@ | ||
#!/bin/bash | ||
trap "cleanup" EXIT | ||
|
||
killall -9 dgraph || true | ||
|
||
DGRAPH_ROOT=$GOPATH/src/github.com/dgraph-io/dgraph/dgraph | ||
function build { | ||
pushd $DGRAPH_ROOT > /dev/null | ||
go build . | ||
popd > /dev/null | ||
cleanup() { | ||
killall -INT dgraph >/dev/null 2>/dev/null | ||
} | ||
|
||
SERVER=$1 | ||
CLIENT=$2 | ||
ALPHA=$1 | ||
LIVE=$2 | ||
EXPECTED=$3 | ||
|
||
build "dgraph" | ||
|
||
$DGRAPH_ROOT/dgraph zero -w zw -o 1 > zero.log 2>&1 & | ||
$DGRAPH_BIN zero -w zw -o 1 > zero.log 2>&1 & | ||
sleep 5 | ||
|
||
$ALPHA >/dev/null 2>&1 & | ||
|
||
$SERVER > /dev/null 2>&1 & | ||
timeout 30s $CLIENT > client.log 2>&1 | ||
RESULT=$? | ||
# echo -e "Result $RESULT" | ||
if [ "x$RELOAD_TEST" != "x" ]; then | ||
trap '' HUP | ||
rm -f ./tls/ca.key | ||
$DGRAPH_BIN cert -d $PWD/tls -n localhost -c live --force | ||
# pkill -HUP dgraph alpha >/dev/null 2>/dev/null | ||
killall -HUP dgraph >/dev/null 2>/dev/null | ||
sleep 3 | ||
fi | ||
|
||
echo "$SERVER <-> $CLIENT: $RESULT (expected: $EXPECTED)" | ||
timeout 30s $LIVE > live.log 2>&1 | ||
RESULT=$? | ||
|
||
if [ $RESULT == $EXPECTED ]; then | ||
exit 0 | ||
else | ||
if [ $RESULT != $EXPECTED ]; then | ||
echo "$ALPHA <-> $LIVE: $RESULT != $EXPECTED" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
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