func expectStatefulSetTLSConfig(t *testing.T, g *gomega.GomegaWithT, sc *solr.SolrCloud, needsPkcs12InitContainer bool) *appsv1.StatefulSet {
	ctx := context.TODO()
	stateful := &appsv1.StatefulSet{}
	g.Eventually(func() error { return testClient.Get(ctx, expectedStatefulSetName, stateful) }, timeout).Should(gomega.Succeed())
	podTemplate := &stateful.Spec.Template
	expectTLSConfigOnPodTemplate(t, sc.Spec.SolrTLS, podTemplate, needsPkcs12InitContainer)

	// Check HTTPS cluster prop setup container
	assert.NotNil(t, podTemplate.Spec.InitContainers)
	var zkSetupInitContainer *corev1.Container = nil
	for _, cnt := range podTemplate.Spec.InitContainers {
		if cnt.Name == "setup-zk" {
			zkSetupInitContainer = &cnt
			break
		}
	}
	expCmd := "/opt/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost ${ZK_HOST} -cmd clusterprop -name urlScheme -val https"
	if sc.Spec.SolrTLS != nil {
		assert.NotNil(t, zkSetupInitContainer, "Didn't find the zk-setup InitContainer in the sts!")
		if zkSetupInitContainer != nil {
			assert.Equal(t, "library/solr:7.7.0", zkSetupInitContainer.Image)
			assert.Equal(t, 3, len(zkSetupInitContainer.Command), "Wrong command length for zk-setup init container")
			assert.Contains(t, zkSetupInitContainer.Command[2], expCmd, "ZK Setup command does not set urlScheme")
			expNumVars := 3
			if sc.Spec.SolrSecurity != nil && sc.Spec.SolrSecurity.BasicAuthSecret == "" {
				expNumVars = 4 // one more for SECURITY_JSON
			}
			assert.Equal(t, expNumVars, len(zkSetupInitContainer.Env), "Wrong number of envVars for zk-setup init container")
		}
	} else {
		assert.Nil(t, zkSetupInitContainer, "Shouldn't find the zk-setup InitContainer in the sts, when not using https!")
	}
	return stateful
}
// ensures the TLS settings are applied correctly to the STS
ensures the TLS settings are applied correctly to the STS
// ensures the TLS settings are applied correctly to the STS
func expectStatefulSetTLSConfig(t *testing.T, g *gomega.GomegaWithT, sc *solr.SolrCloud, needsPkcs12InitContainer bool) *appsv1.StatefulSet {
	ctx := context.TODO()
	stateful := &appsv1.StatefulSet{}
	g.Eventually(func() error { return testClient.Get(ctx, expectedStatefulSetName, stateful) }, timeout).Should(gomega.Succeed())
	podTemplate := &stateful.Spec.Template
	expectTLSConfigOnPodTemplate(t, sc.Spec.SolrTLS, podTemplate, needsPkcs12InitContainer)
	assert.NotNil(t, podTemplate.Spec.InitContainers)
	var zkSetupInitContainer *corev1.Container = nil
	for _, cnt := range podTemplate.Spec.InitContainers {
		if cnt.Name == "setup-zk" {
			zkSetupInitContainer = &cnt
			break
		}
	}
	expCmd := "/opt/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost ${ZK_HOST} -cmd clusterprop -name urlScheme -val https"
	if sc.Spec.SolrTLS != nil {
		assert.NotNil(t, zkSetupInitContainer, "Didn't find the zk-setup InitContainer in the sts!")
		if zkSetupInitContainer != nil {
			assert.Equal(t, "library/solr:7.7.0", zkSetupInitContainer.Image)
			assert.Equal(t, 3, len(zkSetupInitContainer.Command), "Wrong command length for zk-setup init container")
			assert.Contains(t, zkSetupInitContainer.Command[2], expCmd, "ZK Setup command does not set urlScheme")
			expNumVars := 3
			if sc.Spec.SolrSecurity != nil && sc.Spec.SolrSecurity.BasicAuthSecret == "" {
				expNumVars = 4 
			}
			assert.Equal(t, expNumVars, len(zkSetupInitContainer.Env), "Wrong number of envVars for zk-setup init container")
		}
	} else {
		assert.Nil(t, zkSetupInitContainer, "Shouldn't find the zk-setup InitContainer in the sts, when not using https!")
	}
	return stateful
}
func expectStatefulSetTLSConfig ( t * testing . T , g * gomega . GomegaWithT , sc * solr . SolrCloud , needsPkcs12InitContainer bool ) * appsv1 . StatefulSet { ctx := context . TODO ( ) stateful := & appsv1 . StatefulSet { } g . Eventually ( func ( ) error { return testClient . Get ( ctx , expectedStatefulSetName , stateful ) } , timeout ) . Should ( gomega . Succeed ( ) ) podTemplate := & stateful . Spec . Template expectTLSConfigOnPodTemplate ( t , sc . Spec . SolrTLS , podTemplate , needsPkcs12InitContainer ) assert . NotNil ( t , podTemplate . Spec . InitContainers ) var zkSetupInitContainer * corev1 . Container = nil for _ , cnt := range podTemplate . Spec . InitContainers { if cnt . Name == " " { zkSetupInitContainer = & cnt break } } expCmd := " " if sc . Spec . SolrTLS != nil { assert . NotNil ( t , zkSetupInitContainer , " " ) if zkSetupInitContainer != nil { assert . Equal ( t , " " , zkSetupInitContainer . Image ) assert . Equal ( t , 3 , len ( zkSetupInitContainer . Command ) , " " ) assert . Contains ( t , zkSetupInitContainer . Command [ 2 ] , expCmd , " " ) expNumVars := 3 if sc . Spec . SolrSecurity != nil && sc . Spec . SolrSecurity . BasicAuthSecret == " " { expNumVars = 4 } assert . Equal ( t , expNumVars , len ( zkSetupInitContainer . Env ) , " " ) } } else { assert . Nil ( t , zkSetupInitContainer , " " ) } return stateful }
ensures the TLS settings are applied correctly to the STS
ensures the TLS settings are applied correctly to the STS
// Check HTTPS cluster prop setup container // one more for SECURITY_JSON