@@ -127,7 +127,7 @@ func TestLookupSuccess(t *testing.T) {
127
127
BrokerServiceUrl : proto .String ("pulsar://broker-1:6650" ),
128
128
},
129
129
},
130
- }, url )
130
+ }, url , false )
131
131
132
132
lr , err := ls .Lookup ("my-topic" )
133
133
assert .NoError (t , err )
@@ -137,6 +137,38 @@ func TestLookupSuccess(t *testing.T) {
137
137
assert .Equal (t , "pulsar://broker-1:6650" , lr .PhysicalAddr .String ())
138
138
}
139
139
140
+ func TestTlsLookupSuccess (t * testing.T ) {
141
+ url , err := url .Parse ("pulsar+ssl://example:6651" )
142
+ assert .NoError (t , err )
143
+
144
+ ls := NewLookupService (& mockedRPCClient {
145
+ t : t ,
146
+
147
+ expectedRequests : []pb.CommandLookupTopic {
148
+ {
149
+ RequestId : proto .Uint64 (1 ),
150
+ Topic : proto .String ("my-topic" ),
151
+ Authoritative : proto .Bool (false ),
152
+ },
153
+ },
154
+ mockedResponses : []pb.CommandLookupTopicResponse {
155
+ {
156
+ RequestId : proto .Uint64 (1 ),
157
+ Response : responseType (pb .CommandLookupTopicResponse_Connect ),
158
+ Authoritative : proto .Bool (true ),
159
+ BrokerServiceUrlTls : proto .String ("pulsar+ssl://broker-1:6651" ),
160
+ },
161
+ },
162
+ }, url , true )
163
+
164
+ lr , err := ls .Lookup ("my-topic" )
165
+ assert .NoError (t , err )
166
+ assert .NotNil (t , lr )
167
+
168
+ assert .Equal (t , "pulsar+ssl://broker-1:6651" , lr .LogicalAddr .String ())
169
+ assert .Equal (t , "pulsar+ssl://broker-1:6651" , lr .PhysicalAddr .String ())
170
+ }
171
+
140
172
func TestLookupWithProxy (t * testing.T ) {
141
173
url , err := url .Parse ("pulsar://example:6650" )
142
174
assert .NoError (t , err )
@@ -160,7 +192,7 @@ func TestLookupWithProxy(t *testing.T) {
160
192
ProxyThroughServiceUrl : proto .Bool (true ),
161
193
},
162
194
},
163
- }, url )
195
+ }, url , false )
164
196
165
197
lr , err := ls .Lookup ("my-topic" )
166
198
assert .NoError (t , err )
@@ -170,6 +202,39 @@ func TestLookupWithProxy(t *testing.T) {
170
202
assert .Equal (t , "pulsar://example:6650" , lr .PhysicalAddr .String ())
171
203
}
172
204
205
+ func TestTlsLookupWithProxy (t * testing.T ) {
206
+ url , err := url .Parse ("pulsar+ssl://example:6651" )
207
+ assert .NoError (t , err )
208
+
209
+ ls := NewLookupService (& mockedRPCClient {
210
+ t : t ,
211
+
212
+ expectedRequests : []pb.CommandLookupTopic {
213
+ {
214
+ RequestId : proto .Uint64 (1 ),
215
+ Topic : proto .String ("my-topic" ),
216
+ Authoritative : proto .Bool (false ),
217
+ },
218
+ },
219
+ mockedResponses : []pb.CommandLookupTopicResponse {
220
+ {
221
+ RequestId : proto .Uint64 (1 ),
222
+ Response : responseType (pb .CommandLookupTopicResponse_Connect ),
223
+ Authoritative : proto .Bool (true ),
224
+ BrokerServiceUrlTls : proto .String ("pulsar+ssl://broker-1:6651" ),
225
+ ProxyThroughServiceUrl : proto .Bool (true ),
226
+ },
227
+ },
228
+ }, url , true )
229
+
230
+ lr , err := ls .Lookup ("my-topic" )
231
+ assert .NoError (t , err )
232
+ assert .NotNil (t , lr )
233
+
234
+ assert .Equal (t , "pulsar+ssl://broker-1:6651" , lr .LogicalAddr .String ())
235
+ assert .Equal (t , "pulsar+ssl://example:6651" , lr .PhysicalAddr .String ())
236
+ }
237
+
173
238
func TestLookupWithRedirect (t * testing.T ) {
174
239
url , err := url .Parse ("pulsar://example:6650" )
175
240
assert .NoError (t , err )
@@ -204,7 +269,7 @@ func TestLookupWithRedirect(t *testing.T) {
204
269
BrokerServiceUrl : proto .String ("pulsar://broker-1:6650" ),
205
270
},
206
271
},
207
- }, url )
272
+ }, url , false )
208
273
209
274
lr , err := ls .Lookup ("my-topic" )
210
275
assert .NoError (t , err )
@@ -214,6 +279,50 @@ func TestLookupWithRedirect(t *testing.T) {
214
279
assert .Equal (t , "pulsar://broker-1:6650" , lr .PhysicalAddr .String ())
215
280
}
216
281
282
+ func TestTlsLookupWithRedirect (t * testing.T ) {
283
+ url , err := url .Parse ("pulsar+ssl://example:6651" )
284
+ assert .NoError (t , err )
285
+
286
+ ls := NewLookupService (& mockedRPCClient {
287
+ t : t ,
288
+ expectedURL : "pulsar+ssl://broker-2:6651" ,
289
+
290
+ expectedRequests : []pb.CommandLookupTopic {
291
+ {
292
+ RequestId : proto .Uint64 (1 ),
293
+ Topic : proto .String ("my-topic" ),
294
+ Authoritative : proto .Bool (false ),
295
+ },
296
+ {
297
+ RequestId : proto .Uint64 (2 ),
298
+ Topic : proto .String ("my-topic" ),
299
+ Authoritative : proto .Bool (true ),
300
+ },
301
+ },
302
+ mockedResponses : []pb.CommandLookupTopicResponse {
303
+ {
304
+ RequestId : proto .Uint64 (1 ),
305
+ Response : responseType (pb .CommandLookupTopicResponse_Redirect ),
306
+ Authoritative : proto .Bool (true ),
307
+ BrokerServiceUrlTls : proto .String ("pulsar+ssl://broker-2:6651" ),
308
+ },
309
+ {
310
+ RequestId : proto .Uint64 (2 ),
311
+ Response : responseType (pb .CommandLookupTopicResponse_Connect ),
312
+ Authoritative : proto .Bool (true ),
313
+ BrokerServiceUrlTls : proto .String ("pulsar+ssl://broker-1:6651" ),
314
+ },
315
+ },
316
+ }, url , true )
317
+
318
+ lr , err := ls .Lookup ("my-topic" )
319
+ assert .NoError (t , err )
320
+ assert .NotNil (t , lr )
321
+
322
+ assert .Equal (t , "pulsar+ssl://broker-1:6651" , lr .LogicalAddr .String ())
323
+ assert .Equal (t , "pulsar+ssl://broker-1:6651" , lr .PhysicalAddr .String ())
324
+ }
325
+
217
326
func TestLookupWithInvalidUrlResponse (t * testing.T ) {
218
327
url , err := url .Parse ("pulsar://example:6650" )
219
328
assert .NoError (t , err )
@@ -237,7 +346,7 @@ func TestLookupWithInvalidUrlResponse(t *testing.T) {
237
346
ProxyThroughServiceUrl : proto .Bool (false ),
238
347
},
239
348
},
240
- }, url )
349
+ }, url , false )
241
350
242
351
lr , err := ls .Lookup ("my-topic" )
243
352
assert .Error (t , err )
@@ -265,7 +374,7 @@ func TestLookupWithLookupFailure(t *testing.T) {
265
374
Authoritative : proto .Bool (true ),
266
375
},
267
376
},
268
- }, url )
377
+ }, url , false )
269
378
270
379
lr , err := ls .Lookup ("my-topic" )
271
380
assert .Error (t , err )
0 commit comments