blob: 1f3116430a257e020f22420c755a561c33d8cca1 (
plain)
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
|
module ProxyHelper
def x509_certificate(host)
License::Management.root.join("tmp/#{host}.crt")
end
def generate_self_signed_certificate_for(host)
Dir.chdir License::Management.root.join('tmp') do
system([
"rm -f #{host}.*",
"/usr/bin/openssl req -x509 -newkey rsa:4096 -keyout #{host}.key -out #{host}.crt -days 999 -nodes -subj '/C=/ST=/L=/O=/OU=/CN=*.test' -addext 'subjectAltName=DNS:nuget.test,DNS:rubygems.test,DNS:goproxy.test,DNS:maven.test,DNS:pypi.test,DNS:npm.test,DNS:composer.test'",
"cat #{host}.* > #{host}.pem"
].join("&&"))
end
end
def start_proxy_server
@proxy_server_pid ||=
begin
generate_self_signed_certificate_for('wildcard.test')
spawn("/usr/sbin/haproxy -f #{fixture_file('haproxy.cfg')}")
end
end
def stop_proxy_server
return if !defined?(@proxy_server_pid) || @proxy_server_pid.nil?
Process.kill("TERM", @proxy_server_pid)
Process.wait(@proxy_server_pid)
@proxy_server_pid = nil
end
end
RSpec.configure do |config|
config.include(ProxyHelper, type: :integration)
config.after(:example, type: :integration) do
stop_proxy_server
system("rm -f /usr/local/share/ca-certificates/custom.*")
system("rm -f /usr/lib/ssl/certs/custom.*")
system("update-ca-certificates -v")
system("c_rehash -v")
system("/opt/asdf/installs/mono/6.8.0.123/bin/cert-sync /etc/ssl/certs/ca-certificates.crt")
end
end
|