@@ -66,7 +66,9 @@ def test_get_auth_grpc_endpoint(
6666 ),
6767 ),
6868)
69- def test_publish_endpoint (ctx , auth_relation , backend_container , leader , expected ):
69+ def test_publish_endpoint_without_tls (
70+ ctx , auth_relation , backend_container , leader , expected
71+ ):
7072 # GIVEN an auth integration
7173 auth_relation = dataclasses .replace (auth_relation )
7274
@@ -84,3 +86,49 @@ def test_publish_endpoint(ctx, auth_relation, backend_container, leader, expecte
8486 # THEN the leader unit will publish it's grpc server endpoint
8587 relation_out = state_out .get_relation (auth_relation .id )
8688 assert relation_out .local_app_data == expected
89+
90+
91+ @pytest .mark .parametrize (
92+ "leader, expected" ,
93+ (
94+ (False , {}),
95+ (
96+ True ,
97+ {
98+ "grpc_server_host" : json .dumps (
99+ "litmus-backend-k8s.test.svc.cluster.local"
100+ ),
101+ "grpc_server_port" : json .dumps (8001 ),
102+ "insecure" : json .dumps (False ),
103+ "version" : json .dumps (0 ),
104+ },
105+ ),
106+ ),
107+ )
108+ def test_publish_endpoint_with_tls (
109+ ctx ,
110+ auth_relation ,
111+ tls_certificates_relation ,
112+ patch_cert_and_key ,
113+ backend_container ,
114+ leader ,
115+ expected ,
116+ ):
117+ # GIVEN an auth integration
118+ auth_relation = dataclasses .replace (auth_relation )
119+ tls_certificates_relation = dataclasses .replace (tls_certificates_relation )
120+
121+ # WHEN a relation_changed event fires
122+ state_out = ctx .run (
123+ state = State (
124+ relations = {auth_relation , tls_certificates_relation },
125+ containers = {backend_container },
126+ leader = leader ,
127+ model = Model (name = "test" ),
128+ ),
129+ event = ctx .on .relation_changed (auth_relation ),
130+ )
131+
132+ # THEN the leader unit will publish it's grpc server endpoint
133+ relation_out = state_out .get_relation (auth_relation .id )
134+ assert relation_out .local_app_data == expected
0 commit comments