@@ -71,43 +71,44 @@ var _ = Describe("RabbitMQ Client", func() {
7171 })
7272
7373 It ("returns client info with correct credentials" , func () {
74- podIP := "10.0.0.1 "
75- info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podIP )
74+ podName := "test-cluster-server-0 "
75+ info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podName )
7676 Expect (err ).NotTo (HaveOccurred ())
7777 Expect (info ).NotTo (BeNil ())
7878 Expect (info .Username ).To (Equal ("test-user" ))
7979 Expect (info .Password ).To (Equal ("test-password" ))
8080 })
8181
82- It ("returns the correct base URL for non-TLS with pod IP " , func () {
83- podIP := "10.0.0.1 "
84- info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podIP )
82+ It ("returns the correct base URL for non-TLS with pod DNS name " , func () {
83+ podName := "test-cluster-server-0 "
84+ info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podName )
8585 Expect (err ).NotTo (HaveOccurred ())
86- Expect (info .BaseURL ).To (Equal ("http://10.0.0.1 :15672" ))
86+ Expect (info .BaseURL ).To (Equal ("http://test-cluster-server-0.test-cluster-nodes.test-namespace.svc :15672" ))
8787 })
8888
89- It ("returns the correct base URL for TLS with pod IP " , func () {
89+ It ("returns the correct base URL for TLS with pod DNS name " , func () {
9090 rmq .Spec .TLS .SecretName = "tls-secret"
9191 rmq .Spec .TLS .DisableNonTLSListeners = true
92- podIP := "10.0.0.2 "
93- info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podIP )
92+ podName := "test-cluster-server-1 "
93+ info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podName )
9494 Expect (err ).NotTo (HaveOccurred ())
95- Expect (info .BaseURL ).To (Equal ("https://10.0.0.2 :15671" ))
95+ Expect (info .BaseURL ).To (Equal ("https://test-cluster-server-1.test-cluster-nodes.test-namespace.svc :15671" ))
9696 })
9797
98- It ("returns an HTTP transport for TLS" , func () {
98+ It ("returns an HTTP transport for TLS with correct ServerName " , func () {
9999 rmq .Spec .TLS .SecretName = "tls-secret"
100100 rmq .Spec .TLS .DisableNonTLSListeners = true
101- podIP := "10.0.0.1 "
102- info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podIP )
101+ podName := "test-cluster-server-0 "
102+ info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podName )
103103 Expect (err ).NotTo (HaveOccurred ())
104104 Expect (info .Transport ).NotTo (BeNil ())
105105 Expect (info .Transport .TLSClientConfig ).NotTo (BeNil ())
106+ Expect (info .Transport .TLSClientConfig .ServerName ).To (Equal ("test-cluster-server-0.test-cluster-nodes.test-namespace.svc" ))
106107 })
107108
108109 It ("returns nil transport for non-TLS" , func () {
109- podIP := "10.0.0.1 "
110- info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podIP )
110+ podName := "test-cluster-server-0 "
111+ info , err := GetClientInfoForPod (ctx , k8sClient , rmq , podName )
111112 Expect (err ).NotTo (HaveOccurred ())
112113 Expect (info .Transport ).To (BeNil ())
113114 })
@@ -122,8 +123,8 @@ var _ = Describe("RabbitMQ Client", func() {
122123 })
123124
124125 It ("returns an error" , func () {
125- podIP := "10.0.0.1 "
126- _ , err := GetClientInfoForPod (ctx , k8sClient , rmq , podIP )
126+ podName := "test-cluster-server-0 "
127+ _ , err := GetClientInfoForPod (ctx , k8sClient , rmq , podName )
127128 Expect (err ).To (HaveOccurred ())
128129 Expect (err .Error ()).To (ContainSubstring ("failed to get default user secret" ))
129130 })
@@ -141,8 +142,8 @@ var _ = Describe("RabbitMQ Client", func() {
141142
142143 Context ("when TLS is disabled" , func () {
143144 It ("returns a non-TLS client" , func () {
144- podIP := "10.0.0.1 "
145- client , err := GetRabbitmqClientForPod (ctx , k8sClient , rmq , podIP )
145+ podName := "test-cluster-server-0 "
146+ client , err := GetRabbitmqClientForPod (ctx , k8sClient , rmq , podName )
146147 Expect (err ).NotTo (HaveOccurred ())
147148 Expect (client ).NotTo (BeNil ())
148149 })
@@ -152,8 +153,8 @@ var _ = Describe("RabbitMQ Client", func() {
152153 It ("returns a TLS client" , func () {
153154 rmq .Spec .TLS .SecretName = "tls-secret"
154155 rmq .Spec .TLS .DisableNonTLSListeners = true
155- podIP := "10.0.0.1 "
156- client , err := GetRabbitmqClientForPod (ctx , k8sClient , rmq , podIP )
156+ podName := "test-cluster-server-0 "
157+ client , err := GetRabbitmqClientForPod (ctx , k8sClient , rmq , podName )
157158 Expect (err ).NotTo (HaveOccurred ())
158159 Expect (client ).NotTo (BeNil ())
159160 })
@@ -168,8 +169,8 @@ var _ = Describe("RabbitMQ Client", func() {
168169 })
169170
170171 It ("returns an error" , func () {
171- podIP := "10.0.0.1 "
172- _ , err := GetRabbitmqClientForPod (ctx , k8sClient , rmq , podIP )
172+ podName := "test-cluster-server-0 "
173+ _ , err := GetRabbitmqClientForPod (ctx , k8sClient , rmq , podName )
173174 Expect (err ).To (HaveOccurred ())
174175 Expect (err .Error ()).To (ContainSubstring ("failed to get default user secret" ))
175176 })
0 commit comments