@@ -47,12 +47,25 @@ func TestGenerate(t *testing.T) {
47
47
Port : 443 ,
48
48
},
49
49
},
50
+ TLSPassthroughServers : []dataplane.Layer4VirtualServer {
51
+ {
52
+ Hostname : "app.example.com" ,
53
+ Port : 443 ,
54
+ UpstreamName : "stream_up" ,
55
+ },
56
+ },
50
57
Upstreams : []dataplane.Upstream {
51
58
{
52
59
Name : "up" ,
53
60
Endpoints : nil ,
54
61
},
55
62
},
63
+ StreamUpstreams : []dataplane.Upstream {
64
+ {
65
+ Name : "stream_up" ,
66
+ Endpoints : nil ,
67
+ },
68
+ },
56
69
BackendGroups : []dataplane.BackendGroup {bg },
57
70
SSLKeyPairs : map [dataplane.SSLKeyPairID ]dataplane.SSLKeyPair {
58
71
"test-keypair" : {
@@ -81,7 +94,7 @@ func TestGenerate(t *testing.T) {
81
94
82
95
files := generator .Generate (conf )
83
96
84
- g .Expect (files ).To (HaveLen (6 ))
97
+ g .Expect (files ).To (HaveLen (7 ))
85
98
arrange := func (i , j int ) bool {
86
99
return files [i ].Path < files [j ].Path
87
100
}
@@ -98,7 +111,7 @@ func TestGenerate(t *testing.T) {
98
111
// Note: this only verifies that Generate() returns a byte array with upstream, server, and split_client blocks.
99
112
// It does not test the correctness of those blocks. That functionality is covered by other tests in this package.
100
113
g .Expect (httpCfg ).To (ContainSubstring ("listen 80" ))
101
- g .Expect (httpCfg ).To (ContainSubstring ("listen 443 " ))
114
+ g .Expect (httpCfg ).To (ContainSubstring ("listen unix:/var/run/nginx/https443.sock " ))
102
115
g .Expect (httpCfg ).To (ContainSubstring ("upstream" ))
103
116
g .Expect (httpCfg ).To (ContainSubstring ("split_clients" ))
104
117
@@ -127,4 +140,12 @@ func TestGenerate(t *testing.T) {
127
140
Path : "/etc/nginx/secrets/test-keypair.pem" ,
128
141
Content : []byte ("test-cert\n test-key" ),
129
142
}))
143
+
144
+ g .Expect (files [6 ].Path ).To (Equal ("/etc/nginx/stream-conf.d/stream.conf" ))
145
+ g .Expect (files [6 ].Type ).To (Equal (file .TypeRegular ))
146
+ streamCfg := string (files [6 ].Content )
147
+ g .Expect (streamCfg ).To (ContainSubstring ("listen unix:/var/run/nginx/app.example.com-443.sock" ))
148
+ g .Expect (streamCfg ).To (ContainSubstring ("listen 443" ))
149
+ g .Expect (streamCfg ).To (ContainSubstring ("app.example.com unix:/var/run/nginx/app.example.com-443.sock" ))
150
+ g .Expect (streamCfg ).To (ContainSubstring ("example.com unix:/var/run/nginx/https443.sock" ))
130
151
}
0 commit comments