blob: 407f7dc2658eb1df22f5a7bb07ef6c4364e08954 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001#!/bin/bash
2
3set -e
4
5cd "$(dirname $0)"
6
7# Run this script to generate files used by tests.
8
9echo "Creating protosets..."
10protoc testing/test.proto \
11 --include_imports \
12 --descriptor_set_out=testing/test.protoset
13
14protoc testing/example.proto \
15 --include_imports \
16 --descriptor_set_out=testing/example.protoset
17
18echo "Creating certs for TLS testing..."
19if ! hash certstrap 2>/dev/null; then
20 # certstrap not found: try to install it
21 go get github.com/square/certstrap
22 go install github.com/square/certstrap
23fi
24
25function cs() {
26 certstrap --depot-path testing/tls "$@" --passphrase ""
27}
28
29rm -rf testing/tls
30
31# Create CA
32cs init --years 10 --common-name ca
33
34# Create client cert
35cs request-cert --common-name client
36cs sign client --years 10 --CA ca
37
38# Create server cert
39cs request-cert --common-name server --ip 127.0.0.1 --domain localhost
40cs sign server --years 10 --CA ca
41
42# Create another server cert for error testing
43cs request-cert --common-name other --ip 1.2.3.4 --domain foobar.com
44cs sign other --years 10 --CA ca
45
46# Create another CA and client cert for more
47# error testing
48cs init --years 10 --common-name wrong-ca
49cs request-cert --common-name wrong-client
50cs sign wrong-client --years 10 --CA wrong-ca
51
52# Create expired cert
53cs request-cert --common-name expired --ip 127.0.0.1 --domain localhost
54cs sign expired --years 0 --CA ca