@@ -30,8 +30,10 @@ class ResultBackendConnectionSecretTest(unittest.TestCase):
30
30
"user" : "someuser" ,
31
31
"pass" : "somepass" ,
32
32
"host" : "somehost" ,
33
+ "protocol" : "postgresql" ,
33
34
"port" : 7777 ,
34
35
"db" : "somedb" ,
36
+ "sslmode" : "allow" ,
35
37
}
36
38
37
39
def test_should_not_generate_a_document_if_using_existing_secret (self ):
@@ -73,6 +75,19 @@ def test_default_connection(self):
73
75
== connection
74
76
)
75
77
78
+ def test_should_default_to_custom_metadata_db_connection_with_pgbouncer_overrides (self ):
79
+ values = {
80
+ "pgbouncer" : {"enabled" : True },
81
+ "data" : {"metadataConnection" : {** self .non_chart_database_values }},
82
+ }
83
+ connection = self ._get_connection (values )
84
+
85
+ # host, port, dbname still get overridden
86
+ assert (
87
+ "db+postgresql://someuser:somepass@RELEASE-NAME-pgbouncer:6543"
88
+ "/RELEASE-NAME-result-backend?sslmode=allow" == connection
89
+ )
90
+
76
91
def test_should_set_pgbouncer_overrides_when_enabled (self ):
77
92
values = {"pgbouncer" : {"enabled" : True }}
78
93
connection = self ._get_connection (values )
@@ -93,32 +108,48 @@ def test_should_set_pgbouncer_overrides_with_non_chart_database_when_enabled(sel
93
108
# host, port, dbname still get overridden even with an non-chart db
94
109
assert (
95
110
"db+postgresql://someuser:somepass@RELEASE-NAME-pgbouncer:6543"
96
- "/RELEASE-NAME-result-backend?sslmode=disable " == connection
111
+ "/RELEASE-NAME-result-backend?sslmode=allow " == connection
97
112
)
98
113
114
+ def test_should_default_to_custom_metadata_db_connection (self ):
115
+ values = {
116
+ "data" : {"metadataConnection" : {** self .non_chart_database_values }},
117
+ }
118
+ connection = self ._get_connection (values )
119
+
120
+ assert "db+postgresql://someuser:somepass@somehost:7777/somedb?sslmode=allow" == connection
121
+
99
122
def test_should_correctly_use_non_chart_database (self ):
123
+ values = {"data" : {"resultBackendConnection" : {** self .non_chart_database_values }}}
124
+ connection = self ._get_connection (values )
125
+
126
+ assert "db+postgresql://someuser:somepass@somehost:7777/somedb?sslmode=allow" == connection
127
+
128
+ def test_should_support_non_postgres_db (self ):
100
129
values = {
101
130
"data" : {
102
131
"resultBackendConnection" : {
103
132
** self .non_chart_database_values ,
104
- "sslmode " : "require " ,
133
+ "protocol " : "mysql " ,
105
134
}
106
135
}
107
136
}
108
137
connection = self ._get_connection (values )
109
138
110
- assert "db+postgresql://someuser:somepass@somehost:7777/somedb?sslmode=require" == connection
139
+ # sslmode is only added for postgresql
140
+ assert "db+mysql://someuser:somepass@somehost:7777/somedb" == connection
111
141
112
- def test_should_support_non_postgres_db (self ):
142
+ def test_should_correctly_use_non_chart_database_when_both_db_are_external (self ):
113
143
values = {
114
144
"data" : {
145
+ "metadataConnection" : {** self .non_chart_database_values },
115
146
"resultBackendConnection" : {
116
147
** self .non_chart_database_values ,
117
- "protocol" : "mysql" ,
118
- }
148
+ "user" : "anotheruser" ,
149
+ "pass" : "anotherpass" ,
150
+ },
119
151
}
120
152
}
121
153
connection = self ._get_connection (values )
122
154
123
- # sslmode is only added for postgresql
124
- assert "db+mysql://someuser:somepass@somehost:7777/somedb" == connection
155
+ assert "db+postgresql://anotheruser:anotherpass@somehost:7777/somedb?sslmode=allow" == connection
0 commit comments