forked from fullstorydev/grpcurl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk-test-files.sh
executable file
·57 lines (42 loc) · 1.41 KB
/
mk-test-files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -e
cd "$(dirname $0)"
# Run this script to generate files used by tests.
echo "Creating protosets..."
protoc testing/test.proto \
--include_imports \
--descriptor_set_out=testing/test.protoset
protoc testing/example.proto \
--include_imports \
--descriptor_set_out=testing/example.protoset
protoc testing/jsonpb_test_proto/test_objects.proto \
--go_out=paths=source_relative:.
echo "Creating certs for TLS testing..."
if ! hash certstrap 2>/dev/null; then
# certstrap not found: try to install it
go get github.com/square/certstrap
go install github.com/square/certstrap
fi
function cs() {
certstrap --depot-path testing/tls "$@" --passphrase ""
}
rm -rf testing/tls
# Create CA
cs init --years 10 --common-name ca
# Create client cert
cs request-cert --common-name client
cs sign client --years 10 --CA ca
# Create server cert
cs request-cert --common-name server --ip 127.0.0.1 --domain localhost
cs sign server --years 10 --CA ca
# Create another server cert for error testing
cs request-cert --common-name other --ip 1.2.3.4 --domain foobar.com
cs sign other --years 10 --CA ca
# Create another CA and client cert for more
# error testing
cs init --years 10 --common-name wrong-ca
cs request-cert --common-name wrong-client
cs sign wrong-client --years 10 --CA wrong-ca
# Create expired cert
cs request-cert --common-name expired --ip 127.0.0.1 --domain localhost
cs sign expired --years 0 --CA ca