@@ -123,6 +123,8 @@ public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
123
123
124
124
private boolean isEnterprise = false ;
125
125
126
+ private boolean hasTlsPorts = false ;
127
+
126
128
/**
127
129
* Creates a new couchbase container with the default image and version.
128
130
* @deprecated use {@link #CouchbaseContainer(DockerImageName)} instead
@@ -345,6 +347,7 @@ protected void containerIsStarting(final InspectContainerResponse containerInfo)
345
347
346
348
timePhase ("waitUntilNodeIsOnline" , this ::waitUntilNodeIsOnline );
347
349
timePhase ("initializeIsEnterprise" , this ::initializeIsEnterprise );
350
+ timePhase ("initializeHasTlsPorts" , this ::initializeHasTlsPorts );
348
351
timePhase ("renameNode" , this ::renameNode );
349
352
timePhase ("initializeServices" , this ::initializeServices );
350
353
timePhase ("setMemoryQuotas" , this ::setMemoryQuotas );
@@ -394,6 +397,31 @@ private void initializeIsEnterprise() {
394
397
}
395
398
}
396
399
400
+ /**
401
+ * Initializes the {@link #hasTlsPorts} flag.
402
+ * <p>
403
+ * Community Edition might support TLS one happy day, so use a "supports TLS" flag separate from
404
+ * the "enterprise edition" flag.
405
+ */
406
+ private void initializeHasTlsPorts () {
407
+ @ Cleanup
408
+ Response response = doHttpRequest (MGMT_PORT , "/pools/default/nodeServices" , "GET" , null , true );
409
+
410
+ try {
411
+ String clusterTopology = response .body ().string ();
412
+ hasTlsPorts =
413
+ !MAPPER
414
+ .readTree (clusterTopology )
415
+ .path ("nodesExt" )
416
+ .path (0 )
417
+ .path ("services" )
418
+ .path ("mgmtSSL" )
419
+ .isMissingNode ();
420
+ } catch (IOException e ) {
421
+ throw new IllegalStateException ("Couchbase /pools/default/nodeServices did not return valid JSON" );
422
+ }
423
+ }
424
+
397
425
/**
398
426
* Rebinds/renames the internal hostname.
399
427
* <p>
@@ -503,33 +531,45 @@ private void configureExternalPorts() {
503
531
final FormBody .Builder builder = new FormBody .Builder ();
504
532
builder .add ("hostname" , getHost ());
505
533
builder .add ("mgmt" , Integer .toString (getMappedPort (MGMT_PORT )));
506
- builder .add ("mgmtSSL" , Integer .toString (getMappedPort (MGMT_SSL_PORT )));
534
+ if (hasTlsPorts ) {
535
+ builder .add ("mgmtSSL" , Integer .toString (getMappedPort (MGMT_SSL_PORT )));
536
+ }
507
537
508
538
if (enabledServices .contains (CouchbaseService .KV )) {
509
539
builder .add ("kv" , Integer .toString (getMappedPort (KV_PORT )));
510
- builder .add ("kvSSL" , Integer .toString (getMappedPort (KV_SSL_PORT )));
511
540
builder .add ("capi" , Integer .toString (getMappedPort (VIEW_PORT )));
512
- builder .add ("capiSSL" , Integer .toString (getMappedPort (VIEW_SSL_PORT )));
541
+ if (hasTlsPorts ) {
542
+ builder .add ("kvSSL" , Integer .toString (getMappedPort (KV_SSL_PORT )));
543
+ builder .add ("capiSSL" , Integer .toString (getMappedPort (VIEW_SSL_PORT )));
544
+ }
513
545
}
514
546
515
547
if (enabledServices .contains (CouchbaseService .QUERY )) {
516
548
builder .add ("n1ql" , Integer .toString (getMappedPort (QUERY_PORT )));
517
- builder .add ("n1qlSSL" , Integer .toString (getMappedPort (QUERY_SSL_PORT )));
549
+ if (hasTlsPorts ) {
550
+ builder .add ("n1qlSSL" , Integer .toString (getMappedPort (QUERY_SSL_PORT )));
551
+ }
518
552
}
519
553
520
554
if (enabledServices .contains (CouchbaseService .SEARCH )) {
521
555
builder .add ("fts" , Integer .toString (getMappedPort (SEARCH_PORT )));
522
- builder .add ("ftsSSL" , Integer .toString (getMappedPort (SEARCH_SSL_PORT )));
556
+ if (hasTlsPorts ) {
557
+ builder .add ("ftsSSL" , Integer .toString (getMappedPort (SEARCH_SSL_PORT )));
558
+ }
523
559
}
524
560
525
561
if (enabledServices .contains (CouchbaseService .ANALYTICS )) {
526
562
builder .add ("cbas" , Integer .toString (getMappedPort (ANALYTICS_PORT )));
527
- builder .add ("cbasSSL" , Integer .toString (getMappedPort (ANALYTICS_SSL_PORT )));
563
+ if (hasTlsPorts ) {
564
+ builder .add ("cbasSSL" , Integer .toString (getMappedPort (ANALYTICS_SSL_PORT )));
565
+ }
528
566
}
529
567
530
568
if (enabledServices .contains (CouchbaseService .EVENTING )) {
531
569
builder .add ("eventingAdminPort" , Integer .toString (getMappedPort (EVENTING_PORT )));
532
- builder .add ("eventingSSL" , Integer .toString (getMappedPort (EVENTING_SSL_PORT )));
570
+ if (hasTlsPorts ) {
571
+ builder .add ("eventingSSL" , Integer .toString (getMappedPort (EVENTING_SSL_PORT )));
572
+ }
533
573
}
534
574
535
575
@ Cleanup
0 commit comments