qontract-reconcile 0.10.1rc1202__py3-none-any.whl → 0.10.2.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qontract_reconcile-0.10.2.dev1.dist-info/METADATA +500 -0
- {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/RECORD +12 -130
- {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/WHEEL +1 -2
- {qontract_reconcile-0.10.1rc1202.dist-info → qontract_reconcile-0.10.2.dev1.dist-info}/entry_points.txt +1 -0
- reconcile/aws_account_manager/README.md +5 -0
- reconcile/change_owners/README.md +34 -0
- reconcile/glitchtip/README.md +150 -0
- reconcile/gql_definitions/introspection.json +51176 -0
- reconcile/run_integration.py +293 -0
- reconcile/utils/binary.py +2 -2
- reconcile/utils/mr/README.md +198 -0
- reconcile/utils/oc_map.py +2 -2
- tools/qontract_cli.py +0 -0
- qontract_reconcile-0.10.1rc1202.dist-info/METADATA +0 -64
- qontract_reconcile-0.10.1rc1202.dist-info/top_level.txt +0 -3
- reconcile/test/__init__.py +0 -0
- reconcile/test/conftest.py +0 -157
- reconcile/test/fixtures.py +0 -24
- reconcile/test/saas_auto_promotions_manager/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/conftest.py +0 -170
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/conftest.py +0 -115
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/data_keys.py +0 -19
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_desired_state.py +0 -66
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_merge_request_manager.py +0 -86
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_mr_parser.py +0 -352
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_reconciler.py +0 -494
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/__init__.py +0 -0
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +0 -25
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_multiple_namespaces.py +0 -37
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_namespace.py +0 -81
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_target.py +0 -61
- reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_json_path_selector.py +0 -74
- reconcile/test/saas_auto_promotions_manager/test_integration_test.py +0 -52
- reconcile/test/saas_auto_promotions_manager/utils/__init__.py +0 -0
- reconcile/test/test_acs_notifiers.py +0 -393
- reconcile/test/test_acs_policies.py +0 -497
- reconcile/test/test_acs_rbac.py +0 -865
- reconcile/test/test_aggregated_list.py +0 -237
- reconcile/test/test_amtool.py +0 -37
- reconcile/test/test_aws_ami_cleanup.py +0 -230
- reconcile/test/test_aws_ami_share.py +0 -68
- reconcile/test/test_aws_cloudwatch_log_retention.py +0 -434
- reconcile/test/test_aws_iam_keys.py +0 -70
- reconcile/test/test_aws_iam_password_reset.py +0 -35
- reconcile/test/test_aws_support_cases_sos.py +0 -23
- reconcile/test/test_checkpoint.py +0 -178
- reconcile/test/test_cli.py +0 -41
- reconcile/test/test_closedbox_endpoint_monitoring.py +0 -207
- reconcile/test/test_dashdotdb_dora.py +0 -245
- reconcile/test/test_database_access_manager.py +0 -660
- reconcile/test/test_deadmanssnitch.py +0 -290
- reconcile/test/test_gabi_authorized_users.py +0 -72
- reconcile/test/test_gcr_mirror.py +0 -14
- reconcile/test/test_github_org.py +0 -156
- reconcile/test/test_github_repo_invites.py +0 -119
- reconcile/test/test_gitlab_housekeeping.py +0 -333
- reconcile/test/test_gitlab_labeler.py +0 -126
- reconcile/test/test_gitlab_members.py +0 -219
- reconcile/test/test_gitlab_permissions.py +0 -164
- reconcile/test/test_instrumented_wrappers.py +0 -18
- reconcile/test/test_integrations_manager.py +0 -1252
- reconcile/test/test_jenkins_worker_fleets.py +0 -57
- reconcile/test/test_jira_permissions_validator.py +0 -519
- reconcile/test/test_jump_host.py +0 -114
- reconcile/test/test_ldap_users.py +0 -125
- reconcile/test/test_make.py +0 -28
- reconcile/test/test_ocm_additional_routers.py +0 -133
- reconcile/test/test_ocm_clusters.py +0 -798
- reconcile/test/test_ocm_clusters_manifest_updates.py +0 -87
- reconcile/test/test_ocm_machine_pools.py +0 -1103
- reconcile/test/test_ocm_update_recommended_version.py +0 -145
- reconcile/test/test_ocm_upgrade_scheduler_org_updater.py +0 -125
- reconcile/test/test_openshift_base.py +0 -1269
- reconcile/test/test_openshift_cluster_bots.py +0 -240
- reconcile/test/test_openshift_namespace_labels.py +0 -344
- reconcile/test/test_openshift_namespaces.py +0 -256
- reconcile/test/test_openshift_resource.py +0 -443
- reconcile/test/test_openshift_resources_base.py +0 -478
- reconcile/test/test_openshift_saas_deploy.py +0 -188
- reconcile/test/test_openshift_saas_deploy_change_tester.py +0 -308
- reconcile/test/test_openshift_saas_deploy_trigger_cleaner.py +0 -65
- reconcile/test/test_openshift_serviceaccount_tokens.py +0 -282
- reconcile/test/test_openshift_tekton_resources.py +0 -265
- reconcile/test/test_openshift_upgrade_watcher.py +0 -223
- reconcile/test/test_prometheus_rules_tester.py +0 -151
- reconcile/test/test_quay_membership.py +0 -86
- reconcile/test/test_quay_mirror.py +0 -172
- reconcile/test/test_quay_mirror_org.py +0 -82
- reconcile/test/test_quay_repos.py +0 -59
- reconcile/test/test_queries.py +0 -53
- reconcile/test/test_repo_owners.py +0 -47
- reconcile/test/test_requests_sender.py +0 -139
- reconcile/test/test_saasherder.py +0 -1611
- reconcile/test/test_saasherder_allowed_secret_paths.py +0 -125
- reconcile/test/test_secret_reader.py +0 -153
- reconcile/test/test_slack_base.py +0 -183
- reconcile/test/test_slack_usergroups.py +0 -785
- reconcile/test/test_sql_query.py +0 -316
- reconcile/test/test_status_board.py +0 -258
- reconcile/test/test_terraform_aws_route53.py +0 -29
- reconcile/test/test_terraform_cloudflare_dns.py +0 -117
- reconcile/test/test_terraform_cloudflare_resources.py +0 -408
- reconcile/test/test_terraform_cloudflare_users.py +0 -747
- reconcile/test/test_terraform_repo.py +0 -440
- reconcile/test/test_terraform_resources.py +0 -519
- reconcile/test/test_terraform_tgw_attachments.py +0 -1295
- reconcile/test/test_terraform_users.py +0 -152
- reconcile/test/test_terraform_vpc_peerings.py +0 -576
- reconcile/test/test_terraform_vpc_peerings_build_desired_state.py +0 -1434
- reconcile/test/test_three_way_diff_strategy.py +0 -131
- reconcile/test/test_utils_jinja2.py +0 -130
- reconcile/test/test_vault_replication.py +0 -534
- reconcile/test/test_vault_utils.py +0 -47
- reconcile/test/test_version_bump.py +0 -18
- reconcile/test/test_vpc_peerings_validator.py +0 -194
- reconcile/test/test_wrong_region.py +0 -78
- release/__init__.py +0 -0
- release/test_version.py +0 -50
- release/version.py +0 -104
- tools/cli_commands/test/__init__.py +0 -0
- tools/cli_commands/test/conftest.py +0 -332
- tools/cli_commands/test/test_aws_cost_report.py +0 -258
- tools/cli_commands/test/test_cost_management_api.py +0 -326
- tools/cli_commands/test/test_gpg_encrypt.py +0 -235
- tools/cli_commands/test/test_openshift_cost_optimization_report.py +0 -255
- tools/cli_commands/test/test_openshift_cost_report.py +0 -295
- tools/cli_commands/test/test_util.py +0 -70
- tools/test/__init__.py +0 -0
- tools/test/conftest.py +0 -77
- tools/test/test_app_interface_metrics_exporter.py +0 -48
- tools/test/test_erv2.py +0 -80
- tools/test/test_get_container_images.py +0 -230
- tools/test/test_qontract_cli.py +0 -197
- tools/test/test_saas_promotion_state.py +0 -187
- tools/test/test_sd_app_sre_alert_report.py +0 -74
- tools/test/test_sre_checkpoints.py +0 -79
@@ -1,290 +0,0 @@
|
|
1
|
-
from unittest.mock import MagicMock, create_autospec
|
2
|
-
|
3
|
-
import pytest
|
4
|
-
from pytest_mock import MockerFixture
|
5
|
-
|
6
|
-
from reconcile.deadmanssnitch import (
|
7
|
-
DeadMansSnitchIntegration,
|
8
|
-
)
|
9
|
-
from reconcile.gql_definitions.common.app_interface_dms_settings import (
|
10
|
-
DeadMansSnitchSettingsV1,
|
11
|
-
VaultSecretV1,
|
12
|
-
)
|
13
|
-
from reconcile.gql_definitions.common.clusters_with_dms import (
|
14
|
-
ClusterV1,
|
15
|
-
)
|
16
|
-
from reconcile.utils.deadmanssnitch_api import (
|
17
|
-
DeadMansSnitchApi,
|
18
|
-
Snitch,
|
19
|
-
)
|
20
|
-
|
21
|
-
|
22
|
-
@pytest.fixture
|
23
|
-
def deadmanssnitch_api() -> MagicMock:
|
24
|
-
return create_autospec(DeadMansSnitchApi)
|
25
|
-
|
26
|
-
|
27
|
-
@pytest.fixture
|
28
|
-
def deadmanssnitch_settings() -> DeadMansSnitchSettingsV1:
|
29
|
-
settings = DeadMansSnitchSettingsV1(
|
30
|
-
alertMailAddresses=["test_email"],
|
31
|
-
notesLink="test_link",
|
32
|
-
snitchesPath="test_snitches_path",
|
33
|
-
tokenCreds=VaultSecretV1(path="test_path", field="test_field"),
|
34
|
-
tags=["test-tags"],
|
35
|
-
alertType="Heartbeat",
|
36
|
-
interval="15_minute",
|
37
|
-
)
|
38
|
-
return settings
|
39
|
-
|
40
|
-
|
41
|
-
@pytest.fixture
|
42
|
-
def vault_mock(mocker: MockerFixture) -> MockerFixture:
|
43
|
-
return mocker.patch("reconcile.utils.vault._VaultClient")
|
44
|
-
|
45
|
-
|
46
|
-
@pytest.fixture
|
47
|
-
def secret_reader(mocker: MockerFixture) -> MockerFixture:
|
48
|
-
mock_secretreader = mocker.patch(
|
49
|
-
"reconcile.utils.secret_reader.SecretReader", autospec=True
|
50
|
-
)
|
51
|
-
mock_secretreader.read.return_value = "secret"
|
52
|
-
mock_secretreader.read_secret.return_value = "secret"
|
53
|
-
return mock_secretreader
|
54
|
-
|
55
|
-
|
56
|
-
def test_get_current_state(
|
57
|
-
secret_reader: MagicMock,
|
58
|
-
deadmanssnitch_api: MagicMock,
|
59
|
-
mocker: MockerFixture,
|
60
|
-
deadmanssnitch_settings: DeadMansSnitchSettingsV1,
|
61
|
-
) -> None:
|
62
|
-
deadmanssnitch_api.get_snitches.return_value = [
|
63
|
-
Snitch(
|
64
|
-
name="prometheus.test_cluster_1.net",
|
65
|
-
token="test",
|
66
|
-
href="testc",
|
67
|
-
status="healthy",
|
68
|
-
alert_type="basic",
|
69
|
-
alert_email=["test_mail"],
|
70
|
-
interval="15_minute",
|
71
|
-
check_in_url="test_url",
|
72
|
-
tags=["app-sre"],
|
73
|
-
notes="test_notes",
|
74
|
-
)
|
75
|
-
]
|
76
|
-
clusters = [
|
77
|
-
ClusterV1(
|
78
|
-
name="test_cluster_1",
|
79
|
-
serverUrl="testurl",
|
80
|
-
consoleUrl="test_c_url",
|
81
|
-
alertmanagerUrl="test_alert_manager",
|
82
|
-
managedClusterRoles=True,
|
83
|
-
prometheusUrl="https://prometheus.test_cluster_1.net",
|
84
|
-
enableDeadMansSnitch=True,
|
85
|
-
),
|
86
|
-
ClusterV1(
|
87
|
-
name="test_cluster_2",
|
88
|
-
serverUrl="testurl",
|
89
|
-
consoleUrl="test_c_url",
|
90
|
-
alertmanagerUrl="test_alert_manager",
|
91
|
-
managedClusterRoles=True,
|
92
|
-
prometheusUrl="https://prometheus.test_cluster_2.net",
|
93
|
-
enableDeadMansSnitch=True,
|
94
|
-
),
|
95
|
-
]
|
96
|
-
mocker.patch(
|
97
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.__init__"
|
98
|
-
).return_value = None
|
99
|
-
dms_integration = DeadMansSnitchIntegration()
|
100
|
-
dms_integration._secret_reader = secret_reader
|
101
|
-
dms_integration.settings = deadmanssnitch_settings
|
102
|
-
current_state = dms_integration.get_current_state(
|
103
|
-
deadmanssnitch_api=deadmanssnitch_api,
|
104
|
-
clusters=clusters,
|
105
|
-
vault_snitch_map={"deadmanssnitch-test_cluster_1-url": "secret"},
|
106
|
-
)
|
107
|
-
assert current_state["test_cluster_1"].vault_data == "secret"
|
108
|
-
|
109
|
-
|
110
|
-
def test_integration_for_create(
|
111
|
-
vault_mock: MagicMock,
|
112
|
-
deadmanssnitch_settings: DeadMansSnitchSettingsV1,
|
113
|
-
mocker: MockerFixture,
|
114
|
-
secret_reader: MagicMock,
|
115
|
-
) -> None:
|
116
|
-
mocker.patch(
|
117
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.__init__"
|
118
|
-
).return_value = None
|
119
|
-
dms_integration = DeadMansSnitchIntegration()
|
120
|
-
secret_reader.read_all.return_value = {}
|
121
|
-
dms_integration._secret_reader = secret_reader
|
122
|
-
dms_integration.settings = deadmanssnitch_settings
|
123
|
-
dms_integration.vault_client = vault_mock
|
124
|
-
mocker.patch("reconcile.deadmanssnitch.get_clusters_with_dms").return_value = [
|
125
|
-
ClusterV1(
|
126
|
-
name="create_cluster",
|
127
|
-
prometheusUrl="https://prometheus.create_cluster.devshift.net",
|
128
|
-
enableDeadMansSnitch=True,
|
129
|
-
alertmanagerUrl="alertmanager.create_cluster.devshift.net",
|
130
|
-
managedClusterRoles=True,
|
131
|
-
serverUrl="testurl",
|
132
|
-
consoleUrl="test_console",
|
133
|
-
)
|
134
|
-
]
|
135
|
-
mocker.patch(
|
136
|
-
"reconcile.deadmanssnitch.DeadMansSnitchApi.get_snitches"
|
137
|
-
).return_value = []
|
138
|
-
mock_create_snitch = mocker.patch(
|
139
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.create_snitch"
|
140
|
-
)
|
141
|
-
mock_create_snitch.return_value = Snitch(
|
142
|
-
name="prometheus.create_cluster.devshift.net",
|
143
|
-
token="test",
|
144
|
-
href="testc",
|
145
|
-
status="healthy",
|
146
|
-
alert_type="basic",
|
147
|
-
alert_email=["test_mail"],
|
148
|
-
interval="15_minute",
|
149
|
-
check_in_url="test_url",
|
150
|
-
tags=["app-sre"],
|
151
|
-
notes="test_notes",
|
152
|
-
)
|
153
|
-
dms_integration.run(dry_run=False)
|
154
|
-
mock_create_snitch.assert_called_once()
|
155
|
-
|
156
|
-
|
157
|
-
def test_integration_for_delete(
|
158
|
-
deadmanssnitch_settings: DeadMansSnitchSettingsV1,
|
159
|
-
vault_mock: MagicMock,
|
160
|
-
mocker: MockerFixture,
|
161
|
-
secret_reader: MagicMock,
|
162
|
-
) -> None:
|
163
|
-
mocker.patch(
|
164
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.__init__"
|
165
|
-
).return_value = None
|
166
|
-
dms_integration = DeadMansSnitchIntegration()
|
167
|
-
secret_reader.read_all.return_value = {"deadmanssnitch-create_cluster-url": "test"}
|
168
|
-
dms_integration._secret_reader = secret_reader
|
169
|
-
dms_integration.settings = deadmanssnitch_settings
|
170
|
-
dms_integration.vault_client = vault_mock
|
171
|
-
mocker.patch("reconcile.deadmanssnitch.get_clusters_with_dms").return_value = [
|
172
|
-
ClusterV1(
|
173
|
-
name="create_cluster",
|
174
|
-
prometheusUrl="https://prometheus.create_cluster.devshift.net",
|
175
|
-
enableDeadMansSnitch=False,
|
176
|
-
alertmanagerUrl="alertmanager.create_cluster.devshift.net",
|
177
|
-
managedClusterRoles=True,
|
178
|
-
serverUrl="testurl",
|
179
|
-
consoleUrl="test_console",
|
180
|
-
)
|
181
|
-
]
|
182
|
-
mocker.patch(
|
183
|
-
"reconcile.deadmanssnitch.DeadMansSnitchApi.get_snitches"
|
184
|
-
).return_value = [
|
185
|
-
Snitch(
|
186
|
-
name="prometheus.create_cluster.devshift.net",
|
187
|
-
token="test",
|
188
|
-
href="testc",
|
189
|
-
status="healthy",
|
190
|
-
alert_type="basic",
|
191
|
-
alert_email=["test_mail"],
|
192
|
-
interval="15_minute",
|
193
|
-
check_in_url="test_url",
|
194
|
-
tags=["app-sre"],
|
195
|
-
notes="test_notes",
|
196
|
-
)
|
197
|
-
]
|
198
|
-
mock_delete_snitch = mocker.patch(
|
199
|
-
"reconcile.deadmanssnitch.DeadMansSnitchApi.delete_snitch"
|
200
|
-
)
|
201
|
-
mock_delete_snitch.return_value = None
|
202
|
-
dms_integration.run(dry_run=False)
|
203
|
-
mock_delete_snitch.assert_called_once_with("test")
|
204
|
-
|
205
|
-
|
206
|
-
def test_integration_for_update_vault(
|
207
|
-
deadmanssnitch_settings: DeadMansSnitchSettingsV1,
|
208
|
-
vault_mock: MagicMock,
|
209
|
-
mocker: MockerFixture,
|
210
|
-
secret_reader: MagicMock,
|
211
|
-
) -> None:
|
212
|
-
mocker.patch(
|
213
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.__init__"
|
214
|
-
).return_value = None
|
215
|
-
dms_integration = DeadMansSnitchIntegration()
|
216
|
-
secret_reader.read_all.return_value = {"deadmanssnitch-test_cluster-url": "test"}
|
217
|
-
dms_integration._secret_reader = secret_reader
|
218
|
-
dms_integration.settings = deadmanssnitch_settings
|
219
|
-
dms_integration.vault_client = vault_mock
|
220
|
-
mocker.patch("reconcile.deadmanssnitch.get_clusters_with_dms").return_value = [
|
221
|
-
ClusterV1(
|
222
|
-
name="test_cluster",
|
223
|
-
prometheusUrl="https://prometheus.create_cluster.devshift.net",
|
224
|
-
enableDeadMansSnitch=True,
|
225
|
-
alertmanagerUrl="alertmanager.create_cluster.devshift.net",
|
226
|
-
managedClusterRoles=True,
|
227
|
-
serverUrl="testurl",
|
228
|
-
consoleUrl="test_console",
|
229
|
-
)
|
230
|
-
]
|
231
|
-
mocker.patch(
|
232
|
-
"reconcile.deadmanssnitch.DeadMansSnitchApi.get_snitches"
|
233
|
-
).return_value = [
|
234
|
-
Snitch(
|
235
|
-
name="prometheus.create_cluster.devshift.net",
|
236
|
-
token="test",
|
237
|
-
href="testc",
|
238
|
-
status="healthy",
|
239
|
-
alert_type="basic",
|
240
|
-
alert_email=["test_mail"],
|
241
|
-
interval="15_minute",
|
242
|
-
check_in_url="test_url",
|
243
|
-
tags=["app-sre"],
|
244
|
-
notes="test_notes",
|
245
|
-
)
|
246
|
-
]
|
247
|
-
dms_integration.run(dry_run=False)
|
248
|
-
data = {"deadmanssnitch-test_cluster-url": "test_url"}
|
249
|
-
vault_mock.write.assert_called_once_with(
|
250
|
-
{
|
251
|
-
"path": deadmanssnitch_settings.snitches_path,
|
252
|
-
"data": data,
|
253
|
-
},
|
254
|
-
decode_base64=False,
|
255
|
-
)
|
256
|
-
|
257
|
-
|
258
|
-
def test_integration_while_failed(
|
259
|
-
deadmanssnitch_settings: DeadMansSnitchSettingsV1,
|
260
|
-
vault_mock: MagicMock,
|
261
|
-
mocker: MockerFixture,
|
262
|
-
secret_reader: MagicMock,
|
263
|
-
) -> None:
|
264
|
-
mocker.patch(
|
265
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.__init__"
|
266
|
-
).return_value = None
|
267
|
-
dms_integration = DeadMansSnitchIntegration()
|
268
|
-
dms_integration._secret_reader = secret_reader
|
269
|
-
dms_integration.settings = deadmanssnitch_settings
|
270
|
-
dms_integration.vault_client = vault_mock
|
271
|
-
mocker.patch("reconcile.deadmanssnitch.get_clusters_with_dms").return_value = [
|
272
|
-
ClusterV1(
|
273
|
-
name="create_cluster",
|
274
|
-
prometheusUrl="https://prometheus.create_cluster.devshift.net",
|
275
|
-
enableDeadMansSnitch=True,
|
276
|
-
alertmanagerUrl="alertmanager.create_cluster.devshift.net",
|
277
|
-
managedClusterRoles=True,
|
278
|
-
serverUrl="testurl",
|
279
|
-
consoleUrl="test_console",
|
280
|
-
)
|
281
|
-
]
|
282
|
-
mocker.patch(
|
283
|
-
"reconcile.deadmanssnitch.DeadMansSnitchApi.get_snitches"
|
284
|
-
).return_value = []
|
285
|
-
mocker.patch(
|
286
|
-
"reconcile.deadmanssnitch.DeadMansSnitchIntegration.create_snitch",
|
287
|
-
side_effect=Exception("mock vault"),
|
288
|
-
)
|
289
|
-
with pytest.raises(ExceptionGroup):
|
290
|
-
dms_integration.run(dry_run=False)
|
@@ -1,72 +0,0 @@
|
|
1
|
-
from datetime import (
|
2
|
-
date,
|
3
|
-
timedelta,
|
4
|
-
)
|
5
|
-
|
6
|
-
import pytest
|
7
|
-
from pytest_mock import MockerFixture
|
8
|
-
|
9
|
-
import reconcile.gabi_authorized_users as gabi_u
|
10
|
-
import reconcile.openshift_base as ob
|
11
|
-
from reconcile.test.fixtures import Fixtures
|
12
|
-
from reconcile.utils.aggregated_list import RunnerException
|
13
|
-
from reconcile.utils.openshift_resource import OpenshiftResource as OR
|
14
|
-
from reconcile.utils.openshift_resource import ResourceInventory
|
15
|
-
|
16
|
-
fixture = Fixtures("gabi_authorized_users").get_anymarkup("api.yml")
|
17
|
-
|
18
|
-
|
19
|
-
def test_gabi_authorized_users_apply(mocker: MockerFixture) -> None:
|
20
|
-
ri = ResourceInventory()
|
21
|
-
ri.initialize_resource_type("server", "gabi-db", "ConfigMap")
|
22
|
-
gabi_instance = fixture["gql_response"][0]
|
23
|
-
gabi_u.fetch_desired_state([gabi_instance], ri)
|
24
|
-
mock_apply = mocker.patch.object(ob, "apply", autospec=True)
|
25
|
-
oc_map = mocker.patch("reconcile.utils.oc_map.OCMap", autospec=True)
|
26
|
-
ob.realize_data(True, oc_map, ri, 1)
|
27
|
-
expected = OR(
|
28
|
-
fixture["desired"],
|
29
|
-
gabi_u.QONTRACT_INTEGRATION,
|
30
|
-
gabi_u.QONTRACT_INTEGRATION_VERSION,
|
31
|
-
)
|
32
|
-
_, kwargs = mock_apply.call_args
|
33
|
-
assert kwargs["resource"] == expected
|
34
|
-
|
35
|
-
|
36
|
-
def test_gabi_authorized_users_exist(mocker: MockerFixture) -> None:
|
37
|
-
ri = ResourceInventory()
|
38
|
-
ri.initialize_resource_type("server", "gabi-db", "ConfigMap")
|
39
|
-
current = OR(
|
40
|
-
fixture["current"],
|
41
|
-
gabi_u.QONTRACT_INTEGRATION,
|
42
|
-
gabi_u.QONTRACT_INTEGRATION_VERSION,
|
43
|
-
)
|
44
|
-
ri.add_current(
|
45
|
-
"server",
|
46
|
-
"gabi-db",
|
47
|
-
"ConfigMap",
|
48
|
-
current.name,
|
49
|
-
current,
|
50
|
-
)
|
51
|
-
gabi_instance = fixture["gql_response"][0]
|
52
|
-
gabi_u.fetch_desired_state([gabi_instance], ri)
|
53
|
-
mock_apply = mocker.patch.object(ob, "apply", autospec=True)
|
54
|
-
oc_map = mocker.patch("reconcile.utils.oc_map.OCMap", autospec=True)
|
55
|
-
ob.realize_data(True, oc_map, ri, 1)
|
56
|
-
mock_apply.assert_not_called()
|
57
|
-
|
58
|
-
|
59
|
-
def test_gabi_authorized_users_exceed() -> None:
|
60
|
-
expiration_date = date.today() + timedelta(days=(gabi_u.EXPIRATION_DAYS_MAX + 1))
|
61
|
-
gabi_instance = fixture["gql_response"][0]
|
62
|
-
gabi_instance["expirationDate"] = str(expiration_date)
|
63
|
-
ri = ResourceInventory()
|
64
|
-
with pytest.raises(RunnerException):
|
65
|
-
gabi_u.fetch_desired_state([gabi_instance], ri)
|
66
|
-
|
67
|
-
|
68
|
-
def test_gabi_authorized_users_rds_not_found() -> None:
|
69
|
-
gabi_instance = fixture["gql_response"][1]
|
70
|
-
ri = ResourceInventory()
|
71
|
-
with pytest.raises(RunnerException):
|
72
|
-
gabi_u.fetch_desired_state([gabi_instance], ri)
|
@@ -1,14 +0,0 @@
|
|
1
|
-
from pytest_mock import MockerFixture
|
2
|
-
|
3
|
-
from reconcile.gcr_mirror import QuayMirror
|
4
|
-
|
5
|
-
|
6
|
-
def test_gcr_mirror_session(mocker: MockerFixture) -> None:
|
7
|
-
mocker.patch("reconcile.gcr_mirror.gql")
|
8
|
-
mocker.patch("reconcile.gcr_mirror.queries")
|
9
|
-
mocked_request = mocker.patch("reconcile.gcr_mirror.requests")
|
10
|
-
|
11
|
-
with QuayMirror() as gcr_mirror:
|
12
|
-
assert gcr_mirror.session == mocked_request.Session.return_value
|
13
|
-
|
14
|
-
mocked_request.Session.return_value.close.assert_called_once_with()
|
@@ -1,156 +0,0 @@
|
|
1
|
-
from unittest.mock import patch
|
2
|
-
|
3
|
-
from reconcile import github_org
|
4
|
-
from reconcile.utils import (
|
5
|
-
config,
|
6
|
-
gql,
|
7
|
-
)
|
8
|
-
from reconcile.utils.aggregated_list import AggregatedList
|
9
|
-
|
10
|
-
from .fixtures import Fixtures
|
11
|
-
|
12
|
-
fxt = Fixtures("github_org")
|
13
|
-
|
14
|
-
|
15
|
-
class RawGithubApiMock:
|
16
|
-
@staticmethod
|
17
|
-
def org_invitations(org_name):
|
18
|
-
return []
|
19
|
-
|
20
|
-
@staticmethod
|
21
|
-
def team_invitations(org_id, team_id):
|
22
|
-
return []
|
23
|
-
|
24
|
-
|
25
|
-
class AttrDict(dict):
|
26
|
-
def __init__(self, *args, **kwargs):
|
27
|
-
super().__init__(*args, **kwargs)
|
28
|
-
self.__dict__ = self
|
29
|
-
|
30
|
-
|
31
|
-
class GithubMock:
|
32
|
-
def __init__(self, spec):
|
33
|
-
self.spec = spec
|
34
|
-
|
35
|
-
class GithubOrgMock:
|
36
|
-
def __init__(self, spec_org):
|
37
|
-
self.spec_org = spec_org
|
38
|
-
|
39
|
-
@property
|
40
|
-
def id(self):
|
41
|
-
return self.spec_org["id"]
|
42
|
-
|
43
|
-
class GithubTeamMock:
|
44
|
-
def __init__(self, spec_team):
|
45
|
-
self.spec_team = spec_team
|
46
|
-
|
47
|
-
def get_members(self):
|
48
|
-
return map(AttrDict, self.spec_team["members"])
|
49
|
-
|
50
|
-
@property
|
51
|
-
def id(self):
|
52
|
-
return self.spec_team["name"]
|
53
|
-
|
54
|
-
@property
|
55
|
-
def name(self):
|
56
|
-
return self.spec_team["name"]
|
57
|
-
|
58
|
-
def get_members(self):
|
59
|
-
return map(AttrDict, self.spec_org["members"])
|
60
|
-
|
61
|
-
def get_teams(self):
|
62
|
-
return map(self.GithubTeamMock, self.spec_org["teams"])
|
63
|
-
|
64
|
-
def get_organization(self, org_name):
|
65
|
-
return self.GithubOrgMock(self.spec[org_name])
|
66
|
-
|
67
|
-
|
68
|
-
def get_items_by_params(state, params):
|
69
|
-
h = AggregatedList.hash_params(params)
|
70
|
-
for group in state:
|
71
|
-
this_h = AggregatedList.hash_params(group["params"])
|
72
|
-
|
73
|
-
if h == this_h:
|
74
|
-
return sorted(group["items"])
|
75
|
-
return False
|
76
|
-
|
77
|
-
|
78
|
-
class TestGithubOrg:
|
79
|
-
@staticmethod
|
80
|
-
def setup_method(method):
|
81
|
-
config.init_from_toml(fxt.path("config.toml"))
|
82
|
-
gql.init_from_config(autodetect_sha=False)
|
83
|
-
|
84
|
-
@staticmethod
|
85
|
-
def do_current_state_test(path):
|
86
|
-
fixture = fxt.get_anymarkup(path)
|
87
|
-
|
88
|
-
with (
|
89
|
-
patch("reconcile.github_org.RawGithubApi") as m_rga,
|
90
|
-
patch("reconcile.github_org.Github") as m_gh,
|
91
|
-
):
|
92
|
-
m_gh.return_value = GithubMock(fixture["gh_api"])
|
93
|
-
m_rga.return_value = RawGithubApiMock()
|
94
|
-
|
95
|
-
gh_api_store = github_org.GHApiStore(config.get_config())
|
96
|
-
current_state = github_org.fetch_current_state(gh_api_store)
|
97
|
-
current_state = current_state.dump()
|
98
|
-
|
99
|
-
expected_current_state = fixture["state"]
|
100
|
-
|
101
|
-
assert len(current_state) == len(expected_current_state)
|
102
|
-
for group in current_state:
|
103
|
-
params = group["params"]
|
104
|
-
items = sorted(group["items"])
|
105
|
-
assert items == get_items_by_params(expected_current_state, params)
|
106
|
-
|
107
|
-
@staticmethod
|
108
|
-
def do_desired_state_test(path):
|
109
|
-
fixture = fxt.get_anymarkup(path)
|
110
|
-
|
111
|
-
with patch("reconcile.utils.gql.GqlApi.query") as m_gql:
|
112
|
-
m_gql.return_value = fixture["gql_response"]
|
113
|
-
|
114
|
-
desired_state = github_org.fetch_desired_state(infer_clusters=False).dump()
|
115
|
-
|
116
|
-
expected_desired_state = fixture["state"]
|
117
|
-
|
118
|
-
assert len(desired_state) == len(expected_desired_state)
|
119
|
-
for group in desired_state:
|
120
|
-
params = group["params"]
|
121
|
-
items = sorted(group["items"])
|
122
|
-
assert items == get_items_by_params(expected_desired_state, params)
|
123
|
-
|
124
|
-
def test_current_state_simple(self):
|
125
|
-
self.do_current_state_test("current_state_simple.yml")
|
126
|
-
|
127
|
-
def test_desired_state_simple(self):
|
128
|
-
self.do_desired_state_test("desired_state_simple.yml")
|
129
|
-
|
130
|
-
def test_get_members(self):
|
131
|
-
class SimpleMemberMock:
|
132
|
-
def __init__(self, login):
|
133
|
-
self.login = login
|
134
|
-
|
135
|
-
class SimpleOrgMock:
|
136
|
-
@staticmethod
|
137
|
-
def get_members():
|
138
|
-
return [SimpleMemberMock("a"), SimpleMemberMock("b")]
|
139
|
-
|
140
|
-
org = SimpleOrgMock()
|
141
|
-
assert github_org.get_members(org) == ["a", "b"]
|
142
|
-
|
143
|
-
def test_get_org_teams(self):
|
144
|
-
class SimpleOrgMock:
|
145
|
-
@staticmethod
|
146
|
-
def get_teams():
|
147
|
-
return ["teams"]
|
148
|
-
|
149
|
-
class SimpleGithubMock:
|
150
|
-
@staticmethod
|
151
|
-
def get_organization(org_name):
|
152
|
-
return SimpleOrgMock()
|
153
|
-
|
154
|
-
g = SimpleGithubMock()
|
155
|
-
_, teams = github_org.get_org_and_teams(g, "org")
|
156
|
-
assert teams == ["teams"]
|
@@ -1,119 +0,0 @@
|
|
1
|
-
from collections.abc import (
|
2
|
-
Iterable,
|
3
|
-
Mapping,
|
4
|
-
)
|
5
|
-
from typing import Any
|
6
|
-
from unittest.mock import MagicMock
|
7
|
-
|
8
|
-
import pytest
|
9
|
-
|
10
|
-
from reconcile import github_repo_invites
|
11
|
-
from reconcile.utils.raw_github_api import RawGithubApi
|
12
|
-
|
13
|
-
|
14
|
-
def test_parse_null_code_components():
|
15
|
-
raw_code_components = None
|
16
|
-
expected = github_repo_invites.CodeComponents(
|
17
|
-
urls=set(),
|
18
|
-
known_orgs=set(),
|
19
|
-
)
|
20
|
-
assert github_repo_invites._parse_code_components(raw_code_components) == expected
|
21
|
-
|
22
|
-
|
23
|
-
def test_parse_valid_code_components():
|
24
|
-
raw_code_components: Iterable[Mapping[str, Any]] = [
|
25
|
-
{
|
26
|
-
"codeComponents": [
|
27
|
-
{
|
28
|
-
"url": "https://github.com/org1/project1",
|
29
|
-
"resource": "upstream",
|
30
|
-
},
|
31
|
-
{
|
32
|
-
"url": "https://github.com/org2/project1",
|
33
|
-
"resource": "upstream",
|
34
|
-
},
|
35
|
-
],
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"codeComponents": [],
|
39
|
-
},
|
40
|
-
{
|
41
|
-
"codeComponents": [
|
42
|
-
{
|
43
|
-
"url": "https://github.com/org2/project2",
|
44
|
-
"resource": "upstream",
|
45
|
-
}
|
46
|
-
],
|
47
|
-
},
|
48
|
-
]
|
49
|
-
expected = github_repo_invites.CodeComponents(
|
50
|
-
urls={
|
51
|
-
"https://github.com/org1/project1",
|
52
|
-
"https://github.com/org2/project1",
|
53
|
-
"https://github.com/org2/project2",
|
54
|
-
},
|
55
|
-
known_orgs={
|
56
|
-
"https://github.com/org1",
|
57
|
-
"https://github.com/org2",
|
58
|
-
},
|
59
|
-
)
|
60
|
-
assert github_repo_invites._parse_code_components(raw_code_components) == expected
|
61
|
-
|
62
|
-
|
63
|
-
@pytest.fixture
|
64
|
-
def github():
|
65
|
-
mock = MagicMock(spec=RawGithubApi)
|
66
|
-
mock.repo_invitations = MagicMock()
|
67
|
-
mock.accept_repo_invitation = MagicMock()
|
68
|
-
return mock
|
69
|
-
|
70
|
-
|
71
|
-
def test_accept_invitations_no_dry_run(github):
|
72
|
-
expected_id = "123"
|
73
|
-
expected_org = "https://github.com/org1"
|
74
|
-
github.repo_invitations.side_effect = [
|
75
|
-
[
|
76
|
-
{
|
77
|
-
"id": expected_id,
|
78
|
-
"html_url": f"{expected_org}/project1",
|
79
|
-
},
|
80
|
-
{
|
81
|
-
"id": "456",
|
82
|
-
"html_url": "https://github.com/org3/project1",
|
83
|
-
},
|
84
|
-
]
|
85
|
-
]
|
86
|
-
code_components = github_repo_invites.CodeComponents(
|
87
|
-
urls={f"{expected_org}/project1"},
|
88
|
-
known_orgs={expected_org},
|
89
|
-
)
|
90
|
-
dry_run = False
|
91
|
-
accepted_invitations = github_repo_invites._accept_invitations(
|
92
|
-
github, code_components, dry_run
|
93
|
-
)
|
94
|
-
|
95
|
-
github.accept_repo_invitation.assert_called_once_with(expected_id)
|
96
|
-
assert accepted_invitations == {expected_org}
|
97
|
-
|
98
|
-
|
99
|
-
def test_accept_invitations_dry_run(github):
|
100
|
-
expected_org = "https://github.com/org1"
|
101
|
-
github.repo_invitations.side_effect = [
|
102
|
-
[
|
103
|
-
{
|
104
|
-
"id": "123",
|
105
|
-
"html_url": f"{expected_org}/project1",
|
106
|
-
},
|
107
|
-
],
|
108
|
-
]
|
109
|
-
code_components = github_repo_invites.CodeComponents(
|
110
|
-
urls={f"{expected_org}/project1"},
|
111
|
-
known_orgs={expected_org},
|
112
|
-
)
|
113
|
-
dry_run = True
|
114
|
-
accepted_invitations = github_repo_invites._accept_invitations(
|
115
|
-
github, code_components, dry_run
|
116
|
-
)
|
117
|
-
|
118
|
-
github.accept_repo_invitation.assert_not_called()
|
119
|
-
assert accepted_invitations == {expected_org}
|