-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathstackql_context.py
More file actions
1207 lines (1017 loc) · 95.1 KB
/
stackql_context.py
File metadata and controls
1207 lines (1017 loc) · 95.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import base64
import json
import os
import typing
import copy
from typing import Optional
## cannot use relative imports due to robot usage pattern
from typed_python_responses import SELECT_AWS_CLOUD_CONTROL_EVENTS_MINIMAL_EXPECTED
from registry_cfg import RegistryCfg
_exe_name = 'stackql'
_mcp_client_exe_name = 'stackql_mcp_client'
IS_WINDOWS = '0'
if os.name == 'nt':
IS_WINDOWS = '1'
_exe_name = _exe_name + '.exe'
_PG_SCHEMA_PHYSICAL_TABLES = "stackql_raw"
_PG_SCHEMA_INTEL = "stackql_intel"
_BUILD_MAJOR_VERSION = os.environ.get('BUILDMAJORVERSION', '1')
_BUILD_MINOR_VERSION = os.environ.get('BUILDMINORVERSION', '1')
_BUILD_PATCH_VERSION = os.environ.get('BUILDPATCHVERSION', '1')
_SHELL_WELCOME_MSG = """
""" + f"stackql Command Shell {_BUILD_MAJOR_VERSION}.{_BUILD_MINOR_VERSION}.{_BUILD_PATCH_VERSION}" + """
Copyright (c) 2021, stackql studios. All rights reserved.
Welcome to the interactive shell for running stackql commands.
---
"""
def get_shell_welcome_stdout(env: str) -> str:
return ''
_AZURE_INTEGRATION_TESTING_SUB_ID :str = os.environ.get('AZURE_INTEGRATION_TESTING_SUB_ID', '10001000-1000-1000-1000-100010001000')
_AZURE_VM_SIZES_ENUMERATION :str = f"SELECT * FROM azure.compute.virtual_machine_sizes WHERE location = 'Australia East' AND subscriptionId = '{_AZURE_INTEGRATION_TESTING_SUB_ID}';"
DB_INTERNAL_CFG_LAX :str = "{ \"tableRegex\": \"(?i)^(?:public\\\\.)?(?:pg_.*|current_schema|information_schema)\" }"
_NAMESPACES_TTL_SIMPLE = '{ "analytics": { "ttl": 86400, "regex": "^(?:stackql_analytics_)?(?P<objectName>.*)$", "template": "stackql_analytics_{{ .objectName }}" } }'
_NAMESPACES_TTL_TRANSPARENT = '{ "analytics": { "ttl": 86400, "regex": "^(?P<objectName>.*)$", "template": "stackql_analytics_{{ .objectName }}" } }'
_NAMESPACES_TTL_SPECIALCASE_TRANSPARENT = '{ "analytics": { "ttl": 86400, "regex": "^(?P<objectName>github.*)$", "template": "stackql_analytics_{{ .objectName }}" } }'
DUMMY_DIGITALOCEAN_USERNAME_STR = 'myusername'
DUMMY_DIGITALOCEAN_PASSWORD_STR = 'mypassword'
_GC_CFG_EAGER = '{ "isEager": true }'
_SQL_BACKEND = '{ "isEager": true }'
NAMESPACES_TTL_SIMPLE = _NAMESPACES_TTL_SIMPLE.replace(' ', '')
NAMESPACES_TTL_TRANSPARENT = _NAMESPACES_TTL_TRANSPARENT.replace(' ', '')
NAMESPACES_TTL_SPECIALCASE_TRANSPARENT = _NAMESPACES_TTL_SPECIALCASE_TRANSPARENT.replace(' ', '')
MOCKSERVER_PORT_REGISTRY = 1094
def get_unix_path(pathStr :str) -> str:
return pathStr.replace('\\', '/')
_PROD_REGISTRY_URL :str = "https://cdn.statically.io/gh/stackql/stackql-provider-registry/main/providers"
_DEV_REGISTRY_URL :str = "https://cdn.statically.io/gh/stackql/stackql-provider-registry/dev/providers"
def get_db_setup_src(sql_backend_str :str) -> str:
if sql_backend_str == 'postgres_tcp':
return './test/db/postgres'
return './test/db/sqlite'
def get_registry_cfg(url :str, local_root :str, nop_verify :bool) -> dict:
registry = {
"url": url,
"verifyConfig": {
"nopVerify": nop_verify
}
}
if local_root != "":
registry["localDocRoot"] = local_root
return registry
def get_variables(
repository_root :str,
execution_env :str,
sql_backend_str :str,
use_stackql_preinstalled :str,
sundry_config: str # a json string with arbitrary config
) -> dict:
if not os.path.isdir(repository_root):
raise ValueError(f"repository_root is not a directory: {repository_root}")
## Hack in old time path variables
def get_output_from_local_file(fp :str) -> str:
with open(os.path.join(repository_root, fp), 'r') as f:
return f.read().strip()
def get_json_from_local_file(fp :str) -> typing.Any:
with open(os.path.join(repository_root, fp), 'r') as f:
return json.load(f)
ROBOT_TEST_ROOT = os.path.abspath(os.path.join(repository_root, 'test', 'robot'))
ROBOT_PROD_REG_DIR = os.path.abspath(os.path.join(ROBOT_TEST_ROOT, 'registry', 'prod'))
ROBOT_DEV_REG_DIR = os.path.abspath(os.path.join(ROBOT_TEST_ROOT, 'registry', 'dev'))
ROBOT_MOCKED_REG_DIR = os.path.abspath(os.path.join(ROBOT_TEST_ROOT, 'registry', 'mocked'))
ROBOT_INTEGRATION_TEST_ROOT = os.path.abspath(os.path.join(repository_root, 'test', 'robot', 'integration'))
with open(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'okta', 'api-key.txt'), 'r') as f:
OKTA_SECRET_STR = f.read()
with open(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'github', 'github-key.txt'), 'r') as f:
GITHUB_SECRET_STR = f.read()
with open(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'k8s', 'k8s-token.txt'), 'r') as f:
K8S_SECRET_STR = f.read()
with open(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'azure', 'azure-token.txt'), 'r') as f:
AZURE_SECRET_STR = f.read()
with open(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'sumologic', 'sumologic-token.txt'), 'r') as f:
SUMOLOGIC_SECRET_STR = f.read()
with open(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'digitalocean', 'digitalocean-token.txt'), 'r') as f:
DIGITALOCEAN_SECRET_STR = f.read()
# REGISTRY_PROD_CFG_STR = json.dumps(get_registry_cfg(_PROD_REGISTRY_URL, ROBOT_PROD_REG_DIR, False))
# REGISTRY_DEV_CFG_STR = json.dumps(get_registry_cfg(_DEV_REGISTRY_URL, ROBOT_DEV_REG_DIR, False))
REPOSITORY_ROOT_UNIX = get_unix_path(repository_root)
def get_stackql_exe(execution_env :str, is_preinstalled :bool):
_default_stackql_exe = ' '.join(get_unix_path(os.path.join(repository_root, 'build', _exe_name)).splitlines())
if is_preinstalled:
return 'stackql'
return _default_stackql_exe
def get_stackql_mcp_client_exe(execution_env :str, is_preinstalled :bool):
_default_stackql_mcp_client_exe = ' '.join(get_unix_path(os.path.join(repository_root, 'build', _mcp_client_exe_name)).splitlines())
if is_preinstalled:
return _mcp_client_exe_name
return _default_stackql_mcp_client_exe
def get_registry_mocked(execution_env :str) -> RegistryCfg:
return RegistryCfg(
REPOSITORY_ROOT_UNIX,
"",
remote_url=get_registry_mock_url(execution_env),
nop_verify=True
)
_REGISTRY_NULL = RegistryCfg(
REPOSITORY_ROOT_UNIX,
'',
is_null_registry=True
)
def _get_registry_canonical_no_verify(registry_path: Optional[str] = None) -> RegistryCfg:
_registry_path = registry_path if registry_path else os.path.join('test', 'registry')
return RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(_registry_path),
nop_verify=True
)
def _get_registry_no_verify(registry_path: Optional[str] = None) -> RegistryCfg:
_registry_path = registry_path if registry_path else os.path.join('test', 'registry-mocked')
return RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(_registry_path),
nop_verify=True
)
_REGISTRY_EXPERIMENTAL_NO_VERIFY = RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(os.path.join('test', 'registry-advanced')),
nop_verify=True
)
_REGISTRY_EXPERIMENTAL_DOCKER_NO_VERIFY = RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(os.path.join('test', 'registry-advanced-docker')),
nop_verify=True
)
_REGISTRY_SQL_VERB_CONTRIVED_NO_VERIFY = RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(os.path.join('test', 'registry')),
src_prefix="registry-verb-matching-src",
nop_verify=True
)
_REGISTRY_SQL_VERB_CONTRIVED_NO_VERIFY_DOCKER = RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(os.path.join('test', 'registry')),
src_prefix="registry-verb-matching-src-docker",
nop_verify=True
)
_REGISTRY_DEPRECATED = RegistryCfg(
REPOSITORY_ROOT_UNIX,
get_unix_path(os.path.join('test', 'registry-deprecated')),
nop_verify=True
)
def get_local_temp_path(inode_name: str, execution_env: str) -> str:
if execution_env == 'docker':
return os.path.join('/opt', 'test', 'tmp', inode_name)
return os.path.join(repository_root, 'test', 'tmp', inode_name)
_AUTH_GOOGLE_SA_KEY_PATH = get_unix_path(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'google', 'functional-test-dummy-sa-key.json'))
_NON_EXISTENT_AUTH_GOOGLE_SA_KEY_PATH = get_unix_path(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'google', 'non-existent-dummy-sa-key.json'))
_AUTH_CFG={
"google": {
"credentialsfilepath": _AUTH_GOOGLE_SA_KEY_PATH,
"type": "service_account"
},
"okta": {
"credentialsenvvar": "OKTA_SECRET_KEY",
"type": "api_key"
},
"aws": {
"type": "aws_signing_v4",
"credentialsfilepath": get_unix_path(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'aws', 'functional-test-dummy-aws-key.txt')),
"keyID": "NON_SECRET"
},
"github": {
"type": "basic",
"credentialsenvvar": "GITHUB_SECRET_KEY"
},
"k8s": {
"credentialsenvvar": "K8S_SECRET_KEY",
"type": "api_key",
"valuePrefix": "Bearer "
},
"azure": {
"type": "api_key",
"valuePrefix": "Bearer ",
"credentialsenvvar": "AZ_ACCESS_TOKEN"
},
"sumologic": {
"type": "basic",
"credentialsenvvar": "SUMO_CREDS"
},
"digitalocean": {
"type": "bearer",
"username": "myusername",
"password": "mypassword"
}
}
_AUTH_CFG_DEFECTIVE= copy.deepcopy(_AUTH_CFG)
_AUTH_CFG_DEFECTIVE["google"]["credentialsfilepath"] = _NON_EXISTENT_AUTH_GOOGLE_SA_KEY_PATH
_AUTH_CFG_DEFECTIVE["stackql_oauth2_testing"] = {
"type": "oauth2",
"grant_type": "client_credentials",
"client_id": "dummy_client_id",
"client_secret": "dummy_client_secret",
"token_url": "https://localhost:2091/contrived/simple/error/token",
"scopes": ["scope1", "scope2"]
}
_AUTH_PLUS_EXTERNAL_POSTGRES = copy.deepcopy(_AUTH_CFG)
_AUTH_PLUS_EXTERNAL_POSTGRES["pgi"] = {
"type": "sql_data_source::postgres",
"sqlDataSource": {
"dsn": "postgres://stackql:[email protected]:8432"
}
}
_AUTH_GOOGLE_SA_KEY_PATH_DOCKER = os.path.join('/opt', 'stackql', 'credentials', 'dummy', 'google', 'docker-functional-test-dummy-sa-key.json')
_NON_EXISTENT_AUTH_GOOGLE_SA_KEY_PATH_DOCKER = get_unix_path(os.path.join('/opt', 'stackql', 'credentials', 'dummy', 'google', 'non-existent-dummy-sa-key.json'))
_AUTH_CFG_DOCKER={
"google": {
"credentialsfilepath": _AUTH_GOOGLE_SA_KEY_PATH_DOCKER,
"type": "service_account"
},
"okta": {
"credentialsenvvar": "OKTA_SECRET_KEY",
"type": "api_key"
},
"aws": {
"type": "aws_signing_v4",
"credentialsfilepath": get_unix_path(os.path.join('/opt', 'stackql', 'credentials', 'dummy', 'aws', 'functional-test-dummy-aws-key.txt')),
"keyID": "NON_SECRET"
},
"github": {
"type": "basic",
"credentialsenvvar": "GITHUB_SECRET_KEY"
},
"k8s": {
"credentialsenvvar": "K8S_SECRET_KEY",
"type": "api_key",
"valuePrefix": "Bearer "
},
"azure": {
"type": "api_key",
"valuePrefix": "Bearer ",
"credentialsenvvar": "AZ_ACCESS_TOKEN"
},
"sumologic": {
"type": "basic",
"credentialsenvvar": "SUMO_CREDS"
},
"digitalocean": {
"type": "bearer",
"username": "myusername",
"password": "mypassword"
}
}
_AUTH_CFG_DEFECTIVE_DOCKER= copy.deepcopy(_AUTH_CFG_DOCKER)
_AUTH_CFG_DEFECTIVE_DOCKER["google"]["credentialsfilepath"] = _NON_EXISTENT_AUTH_GOOGLE_SA_KEY_PATH_DOCKER
_AUTH_CFG_DEFECTIVE_DOCKER["stackql_oauth2_testing"] = {
"type": "oauth2",
"grant_type": "client_credentials",
"client_id": "dummy_client_id",
"client_secret": "dummy_client_secret",
"token_url": "https://host.docker.internal:2091/contrived/simple/error/token",
"scopes": ["scope1", "scope2"]
}
_AUTH_PLUS_EXTERNAL_POSTGRES_DOCKER = copy.deepcopy(_AUTH_CFG_DOCKER)
_AUTH_PLUS_EXTERNAL_POSTGRES_DOCKER["pgi"] = {
"type": "sql_data_source::postgres",
"sqlDataSource": {
"dsn": "postgres://stackql:[email protected]:8432"
}
}
_GOOGLE_DUMMY_CREDENTIALS_PATH = os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'google', 'functional-test-dummy-sa-key.json')
_AUTH_CFG_INTEGRATION={
"google": {
"credentialsfilepath": get_unix_path(_GOOGLE_DUMMY_CREDENTIALS_PATH),
"type": "service_account"
},
"okta": {
"credentialsenvvar": "OKTA_SECRET_KEY",
"type": "api_key"
},
"aws": {
"type": "aws_signing_v4",
"credentialsfilepath": get_unix_path(os.path.join(repository_root, 'test', 'assets', 'credentials', 'dummy', 'aws', 'functional-test-dummy-aws-key.txt')),
"keyID": "NON_SECRET"
},
"github": {
"type": "basic",
"credentialsenvvar": "GITHUB_SECRET_KEY"
},
"k8s": {
"credentialsenvvar": "K8S_SECRET_KEY",
"type": "api_key",
"valuePrefix": "Bearer "
},
"azure": {
"type": "azure_default"
},
"sumologic": {
"type": "basic",
"credentialsenvvar": "SUMO_CREDS"
},
"digitalocean": {
"type": "bearer",
"username": "myusername",
"password": "mypassword"
}
}
_GOOGLE_DUMMY_CREDENTIALS_PATH_DOCKER = os.path.join('/opt', 'stackql', 'credentials', 'dummy', 'google', 'docker-functional-test-dummy-sa-key.json')
_AUTH_CFG_INTEGRATION_DOCKER={
"google": {
"credentialsfilepath": get_unix_path(_GOOGLE_DUMMY_CREDENTIALS_PATH_DOCKER),
"type": "service_account"
},
"okta": {
"credentialsenvvar": "OKTA_SECRET_KEY",
"type": "api_key"
},
"aws": {
"type": "aws_signing_v4",
"credentialsfilepath": get_unix_path(os.path.join('/opt', 'stackql', 'credentials', 'dummy', 'aws', 'functional-test-dummy-aws-key.txt')),
"keyID": "NON_SECRET"
},
"github": {
"type": "basic",
"credentialsenvvar": "GITHUB_SECRET_KEY"
},
"k8s": {
"credentialsenvvar": "K8S_SECRET_KEY",
"type": "api_key",
"valuePrefix": "Bearer "
},
"azure": {
"type": "azure_default"
},
"sumologic": {
"type": "basic",
"credentialsenvvar": "SUMO_CREDS"
},
"digitalocean": {
"type": "bearer",
"username": "myusername",
"password": "mypassword"
}
}
STACKQL_PG_SERVER_KEY_PATH :str = os.path.abspath(os.path.join(repository_root, "test", "server", "mtls", "credentials", "pg_server_key.pem"))
STACKQL_PG_SERVER_CERT_PATH :str = os.path.abspath(os.path.join(repository_root, "test", "server", "mtls", "credentials", "pg_server_cert.pem"))
STACKQL_PG_CLIENT_KEY_PATH :str = os.path.abspath(os.path.join(repository_root, "test", "server", "mtls", "credentials", "pg_client_key.pem"))
STACKQL_PG_CLIENT_CERT_PATH :str = os.path.abspath(os.path.join(repository_root, "test", "server", "mtls", "credentials", "pg_client_cert.pem"))
STACKQL_PG_SERVER_CERT_PATH_UNIX :str = get_unix_path(STACKQL_PG_SERVER_CERT_PATH)
STACKQL_PG_CLIENT_KEY_PATH_UNIX :str = get_unix_path(STACKQL_PG_CLIENT_KEY_PATH)
STACKQL_PG_CLIENT_CERT_PATH_UNIX :str = get_unix_path(STACKQL_PG_CLIENT_CERT_PATH)
STACKQL_PG_RUBBISH_KEY_PATH :str = os.path.abspath(os.path.join(repository_root, "test", "server", "mtls", "credentials", "pg_rubbish_key.pem"))
STACKQL_PG_RUBBISH_CERT_PATH :str = os.path.abspath(os.path.join(repository_root, "test", "server", "mtls", "credentials", "pg_rubbish_cert.pem"))
STACKQL_PG_SERVER_KEY_PATH_DOCKER :str = os.path.abspath(os.path.join(repository_root, "cicd", "vol", "srv", "credentials", "pg_server_key.pem"))
STACKQL_PG_SERVER_CERT_PATH_DOCKER :str = os.path.abspath(os.path.join(repository_root, "cicd", "vol", "srv", "credentials", "pg_server_cert.pem"))
STACKQL_PG_CLIENT_KEY_PATH_DOCKER :str = os.path.abspath(os.path.join(repository_root, "cicd", "vol", "srv", "credentials", "pg_client_key.pem"))
STACKQL_PG_CLIENT_CERT_PATH_DOCKER :str = os.path.abspath(os.path.join(repository_root, "cicd", "vol", "srv", "credentials", "pg_client_cert.pem"))
STACKQL_PG_RUBBISH_KEY_PATH_DOCKER :str = os.path.abspath(os.path.join(repository_root, "cicd", "vol", "srv", "credentials", "pg_rubbish_key.pem"))
STACKQL_PG_RUBBISH_CERT_PATH_DOCKER :str = os.path.abspath(os.path.join(repository_root, "cicd", "vol", "srv", "credentials", "pg_rubbish_cert.pem"))
def get_sql_dialect_from_sql_backend_str(sql_backend_str :str) -> str:
if sql_backend_str == 'postgres_tcp':
return 'postgres'
return 'sqlite'
def get_analytics_db_init_path(sql_backend_str :str) -> str:
sql_dialect = get_sql_dialect_from_sql_backend_str(sql_backend_str)
return os.path.abspath(os.path.join(repository_root, "test", "db", sql_dialect, "cache_setup.sql"))
def get_sqlite_export_db_path(execution_env :str) -> str:
if execution_env == 'native':
return get_unix_path(os.path.abspath(os.path.join(repository_root, "test", "db", "tmp", "export_testing.sqlite")))
if execution_env == 'docker':
return get_unix_path(os.path.join('/opt', 'stackql', "test", "export_testing.sqlite"))
ANALYTICS_DB_INIT_PATH_DOCKER :str = get_unix_path(os.path.join('/opt', 'stackql', "db", "cache_setup.sql"))
def get_analytics_db_init_path_unix(sql_backend_str :str) ->str:
return get_unix_path(get_analytics_db_init_path(sql_backend_str))
_SQL_BACKEND_POSTGRES_DOCKER_DSN :str = 'postgres://stackql:stackql@postgres_stackql:5432/stackql'
_SQL_BACKEND_POSTGRES_PUBLISHED_DOCKER_DSN :str = 'postgres://stackql:[email protected]:5532/stackql'
def get_analytics_sql_backend(execution_env :str, sql_backend_str :str) -> str:
if execution_env == 'native':
return f'{{ "dbInitFilepath": "{get_analytics_db_init_path_unix(sql_backend_str)}" }}'.replace(' ', '')
if execution_env == 'docker':
if sql_backend_str == 'postgres_tcp':
return f'{{ "dbEngine": "postgres_tcp", "dsn": "{_SQL_BACKEND_POSTGRES_DOCKER_DSN}", "sqlDialect": "postgres", "dbInitFilepath": "{ANALYTICS_DB_INIT_PATH_DOCKER}", "schemata": {{ "tableSchema": "{_PG_SCHEMA_PHYSICAL_TABLES}", "intelViewSchema": "{_PG_SCHEMA_INTEL}", "opsViewSchema": "stackql_ops" }} }}'.replace(' ', '')
return f'{{ "dbInitFilepath": "{ANALYTICS_DB_INIT_PATH_DOCKER}" }}'.replace(' ', '')
def get_canonical_sql_backend(execution_env :str, sql_backend_str :str) -> str:
if execution_env == 'native':
return '{}'
if execution_env == 'docker':
if sql_backend_str == 'postgres_tcp':
return f'{{ "dbEngine": "postgres_tcp", "dsn": "{_SQL_BACKEND_POSTGRES_DOCKER_DSN}", "sqlDialect": "postgres", "schemata": {{ "tableSchema": "{_PG_SCHEMA_PHYSICAL_TABLES}", "intelViewSchema": "{_PG_SCHEMA_INTEL}", "opsViewSchema": "stackql_ops" }} }}'.replace(' ', '')
return '{}'
def get_export_sql_backend(execution_env :str, sql_backend_str :str) -> str:
sqlite_file_path = get_sqlite_export_db_path(execution_env)
if execution_env == 'native':
return f'{{ "dsn": "file:{sqlite_file_path}" }} }}'
if execution_env == 'docker':
if sql_backend_str == 'postgres_tcp':
# same as always
return f'{{ "dbEngine": "postgres_tcp", "dsn": "{_SQL_BACKEND_POSTGRES_DOCKER_DSN}", "sqlDialect": "postgres", "schemata": {{ "tableSchema": "{_PG_SCHEMA_PHYSICAL_TABLES}", "intelViewSchema": "{_PG_SCHEMA_INTEL}", "opsViewSchema": "stackql_ops" }} }}'.replace(' ', '')
return f'{{ "dsn": "file:{sqlite_file_path}" }}'
def get_export_sql_connection_arg(execution_env :str, sql_backend_str :str) -> str:
sqlite_file_path = get_sqlite_export_db_path(execution_env)
if execution_env == 'native':
return sqlite_file_path
if execution_env == 'docker':
if sql_backend_str == 'postgres_tcp':
return _SQL_BACKEND_POSTGRES_PUBLISHED_DOCKER_DSN
return os.path.abspath(os.path.join(repository_root, "cicd", "vol", "stackql", "test", "export_testing.sqlite"))
with open(os.path.join(repository_root, 'test', 'server', 'mtls', 'credentials', 'pg_client_cert.pem'), 'rb') as f:
_CLIENT_CERT_ENCODED :str = base64.b64encode(f.read()).decode('utf-8')
# with open(os.path.join(repository_root, 'vol', 'srv', 'credentials', 'pg_client_cert.pem'), 'rb') as f:
# _DOCKER_CLIENT_CERT_ENCODED :str = base64.b64encode(f.read()).decode('utf-8')
_mTLS_CFG :dict = {
"keyFilePath": STACKQL_PG_SERVER_KEY_PATH,
"certFilePath": STACKQL_PG_SERVER_CERT_PATH,
"clientCAs": [
_CLIENT_CERT_ENCODED
]
}
_mTLS_CFG_DOCKER :dict = {
"keyFilePath": "/opt/stackql/srv/credentials/pg_server_key.pem",
"certFilePath": "/opt/stackql/srv/credentials/pg_server_cert.pem",
"clientCAs": [
"'\$(base64 -w 0 /opt/stackql/srv/credentials/pg_client_cert.pem)'"
]
}
def get_object_count_dict(count :int) -> dict:
"""
Blasted type inference in golang SQL lib is not flash.
"""
return { "object_count": f"{count}" }
PG_SRV_MTLS_CFG_STR :str = json.dumps(_mTLS_CFG)
PG_SRV_MTLS_DOCKER_CFG_STR :str = json.dumps(_mTLS_CFG_DOCKER).replace('\\$', '\$')
AUTH_CFG_STR = json.dumps(_AUTH_CFG)
AUTH_CFG_STR_DOCKER = json.dumps(_AUTH_CFG_DOCKER)
AUTH_CFG_DEFECTIVE_STR = json.dumps(_AUTH_CFG_DEFECTIVE)
AUTH_CFG_DEFECTIVE_STR_DOCKER = json.dumps(_AUTH_CFG_DEFECTIVE_DOCKER)
AUTH_PLUS_EXTERNAL_POSTGRES = json.dumps(_AUTH_PLUS_EXTERNAL_POSTGRES)
AUTH_PLUS_EXTERNAL_POSTGRES_DOCKER = json.dumps(_AUTH_PLUS_EXTERNAL_POSTGRES_DOCKER)
AUTH_CFG_INTEGRATION_STR = json.dumps(_AUTH_CFG_INTEGRATION)
AUTH_CFG_INTEGRATION_STR_DOCKER = json.dumps(_AUTH_CFG_INTEGRATION_DOCKER)
SHOW_PROVIDERS_STR = "show providers;"
SHOW_OKTA_SERVICES_FILTERED_STR = "show services from okta like 'app%';"
SHOW_OKTA_APPLICATION_RESOURCES_FILTERED_STR = "show resources from okta.application like 'gr%';"
SHOW_METHODS_GITHUB_REPOS_REPOS = "show methods in github.repos.repos;"
DESCRIBE_GITHUB_REPOS_PAGES = "describe github.repos.pages;"
DESCRIBE_AWS_EC2_INSTANCES = "describe aws.ec2.instances;"
DESCRIBE_AWS_EC2_DEFAULT_KMS_KEY_ID = "describe aws.ec2.ebs_default_kms_key_id;"
MOCKSERVER_JAR = os.path.join(repository_root, 'test', 'downloads', 'mockserver-netty-5.12.0-shaded.jar')
JSON_INIT_FILE_PATH_GOOGLE = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-gcp-expectations.json')
MOCKSERVER_PORT_GOOGLE = 1080
JSON_INIT_FILE_PATH_GOOGLEADMIN = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-google-admin-expectations.json')
MOCKSERVER_PORT_GOOGLEADMIN = 1098
JSON_INIT_FILE_PATH_STACKQL_AUTH_TESTING = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-auth-testing-expectations.json')
MOCKSERVER_PORT_STACKQL_AUTH_TESTING = 1170
JSON_INIT_FILE_PATH_OKTA = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-okta-expectations.json')
MOCKSERVER_PORT_OKTA = 1090
JSON_INIT_FILE_PATH_AWS = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-aws-expectations.json')
MOCKSERVER_PORT_AWS = 1091
JSON_INIT_FILE_PATH_K8S = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-k8s-expectations.json')
MOCKSERVER_PORT_K8S = 1092
JSON_INIT_FILE_PATH_GITHUB = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-github-expectations.json')
MOCKSERVER_PORT_GITHUB = 1093
JSON_INIT_FILE_PATH_AZURE = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-azure-expectations.json')
MOCKSERVER_PORT_AZURE = 1095
JSON_INIT_FILE_PATH_SUMOLOGIC = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-sumologic-expectations.json')
MOCKSERVER_PORT_SUMOLOGIC = 1096
JSON_INIT_FILE_PATH_DIGITALOCEAN = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-digitalocean-expectations.json')
MOCKSERVER_PORT_DIGITALOCEAN = 1097
MOCKSERVER_PORT_OAUTH_CLIENT_CREDENTIALS_TOKEN = 2091
JSON_INIT_FILE_PATH_REGISTRY = os.path.join(repository_root, 'test', 'mockserver', 'expectations', 'static-registry-expectations.json')
PG_SRV_PORT_MTLS = 5476
PG_SRV_PORT_MTLS_WITH_NAMESPACES = 5486
PG_SRV_PORT_MTLS_WITH_EAGER_GC = 5496
PG_SRV_PORT_MTLS_EXPORT = 5497
PG_SRV_PORT_UNENCRYPTED = 5477
PG_SRV_PORT_DOCKER_MTLS = 5576
PG_SRV_PORT_DOCKER_MTLS_WITH_NAMESPACES = 5586
PG_SRV_PORT_DOCKER_MTLS_WITH_EAGER_GC = 5596
PG_SRV_PORT_DOCKER_MTLS_EXPORT = 5597
PG_SRV_PORT_DOCKER_UNENCRYPTED = 5577
PSQL_EXE :str = os.environ.get('PSQL_EXE', 'psql')
SQLITE_EXE :str = os.environ.get('SQLITE_EXE', 'sqlite3')
PSQL_CLIENT_HOST :str = "127.0.0.1"
CREATE_DISKS_VIEW_NO_PRIMARY_ALIAS = "create view cross_cloud_disks_not_aliased as select 'aws' as vendor, volumeId as name, volumeType as type, status, size from aws.ec2.volumes where region = 'ap-southeast-2' union select 'google' as vendor, name, split_part(split_part(type, '/', 11), '-', 2) as type, status, sizeGb as size from google.compute.disks where project = 'testing-project' and zone = 'australia-southeast1-a' ;"
CREATE_DISKS_VIEW_PRIMARY_ALIAS = "create view cross_cloud_disks_aliased as select 'google' as vendor, name, split_part(split_part(type, '/', 11), '-', 2) as type, status, sizeGb as size from google.compute.disks where project = 'testing-project' and zone = 'australia-southeast1-a' union select 'aws' as vendor, volumeId as name, volumeType as type, status, size from aws.ec2.volumes where region = 'ap-southeast-2' ;"
PSQL_MTLS_CONN_STR :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH} sslkey={STACKQL_PG_CLIENT_KEY_PATH} sslrootcert={STACKQL_PG_SERVER_CERT_PATH} dbname=mydatabase"
PSQL_MTLS_CONN_STR_UNIX :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_UNIX} sslkey={STACKQL_PG_CLIENT_KEY_PATH_UNIX} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_UNIX} dbname=mydatabase"
def generate_password() -> str:
return os.urandom(16).hex()
PSQL_MTLS_CONN_STR_EXPORT_UNIX :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS_EXPORT} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_UNIX} sslkey={STACKQL_PG_CLIENT_KEY_PATH_UNIX} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_UNIX} dbname=mydatabase".replace('\\', '/')
PSQL_MTLS_DISABLE_CONN_STR :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=disable sslcert={STACKQL_PG_CLIENT_CERT_PATH} sslkey={STACKQL_PG_CLIENT_KEY_PATH} sslrootcert={STACKQL_PG_SERVER_CERT_PATH} dbname=mydatabase"
PSQL_MTLS_DISABLE_CONN_STR_UNIX :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=disable sslcert={STACKQL_PG_CLIENT_CERT_PATH_UNIX} sslkey={STACKQL_PG_CLIENT_KEY_PATH_UNIX} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_UNIX} dbname=mydatabase"
PSQL_MTLS_DISABLE_CONN_STR_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=disable sslcert={STACKQL_PG_CLIENT_CERT_PATH_DOCKER} sslkey={STACKQL_PG_CLIENT_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
OPENSSL_S_CLIENT_MTLS_CONN_STR :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=disable sslcert={STACKQL_PG_CLIENT_CERT_PATH} sslkey={STACKQL_PG_CLIENT_KEY_PATH} sslrootcert={STACKQL_PG_SERVER_CERT_PATH} dbname=mydatabase"
OPENSSL_S_CLIENT_MTLS_CONN_STR_UNIX :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=disable sslcert={STACKQL_PG_CLIENT_CERT_PATH_UNIX} sslkey={STACKQL_PG_CLIENT_KEY_PATH_UNIX} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_UNIX} dbname=mydatabase"
OPENSSL_S_CLIENT_MTLS_CONN_STR_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=disable sslcert={STACKQL_PG_CLIENT_CERT_PATH_DOCKER} sslkey={STACKQL_PG_CLIENT_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
PSQL_MTLS_CONN_STR_UNIX_WITH_NAMESPACES :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS_WITH_NAMESPACES} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_UNIX} sslkey={STACKQL_PG_CLIENT_KEY_PATH_UNIX} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_UNIX} dbname=mydatabase"
PSQL_MTLS_CONN_STR_UNIX_WITH_EAGER_GC :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS_WITH_EAGER_GC} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_UNIX} sslkey={STACKQL_PG_CLIENT_KEY_PATH_UNIX} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_UNIX} dbname=mydatabase"
PSQL_MTLS_INVALID_CONN_STR :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=verify-full sslcert={STACKQL_PG_RUBBISH_CERT_PATH} sslkey={STACKQL_PG_RUBBISH_KEY_PATH} sslrootcert={STACKQL_PG_SERVER_CERT_PATH} dbname=mydatabase"
PSQL_UNENCRYPTED_CONN_STR :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_UNENCRYPTED} user=myuser dbname=mydatabase"
POSTGRES_URL_UNENCRYPTED_CONN :str = f"postgresql://myuser:mypass@{PSQL_CLIENT_HOST}:{PG_SRV_PORT_UNENCRYPTED}/mydatabase"
PSQL_MTLS_CONN_STR_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_DOCKER} sslkey={STACKQL_PG_CLIENT_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
PSQL_MTLS_CONN_STR_EXPORT_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS_EXPORT} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_DOCKER} sslkey={STACKQL_PG_CLIENT_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
PSQL_MTLS_CONN_STR_WITH_NAMESPACES_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS_WITH_NAMESPACES} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_DOCKER} sslkey={STACKQL_PG_CLIENT_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
PSQL_MTLS_CONN_STR_WITH_EAGER_GC_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS_WITH_EAGER_GC} user=myuser sslmode=verify-full sslcert={STACKQL_PG_CLIENT_CERT_PATH_DOCKER} sslkey={STACKQL_PG_CLIENT_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
PSQL_MTLS_INVALID_CONN_STR_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_MTLS} user=myuser sslmode=verify-full sslcert={STACKQL_PG_RUBBISH_CERT_PATH_DOCKER} sslkey={STACKQL_PG_RUBBISH_KEY_PATH_DOCKER} sslrootcert={STACKQL_PG_SERVER_CERT_PATH_DOCKER} dbname=mydatabase"
PSQL_UNENCRYPTED_CONN_STR_DOCKER :str = f"host={PSQL_CLIENT_HOST} port={PG_SRV_PORT_UNENCRYPTED} user=myuser dbname=mydatabase"
POSTGRES_URL_UNENCRYPTED_CONN_DOCKER :str = f"postgresql://myuser:mypass@{PSQL_CLIENT_HOST}:{PG_SRV_PORT_UNENCRYPTED}/mydatabase"
SELECT_CONTAINER_SUBNET_AGG_DESC = "select ipCidrRange, sum(5) cc from google.container.\"projects.aggregated.usableSubnetworks\" where projectsId = 'testing-project' group by ipCidrRange having sum(5) >= 5 order by ipCidrRange desc;"
SELECT_CONTAINER_SUBNET_AGG_ASC = "select ipCidrRange, sum(5) cc from google.container.\"projects.aggregated.usableSubnetworks\" where projectsId = 'testing-project' group by ipCidrRange having sum(5) >= 5 order by ipCidrRange asc;"
SELECT_ACCELERATOR_TYPES_DESC = "select kind, name, maximumCardsPerInstance from google.compute.acceleratorTypes where project = 'testing-project' and zone = 'australia-southeast1-a' order by name desc;"
SELECT_ACCELERATOR_TYPES_DESC_FROM_INTEL_VIEWS = "select kind, name from stackql_intel.\"google.compute.acceleratorTypes\" where project = 'testing-project' and zone like '%%australia-southeast1-a' order by name desc;"
SELECT_ACCELERATOR_TYPES_DESC_FROM_INTEL_VIEWS_SUBQUERY = "SELECT name AS name, count(kind) AS \"COUNT(kind)\" FROM (SELECT * from stackql_intel.\"google.compute.acceleratorTypes\" limit 80) AS virtual_table GROUP BY name ORDER BY \"COUNT(kind)\" DESC LIMIT 1000;"
SELECT_MACHINE_TYPES_DESC = "select name from google.compute.machineTypes where project = 'testing-project' and zone = 'australia-southeast1-a' order by name desc;"
SELECT_GOOGLE_COMPUTE_INSTANCE_IAM_POLICY = "SELECT etag FROM google.compute.instances_iam_policies WHERE project = 'testing-project' AND zone = 'australia-southeast1-a' AND resource = '000000001';"
SELECT_AWS_CLOUD_CONTROL_EVENTS_MINIMAL = "SELECT DISTINCT EventTime, Identifier from aws.cloud_control.resource_requests where data__ResourceRequestStatusFilter='{}' and region = 'ap-southeast-1' order by Identifier, EventTime;"
SELECT_AZURE_COMPUTE_PUBLIC_KEYS = "select id, location from azure.compute.ssh_public_keys where subscriptionId = '10001000-1000-1000-1000-100010001000' ORDER BY id ASC;"
SELECT_AZURE_COMPUTE_VIRTUAL_MACHINES = "SELECT id, name FROM azure.compute.virtual_machines WHERE resourceGroupName = 'stackql-ops-cicd-dev-01' AND subscriptionId = '10001000-1000-1000-1000-100010001000' ORDER BY name ASC;"
SHOW_TRANSACTION_ISOLATION_LEVEL = "show transaction isolation level"
SELECT_HSTORE_DETAILS = "SELECT t.oid, typarray FROM pg_type t JOIN pg_namespace ns ON typnamespace = ns.oid WHERE typname = 'hstore'"
SHOW_TRANSACTION_ISOLATION_LEVEL_JSON_EXPECTED = [{"transaction_isolation": "read committed"}]
SELECT_HSTORE_DETAILS_JSON_EXPECTED = []
SHOW_TRANSACTION_ISOLATION_LEVEL_TUPLES_EXPECTED = [("read committed",)]
SELECT_HSTORE_DETAILS_TUPLES_EXPECTED = []
SELECT_POSTGRES_CATALOG_JOIN_TUPLE_EXPECTED = ("__iql__.control.gc.rings",)
_JSONNET_PLUS_ENV_VARS_QUERY_FILE = os.path.join(REPOSITORY_ROOT_UNIX, 'test', 'assets', 'input', 'env-var-input', 'env-var-input.iql')
_JSONNET_PLUS_ENV_VARS_VAR_FILE = os.path.join(REPOSITORY_ROOT_UNIX, 'test', 'assets', 'input', 'env-var-input', 'vars.jsonnet')
_JSONNET_PLUS_ENV_VARS_QUERY_FILE_DOCKER = os.path.join('/opt', 'stackql', 'input', 'env-var-input', 'env-var-input.iql')
_JSONNET_PLUS_ENV_VARS_VAR_FILE_DOCKER = os.path.join('/opt', 'stackql', 'input', 'env-var-input', 'vars.jsonnet')
_JSONNET_PLUS_ENV_VARS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'env-var-input', 'env-var-input-expected.iql'))
SELECT_AZURE_COMPUTE_PUBLIC_KEYS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'azure', 'compute', 'ssh-public-keys-list.txt'))
SELECT_AZURE_COMPUTE_VIRTUAL_MACHINES_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'azure', 'compute', 'vm-list.txt'))
SELECT_EXTERNAL_INFORMATION_SCHEMA_ORDERED_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'external_sources', 'select_information_schema_single_table_ordered.txt'))
SELECT_EXTERNAL_INFORMATION_SCHEMA_FILTERED_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'external_sources', 'select_information_schema_single_table_filtered.txt'))
SELECT_EXTERNAL_INFORMATION_SCHEMA_INNER_JOIN_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'external_sources', 'select_information_schema_inner_join.txt'))
SELECT_AZURE_COMPUTE_PUBLIC_KEYS_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'azure', 'compute', 'ssh-public-keys-list.json'))
SELECT_AZURE_COMPUTE_VIRTUAL_MACHINES_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'azure', 'compute', 'vm-list.json'))
SELECT_AZURE_COMPUTE_BILLING_ACCOUNTS_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'azure', 'billing', 'billing-account-list.json'))
SELECT_AWS_S3_BUCKET_LOCATIONS = "select LocationConstraint from aws.s3.bucket_locations where region = 'ap-southeast-1' and Bucket = 'stackql-trial-bucket-01';"
SELECT_AWS_S3_BUCKETS = "select Name, CreationDate from aws.s3.buckets where region = 'ap-southeast-1' order by Name ASC;"
SELECT_AWS_S3_OBJECTS = "select \"Key\", Size, StorageClass from aws.s3.objects where region = 'ap-southeast-1' and Bucket = 'stackql-trial-bucket-01' order by \"Key\" ASC;"
SELECT_AWS_S3_OBJECTS_NULL = "select \"Key\", Size, StorageClass from aws.s3.objects where region = 'ap-southeast-2' and Bucket = 'stackql-trial-bucket-02' order by \"Key\" ASC;"
SELECT_AWS_EC2_VPN_GATEWAYS_NULL = "select vpnGatewayId, amazonSideAsn from aws.ec2.vpn_gateways where region = 'ap-southeast-1' order by vpnGatewayId ASC;"
SELECT_AWS_VOLUMES = "select volumeId, encrypted, size from aws.ec2.volumes where region = 'ap-southeast-1' order by volumeId asc;"
SELECT_AWS_IAM_USERS_ASC = "select UserName, Arn from aws.iam.users WHERE region = 'us-east-1' order by UserName ASC;"
CREATE_AWS_VOLUME = """insert into aws.ec2.volumes(AvailabilityZone, Size, region, TagSpecification) select 'ap-southeast-1a', JSON(10), 'ap-southeast-1', JSON('[ { "ResourceType": "volume", "Tag": [ { "Key": "stack", "Value": "production" }, { "Key": "name", "Value": "multi-tag-volume" } ] } ]');"""
SELECT_AWS_CLOUD_CONTROL_VPCS_DESC = "select Identifier, Properties from aws.cloud_control_legacy.resources where region = 'ap-southeast-1' and data__TypeName = 'AWS::EC2::VPC' order by Identifier desc;"
SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION = "SELECT JSON_EXTRACT(Properties, '$.Arn') as Arn FROM aws.cloud_control_legacy.resources WHERE region = 'ap-southeast-2' and data__TypeName = 'AWS::S3::Bucket' and data__Identifier = 'stackql-trial-bucket-01';"
SELECT_AWS_CLOUD_CONTROL_BUCKET_VIEW_PROJECTION = "select Arn from aws.pseudo_s3.s3_bucket_listing where data__Identifier = 'stackql-trial-bucket-01' ;"
SELECT_AWS_CLOUD_CONTROL_BUCKET_VIEW_STAR = "select * from aws.pseudo_s3.s3_bucket_listing where data__Identifier = 'stackql-trial-bucket-01' ;"
SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION_DEFECTIVE = "SELECT JSON_EXTRACT(Arn, '$.Properties') as Arn FROM aws.cloud_control_legacy.resources WHERE region = 'ap-southeast-2' and data__TypeName = 'AWS::S3::Bucket' and data__Identifier = 'stackql-trial-bucket-01';"
GET_AWS_CLOUD_CONTROL_VPCS_DESC = "select Identifier, Properties from aws.cloud_control_legacy.resources where region = 'ap-southeast-1' and data__TypeName = 'AWS::EC2::VPC' and data__Identifier = 'CloudControlExample';"
GET_AWS_CLOUD_CONTROL_REQUEST_LOG_GROUP = """select TypeName, OperationStatus, StatusMessage, Identifier, RequestToken from aws.cloud_control.resource_requests where data__RequestToken = 'abc001' and region = 'ap-southeast-1';"""
SELECT_AWS_CLOUD_CONTROL_OPERATIONS_DESC = "select TypeName, OperationStatus, StatusMessage, Identifier, RequestToken from aws.cloud_control.resource_requests where data__ResourceRequestStatusFilter='{}' and region = 'ap-southeast-1' order by RequestToken desc;"
UPDATE_AWS_EC2_VOLUME = "update aws.ec2.volumes set Size = 12 WHERE region = 'ap-southeast-1' AND VolumeId = 'vol-000000000000001';"
UPDATE_GITHUB_ORG = "update github.orgs.orgs set data__description = 'Some silly description.' WHERE org = 'dummyorg';"
SELECT_GITHUB_REPOS_PAGES_SINGLE = "select url from github.repos.pages where owner = 'dummyorg' and repo = 'dummyapp.io';"
SELECT_GITHUB_REPOS_IDS_ASC = "select id from github.repos.repos where org = 'dummyorg' order by id ASC;"
SELECT_GITHUB_BRANCHES_NAMES_DESC = "select name from github.repos.branches where owner = 'dummyorg' and repo = 'dummyapp.io' order by name desc;"
SELECT_GITHUB_BRANCHES_NAMES_DESC_WRONG_COLUMN = "select name_wrong from github.repos.branches where owner = 'dummyorg' and repo = 'dummyapp.io' order by name desc;"
SELECT_GITHUB_REPOS_WITH_USEFUL_FUNCTIONS = "select name, split_part(teams_url, '/', 5) as extracted_team, regexp_replace((JSON_EXTRACT(owner, '$.url')), '^https://[^/]+/[^/]+/', 'username = ') as user_suffix, name like '%docusaurus%' as is_docusaurus, sqlite_version() as sqlite_lib_version from github.repos.repos where org = 'dummyorg' order by name ASC;"
SELECT_GITHUB_REPOS_FILTERED_SINGLE = "select id, name from github.repos.repos where org = 'dummyorg' and name = 'dummyapp.io';"
SELECT_GITHUB_SCIM_USERS = "select JSON_EXTRACT(name, '$.givenName') || ' ' || JSON_EXTRACT(name, '$.familyName') as name, userName, externalId, id from github.scim.users where org = 'dummyorg' order by id asc;"
SELECT_GITHUB_SAML_IDENTITIES = "select guid, JSON_EXTRACT(samlIdentity, '$.nameId') AS saml_id, JSON_EXTRACT(user, '$.login') AS github_login from github.scim.saml_ids where org = 'dummyorg' order by JSON_EXTRACT(user, '$.login') asc;"
SELECT_GITHUB_TAGS_COUNT = "select count(*) as ct from github.repos.tags where owner = 'dummyorg' and repo = 'dummyapp.io';"
SELECT_GITHUB_SCIM_JOIN_WITH_FUNCTIONS = "select substr(su.userName, 1, instr(su.userName, '@') - 1), su.externalId, su.id, u.login, u.two_factor_authentication AS is_two_fa_enabled from github.scim.users su inner join github.users.users u ON substr(su.userName, 1, instr(su.userName, '@') - 1) = u.username and substr(su.userName, 1, instr(su.userName, '@') - 1) = u.login where su.org = 'dummyorg' order by su.id asc;"
SELECT_GITHUB_ORGS_MEMBERS = "select om.login from github.orgs.members om where om.org = 'dummyorg' order by om.login desc;"
SELECT_GITHUB_JOIN_IN_PARAMS = "select r.name, col.login, col.type, col.role_name from github.repos.collaborators col inner join github.repos.repos r ON col.repo = r.name where col.owner = 'dummyorg' and r.org = 'dummyorg' order by r.name, col.login desc;"
SELECT_GITHUB_JOIN_IN_PARAMS_SPECIALCASE = "select r.id, r.name, col.login, col.type, col.role_name from github.repos.collaborators col inner join github.repos.repos r ON col.repo = r.name where col.owner = 'specialcaseorg' and r.org = 'specialcaseorg' order by r.name, col.login desc;"
SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_SIMPLE = "select r.name, col.login, col.type, col.role_name from stackql_analytics_github.repos.collaborators col inner join stackql_analytics_github.repos.repos r ON col.repo = r.name where col.owner = 'stackql' and r.org = 'stackql' order by r.name, col.login desc;"
SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_TRANSPARENT = "select r.name, col.login, col.type, col.role_name from github.repos.collaborators col inner join github.repos.repos r ON col.repo = r.name where col.owner = 'stackql' and r.org = 'stackql' order by r.name, col.login desc;"
SELECT_OKTA_APPS = "select name, status, label, id from okta.application.apps apps where apps.subdomain = 'example-subdomain' order by name asc;"
SELECT_OKTA_USERS_ASC = "select JSON_EXTRACT(ou.profile, '$.login') as login, ou.status from okta.user.users ou WHERE ou.subdomain = 'dummyorg' order by JSON_EXTRACT(ou.profile, '$.login') asc;"
PURGE_CONSERVATIVE = "PURGE CONSERVATIVE;"
PURGE_CONSERVATIVE_RESPONSE_JSON = [{'message': "PURGE of type 'conservative' successfully completed"}]
_SHOW_INSERT_GOOGLE_BIGQUERY_DATASET = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'simple-templating', 'insert-bigquery-datasets.iql'))
_SHOW_INSERT_EXTENDED_GOOGLE_BIGQUERY_DATASET = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'simple-templating', 'insert-bigquery-datasets-extended.iql'))
_SHOW_INSERT_GOOGLE_CONTAINER_CLUSTERS = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'simple-templating', 'insert-container-clusters.iql'))
def get_native_query_row_count_from_table(table_name :str, sql_backend_str :str) -> str:
if sql_backend_str == 'postgres_tcp':
return f"NATIVEQUERY 'SELECT COUNT(*) as object_count FROM \"{_PG_SCHEMA_PHYSICAL_TABLES}\".\"{table_name}\"' ;"
return f"NATIVEQUERY 'SELECT COUNT(*) as object_count FROM \"{table_name}\"' ;"
def get_native_table_count_by_name(table_name :str, sql_backend_str :str) -> str:
return f"NATIVEQUERY 'SELECT COUNT(*) as object_count FROM sqlite_master where type = 'table' and name = '{table_name}' ;"
SELECT_CONTRIVED_GCP_OKTA_JOIN = "select d1.name, d1.id, d2.name as d2_name, d2.status, d2.label, d2.id as d2_id from google.compute.disks d1 inner join okta.application.apps d2 on d1.name = d2.label where d1.project = 'testing-project' and d1.zone = 'australia-southeast1-b' and d2.subdomain = 'dev-79923018-admin' order by d1.name ASC;"
SELECT_GITHUB_OKTA_SAML_JOIN = "select JSON_EXTRACT(saml.samlIdentity, '$.username') as saml_username, om.login as github_login, ou.status as okta_status from github.scim.saml_ids saml INNER JOIN okta.user.users ou ON JSON_EXTRACT(saml.samlIdentity, '$.username') = JSON_EXTRACT(ou.profile, '$.login') INNER JOIN github.orgs.members om ON JSON_EXTRACT(saml.user, '$.login') = om.login where ou.subdomain = 'dummyorg' AND om.org = 'dummyorg' AND saml.org = 'dummyorg' order by om.login desc;"
SELECT_CONTRIVED_GCP_THREE_WAY_JOIN = "select d1.name as n, d1.id, n1.description, s1.description as s1_description from google.compute.disks d1 inner join google.compute.networks n1 on d1.name = n1.name inner join google.compute.subnetworks s1 on d1.name = s1.name where d1.project = 'testing-project' and d1.zone = 'australia-southeast1-b' and n1.project = 'testing-project' and s1.project = 'testing-project' and s1.region = 'australia-southeast1' ;"
SELECT_CONTRIVED_GCP_SELF_JOIN = "select d1.name as n, d1.id, d2.id as d2_id from google.compute.disks d1 inner join google.compute.disks d2 on d1.id = d2.id where d1.project = 'testing-project' and d1.zone = 'australia-southeast1-b' and d2.project = 'testing-project' and d2.zone = 'australia-southeast1-b' order by d1.name ASC;"
SELECT_CONTAINER_SUBNET_AGG_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aggregated-select', 'google', 'container', 'agg-subnetworks-allowed', 'table', 'simple-count-grouped-variant-desc.txt'))
SELECT_CONTAINER_SUBNET_AGG_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aggregated-select', 'google', 'container', 'agg-subnetworks-allowed', 'table', 'simple-count-grouped-variant-asc.txt'))
SELECT_CONTRIVED_GCP_OKTA_JOIN_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'joins', 'inner', 'contrived-gcp-okta-join.txt'))
SELECT_GITHUB_JOIN_DATA_FLOW_SEQUENTIAL = "select u.name, om.login, u.two_factor_authentication AS is_two_fa_enabled from github.orgs.members om inner join github.users.users u on om.login = u.login AND u.username = om.login where om.org = 'dummyorg' order by u.name desc;"
SHOW_INSERT_GOOGLE_IAM_SERVICE_ACCOUNTS = "show insert into google.iam.service_accounts;"
SHOW_INSERT_GOOGLE_COMPUTE_INSTANCE_IAM_POLICY_ERROR = "show insert into google.compute.instances_iam_policies;"
SELECT_CONTRIVED_GCP_THREE_WAY_JOIN_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'joins', 'inner', 'contrived-three-way-gcp-join.txt'))
SELECT_CONTRIVED_GCP_SELF_JOIN_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'joins', 'inner', 'contrived-gcp-self-join.txt'))
SELECT_CONTRIVED_GCP_GITHUB_JSON_DEPENDENT_JOIN = "SELECT i.name as instance_name, i.status as instance_status, c.sha as commit_sha, JSON_EXTRACT(c.commit, '$.author.email') as author_email, DATE(JSON_EXTRACT(c.commit, '$.author.date')) as commit_date FROM github.repos.commits c INNER JOIN google.compute.instances i ON JSON_EXTRACT(i.labels, '$.sha') = c.sha WHERE c.owner = 'dummyorg' AND c.repo = 'dummyapp.io' AND i.project = 'testing-project' AND i.zone = 'australia-southeast1-a';"
SELECT_CONTRIVED_GCP_GITHUB_JSON_DEPENDENT_JOIN_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'joins', 'inner', 'gcp-github-labelled-instances-commits.txt'))
SELECT_ACCELERATOR_TYPES_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'simple-select', 'compute-accelerator-type', 'select-zone-list-desc.txt'))
SELECT_MACHINE_TYPES_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'google', 'compute', 'instance-type-list-names-paginated-desc.txt'))
SELECT_OKTA_APPS_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'simple-select', 'okta', 'apps', 'select-apps-asc.txt'))
SELECT_OKTA_APPS_ASC_EXPECTED_JSON = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'simple-select', 'okta', 'apps', 'select-apps-asc.json'))
SELECT_OKTA_USERS_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'okta', 'select-users-asc.txt'))
SELECT_SOME_VIEW_EXPECTED_JSON = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'views', 'select-some-view.json'))
SELECT_SOME_VIEW_RECREATED_EXPECTED_JSON = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'views', 'select-some-view-recreated.json'))
SELECT_CROSS_CLOUD_DISKS_VIEW_EXPECTED_JSON = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'views', 'select-cross-cloud-disks.json'))
SELECT_POSTGRES_CATALOG_JOIN = "SELECT c.relname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = 'public' AND c.relkind in ('r', 'p');"
SELECT_AWS_VOLUMES_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'ec2', 'select-volumes-asc.txt'))
SELECT_AWS_EC2_VPN_GATEWAYS_NULL_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'ec2', 'select-vpn-gateways-empty.txt'))
SELECT_AWS_IAM_USERS_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'iam', 'select-users-asc.txt'))
SELECT_AWS_CLOUD_CONTROL_VPCS_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-list-vpcs-desc.txt'))
GET_AWS_CLOUD_CONTROL_VPCS_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-get-vpcs-desc.txt'))
SELECT_AWS_CLOUD_CONTROL_VPCS_DESC_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-list-vpcs-desc.json'))
SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-bucket-detail-projection.txt'))
SELECT_AWS_CLOUD_CONTROL_BUCKET_VIEW_STAR_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-bucket-detail-star.txt'))
SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-bucket-detail-projection.json'))
GET_AWS_CLOUD_CONTROL_VPCS_DESC_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-get-vpcs-desc.json'))
SELECT_AWS_CLOUD_CONTROL_OPERATIONS_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-list-operations-desc.txt'))
GET_AWS_CLOUD_CONTROL_REQUEST_LOG_GROUP_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-get-operation-desc.txt'))
SELECT_AWS_S3_OBJECTS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 's3', 'select-objects.txt'))
SELECT_AWS_S3_OBJECTS_NULL_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 's3', 'select-objects-empty.txt'))
SELECT_AWS_S3_BUCKETS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 's3', 'select-buckets.txt'))
SELECT_AWS_S3_BUCKET_LOCATIONS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 's3', 'select-bucket-locations.txt'))
VIEW_SELECT_AWS_CLOUD_CONTROL_BUCKET_DETAIL_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-bucket-detail.txt'))
VIEW_SELECT_STAR_AWS_CLOUD_CONTROL_BUCKET_DETAIL_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-star-bucket-detail.txt'))
AWS_CC_VIEW_SELECT_PROJECTION_BUCKET_FILTERED_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-projection-bucket-view-response-filtered-only.txt'))
AWS_CC_VIEW_SELECT_STAR_BUCKET_FILTERED_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-star-bucket-view-response-filtered-only.txt'))
AWS_CC_VIEW_SELECT_PROJECTION_BUCKET_COMPLEX_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-projection-bucket-view-parameter-pushed-and-response-filtered.txt'))
AWS_CC_VIEW_SELECT_STAR_BUCKET_COMPLEX_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aws', 'cloud_control', 'select-star-bucket-view-parameter-pushed-and-response-filtered.txt'))
SELECT_GITHUB_REPOS_PAGES_SINGLE_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'repos', 'select-github-repos-pages.txt'))
SELECT_GITHUB_REPOS_IDS_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'repos', 'select-github-repos-ids-asc.txt'))
SELECT_GITHUB_REPOS_WITH_USEFUL_FUNCTIONS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'repos', 'select-github-repos-functions.txt'))
SELECT_GITHUB_REPOS_FILTERED_SINGLE_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'repos', 'select-github-repos-single-filtered.txt'))
SELECT_GITHUB_SCIM_USERS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'scim', 'select-github-scim-users.txt'))
SELECT_GITHUB_SAML_IDENTITIES_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'scim', 'select-github-saml-identities.txt'))
SELECT_GITHUB_BRANCHES_NAMES_DESC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'repos', 'select-github-branches-names-desc.txt'))
SELECT_GITHUB_TAGS_COUNT_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'repos', 'select-github-tags-count.txt'))
SELECT_GITHUB_JOIN_DATA_FLOW_SEQUENTIAL_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'joins', 'select-github-sequential-join.txt'))
SELECT_GITHUB_JOIN_IN_PARAMS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'joins', 'select-github-join-on-path-param.txt'))
SELECT_GITHUB_SCIM_JOIN_WITH_FUNCTIONS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'joins', 'select-github-sequential-join-with-functions.txt'))
SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'joins', 'analytics-repositories-collaborators.txt'))
SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_SPECIALCASE_JSON_EXPECTED = get_json_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'joins', 'specialcase-firstlook-repositories-collaborators.json'))
SELECT_GITHUB_OKTA_SAML_JOIN_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'joins', 'inner', 'github-saml-members-okta-users.txt'))
SELECT_GITHUB_ORGS_MEMBERS_PAGE_LIMITED_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'github', 'orgs', 'page-limited-members.txt'))
SELECT_GOOGLE_COMPUTE_INSTANCE_IAM_POLICY_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'google', 'compute', 'instance-iam-policy-projection.txt'))
SHOW_INSERT_GOOGLE_IAM_SERVICE_ACCOUNTS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'show', 'show-insert-google-iam-service-accounts.txt'))
SHOW_INSERT_GOOGLE_COMPUTE_INSTANCE_IAM_POLICY_ERROR_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'show', 'show-insert-google-compute-instances-iam-error.txt'))
SELECT_SUMOLOGIC_COLLECTORS_IDS = 'select id from sumologic.collectors.collectors order by id desc;'
SELECT_SUMOLOGIC_COLLECTORS_IDS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'sumologic', 'select-collectors-desc.txt'))
GET_IAM_POLICY_AGG_ASC_INPUT_FILE = os.path.join(repository_root, 'test', 'assets', 'input', 'select-exec-dependent-org-iam-policy.iql')
GET_IAM_POLICY_AGG_ASC_INPUT_FILE_DOCKER = os.path.join('/opt', 'stackql', 'input', 'select-exec-dependent-org-iam-policy.iql')
_FILE_QUERY_PARSER_TEST_POSTGRES_CASTING = os.path.join(repository_root, 'test', 'assets', 'input', 'parser-testing', 'postgres-casting-query.sql')
_FILE_QUERY_PARSER_TEST_KEYWORD_QUOTING = os.path.join(repository_root, 'test', 'assets', 'input', 'parser-testing', 'keyword-quoting-query.sql')
_QUERY_PARSER_TEST_POSTGRES_CASTING = get_output_from_local_file(_FILE_QUERY_PARSER_TEST_POSTGRES_CASTING)
_QUERY_PARSER_TEST_KEYWORD_QUOTING = get_output_from_local_file(_FILE_QUERY_PARSER_TEST_KEYWORD_QUOTING)
GET_IAM_POLICY_AGG_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'aggregated-select', 'google', 'cloudresourcemanager', 'select-exec-getiampolicy-agg.csv'))
SHOW_METHODS_GITHUB_REPOS_REPOS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'show', 'show-methods-github-repo-repo.txt'))
SELECT_GOOGLE_CLOUDRESOURCEMANAGER_IAMPOLICY = "SELECT role, members, condition from google.cloudresourcemanager.project_iam_policies where projectsId = 'testproject' order by role asc;"
SELECT_GOOGLE_CLOUDRESOURCEMANAGER_IAMPOLICY_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'google', 'cloudresourcemanager', 'projects-getiampolicy-roles-asc.txt'))
SELECT_GOOGLE_CLOUDRESOURCEMANAGER_IAMPOLICY_LIKE_FILTERED = "SELECT role, members, condition from google.cloudresourcemanager.project_iam_policies where projectsId = 'testproject' and role like '%owner' order by role asc;"
SELECT_GOOGLE_CLOUDRESOURCEMANAGER_IAMPOLICY_COMPARISON_FILTERED = "SELECT role, members, condition from google.cloudresourcemanager.project_iam_policies where projectsId = 'testproject' and role = 'roles/owner' order by role asc;"
SELECT_GOOGLE_CLOUDRESOURCEMANAGER_IAMPOLICY_FILTERED_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'google', 'cloudresourcemanager', 'projects-getiampolicy-roles-asc-filtered.txt'))
SELECT_GOOGLE_JOIN_CONCATENATED_SELECT_EXPRESSIONS :bytes = b"""SELECT i.zone, i.name, i.machineType, i.deletionProtection, '[{"subnetwork":"' || JSON_EXTRACT(i.networkInterfaces, '$[0].subnetwork') || '"}]', '[{"boot": true, "initializeParams": { "diskSizeGb": "' || JSON_EXTRACT(i.disks, '$[0].diskSizeGb') || '", "sourceImage": "' || d.sourceImage || '"}}]', i.labels FROM google.compute.instances i INNER JOIN google.compute.disks d ON i.name = d.name WHERE i.project = 'testing-project' AND i.zone = 'australia-southeast1-a' AND d.project = 'testing-project' AND d.zone = 'australia-southeast1-a' AND i.name LIKE '%' order by i.name DESC;"""
SELECT_GOOGLE_JOIN_CONCATENATED_SELECT_EXPRESSIONS_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'google', 'joins', 'disks-instances-rewritten.txt'))
_CREATE_SOME_VIEW = "create or replace view some_view as select id, name, url from github.repos.repos where org = 'stackql' order by name;"
_RECREATE_SOME_VIEW = "create or replace view some_view as select id, name from github.repos.repos where org = 'stackql' order by name;"
def get_select_k8s_nodes_asc(execution_env :str) -> str:
k8s_host = '127.0.0.1'
if execution_env == 'docker':
k8s_host = 'host.docker.internal'
return f"select json_extract(metadata, '$.name') as name, json_extract(metadata, '$.uid') as uid, json_extract(metadata, '$.creationTimestamp') as creationTimestamp from k8s.core_v1.nodes where cluster_addr = '{k8s_host}:{MOCKSERVER_PORT_K8S}' order by name asc;"
def get_registry_mock_url(execution_env :str) -> str:
host = 'localhost'
if execution_env == 'docker':
host = 'host.docker.internal'
return f"http://{host}:{MOCKSERVER_PORT_REGISTRY}/gh/stackql/stackql-provider-registry/main/providers"
SELECT_K8S_NODES_ASC_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'k8s', 'select-nodes-asc.txt'))
REGISTRY_LIST = "registry list;"
REGISTRY_GOOGLE_PROVIDER_LIST = "registry list google;"
REGISTRY_LIST_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'registry', 'all-providers-list.txt'))
REGISTRY_GOOGLE_PROVIDER_LIST_EXPECTED = get_output_from_local_file(os.path.join('test', 'assets', 'expected', 'registry', 'google-list.txt'))
## End path variables hack
print(f'sundry_config: "{sundry_config}"')
_sundry_config = json.loads(sundry_config) if sundry_config else {}
must_use_stackql_preinstalled :bool = use_stackql_preinstalled.lower() == 'true'
NATIVEQUERY_OKTA_APPS_ROW_COUNT_DISCO_ID_ONE = get_native_query_row_count_from_table('okta.application.apps.Application.generation_1', sql_backend_str)
NATIVEQUERY_OKTA_APPS_ROW_COUNT_DISCO_ID_THREE = get_native_query_row_count_from_table('okta.application.apps.Application.generation_3', sql_backend_str)
rv = {
## general config
'AUTH_AZURE_FAULTY': '{ "azure": { "type": "service_account", "credentialsenvar": "SOME_RUBBISH_ENV_VAR" } }',
'AZURE_SECRET_STR': AZURE_SECRET_STR,
'BUILDMAJORVERSION': _BUILD_MAJOR_VERSION,
'BUILDMINORVERSION': _BUILD_MINOR_VERSION,
'BUILDPATCHVERSION': _BUILD_PATCH_VERSION,
'DB_INTERNAL_CFG_LAX': DB_INTERNAL_CFG_LAX,
'DB_SETUP_SRC': get_db_setup_src(sql_backend_str),
'DIGITALOCEAN_SECRET_STR': DIGITALOCEAN_SECRET_STR,
'DUMMY_DIGITALOCEAN_USERNAME_STR': DUMMY_DIGITALOCEAN_USERNAME_STR,
'DUMMY_DIGITALOCEAN_PASSWORD_STR': DUMMY_DIGITALOCEAN_PASSWORD_STR,
'GC_CFG_EAGER': _GC_CFG_EAGER,
'GITHUB_SECRET_STR': GITHUB_SECRET_STR,
'IS_WINDOWS': IS_WINDOWS,
'JSONNET_PLUS_ENV_VARS_EXPECTED': _JSONNET_PLUS_ENV_VARS_EXPECTED,
'JSONNET_PLUS_ENV_VARS_QUERY_FILE': _JSONNET_PLUS_ENV_VARS_QUERY_FILE,
'JSONNET_PLUS_ENV_VARS_VAR_FILE': _JSONNET_PLUS_ENV_VARS_VAR_FILE,
'K8S_SECRET_STR': K8S_SECRET_STR,
'MOCKSERVER_JAR': MOCKSERVER_JAR,
'MOCKSERVER_PORT_AWS': MOCKSERVER_PORT_AWS,
'MOCKSERVER_PORT_AZURE': MOCKSERVER_PORT_AZURE,
'MOCKSERVER_PORT_GITHUB': MOCKSERVER_PORT_GITHUB,
'MOCKSERVER_PORT_GOOGLE': MOCKSERVER_PORT_GOOGLE,
'MOCKSERVER_PORT_GOOGLEADMIN': MOCKSERVER_PORT_GOOGLEADMIN,
'MOCKSERVER_PORT_STACKQL_AUTH_TESTING': MOCKSERVER_PORT_STACKQL_AUTH_TESTING,
'MOCKSERVER_PORT_OAUTH_CLIENT_CREDENTIALS_TOKEN': MOCKSERVER_PORT_OAUTH_CLIENT_CREDENTIALS_TOKEN,
'MOCKSERVER_PORT_K8S': MOCKSERVER_PORT_K8S,
'MOCKSERVER_PORT_OKTA': MOCKSERVER_PORT_OKTA,
'MOCKSERVER_PORT_REGISTRY': MOCKSERVER_PORT_REGISTRY,
'MOCKSERVER_PORT_SUMOLOGIC': MOCKSERVER_PORT_SUMOLOGIC,
'MOCKSERVER_PORT_DIGITALOCEAN': MOCKSERVER_PORT_DIGITALOCEAN,
'NAMESPACES_TTL_SIMPLE': NAMESPACES_TTL_SIMPLE,
'NAMESPACES_TTL_SPECIALCASE_TRANSPARENT': NAMESPACES_TTL_SPECIALCASE_TRANSPARENT,
'NAMESPACES_TTL_TRANSPARENT': NAMESPACES_TTL_TRANSPARENT,
'OKTA_SECRET_STR': OKTA_SECRET_STR,
'PG_SRV_MTLS_DOCKER_CFG_STR': PG_SRV_MTLS_DOCKER_CFG_STR,
'PG_SRV_PORT_DOCKER_MTLS': PG_SRV_PORT_DOCKER_MTLS,
'PG_SRV_PORT_DOCKER_MTLS_WITH_EAGER_GC': PG_SRV_PORT_DOCKER_MTLS_WITH_EAGER_GC,
'PG_SRV_PORT_DOCKER_MTLS_WITH_NAMESPACES': PG_SRV_PORT_DOCKER_MTLS_WITH_NAMESPACES,
'PG_SRV_PORT_DOCKER_UNENCRYPTED': PG_SRV_PORT_DOCKER_UNENCRYPTED,
'PG_SRV_PORT_MTLS': PG_SRV_PORT_MTLS,
'PG_SRV_PORT_MTLS_WITH_EAGER_GC': PG_SRV_PORT_MTLS_WITH_EAGER_GC,
'PG_SRV_PORT_MTLS_WITH_NAMESPACES': PG_SRV_PORT_MTLS_WITH_NAMESPACES,
'PG_SRV_PORT_DOCKER_MTLS_EXPORT': PG_SRV_PORT_DOCKER_MTLS_EXPORT,
'PG_SRV_PORT_MTLS_EXPORT': PG_SRV_PORT_MTLS_EXPORT,
'PG_SRV_PORT_UNENCRYPTED': PG_SRV_PORT_UNENCRYPTED,
'POSTGRES_URL_UNENCRYPTED_CONN': POSTGRES_URL_UNENCRYPTED_CONN,
'PSQL_CLIENT_HOST': PSQL_CLIENT_HOST,
'PSQL_EXE': PSQL_EXE,
'SQLITE_EXE': SQLITE_EXE,
'EXPORT_SQLITE_FILE_PATH': get_sqlite_export_db_path(execution_env),
'REGISTRY_ROOT_CANONICAL': _get_registry_canonical_no_verify(_sundry_config.get('registry_path_canonical')),
'REGISTRY_ROOT_DEPRECATED': _REGISTRY_DEPRECATED,
'REGISTRY_CANONICAL_CFG_STR': _get_registry_canonical_no_verify(_sundry_config.get('registry_path_canonical')),
'REGISTRY_CANONICAL_NO_VERIFY_CFG_STR': _get_registry_canonical_no_verify(_sundry_config.get('registry_path_canonical')),
'REGISTRY_DEPRECATED_CFG_STR': _REGISTRY_DEPRECATED,
'REGISTRY_MOCKED_CFG_STR': get_registry_mocked(execution_env),
'REGISTRY_NO_VERIFY_CFG_STR': _get_registry_no_verify(_sundry_config.get('registry_path')),
'REGISTRY_NO_VERIFY_CFG_JSON_STR': _get_registry_no_verify(_sundry_config.get('registry_path')).get_config_str(execution_environment=execution_env),
'REGISTRY_NULL': _REGISTRY_NULL,
'REPOSITORY_ROOT': repository_root,
'SQL_BACKEND_CFG_STR_ANALYTICS': get_analytics_sql_backend(execution_env, sql_backend_str),
'SQL_BACKEND_CFG_STR_CANONICAL': get_canonical_sql_backend(execution_env, sql_backend_str),
'SQL_CLIENT_EXPORT_BACKEND': get_export_sql_backend(execution_env, sql_backend_str),
'SQL_CLIENT_EXPORT_CONNECTION_ARG': get_export_sql_connection_arg(execution_env, sql_backend_str),
'STACKQL_EXE': get_stackql_exe(execution_env, must_use_stackql_preinstalled),
'STACKQL_MCP_CLIENT_EXE': get_stackql_mcp_client_exe(execution_env, must_use_stackql_preinstalled),
'SUMOLOGIC_SECRET_STR': SUMOLOGIC_SECRET_STR,
## queries and expectations
'AWS_CC_VIEW_SELECT_PROJECTION_BUCKET_COMPLEX_EXPECTED': AWS_CC_VIEW_SELECT_PROJECTION_BUCKET_COMPLEX_EXPECTED,
'AWS_CC_VIEW_SELECT_PROJECTION_BUCKET_FILTERED_EXPECTED': AWS_CC_VIEW_SELECT_PROJECTION_BUCKET_FILTERED_EXPECTED,
'AWS_CC_VIEW_SELECT_STAR_BUCKET_COMPLEX_EXPECTED': AWS_CC_VIEW_SELECT_STAR_BUCKET_COMPLEX_EXPECTED,
'AWS_CC_VIEW_SELECT_STAR_BUCKET_FILTERED_EXPECTED': AWS_CC_VIEW_SELECT_STAR_BUCKET_FILTERED_EXPECTED,
'AWS_CLOUD_CONTROL_METHOD_SIGNATURE_CMD_ARR': [ SELECT_AWS_CLOUD_CONTROL_VPCS_DESC, GET_AWS_CLOUD_CONTROL_VPCS_DESC ],
'AWS_CLOUD_CONTROL_METHOD_SIGNATURE_CMD_ARR_EXPECTED': SELECT_AWS_CLOUD_CONTROL_VPCS_DESC_JSON_EXPECTED + GET_AWS_CLOUD_CONTROL_VPCS_DESC_JSON_EXPECTED,
'AWS_CLOUD_CONTROL_BUCKET_DETAIL_PROJECTION_DEFECTIVE_CMD_ARR': [ SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION_DEFECTIVE, SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION ],
'AWS_CLOUD_CONTROL_BUCKET_DETAIL_PROJECTION_DEFECTIVE_CMD_ARR_EXPECTED': SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION_JSON_EXPECTED,
'AWS_CLOUD_CONTROL_BUCKET_VIEW_DETAIL_PROJECTION': SELECT_AWS_CLOUD_CONTROL_BUCKET_VIEW_PROJECTION,
'AWS_CLOUD_CONTROL_BUCKET_VIEW_DETAIL_PROJECTION_EXPECTED': SELECT_AWS_CLOUD_CONTROL_BUCKET_PROJECTION_EXPECTED,
'AWS_CLOUD_CONTROL_BUCKET_VIEW_DETAIL_STAR': SELECT_AWS_CLOUD_CONTROL_BUCKET_VIEW_STAR,
'AWS_CLOUD_CONTROL_BUCKET_VIEW_DETAIL_STAR_EXPECTED': SELECT_AWS_CLOUD_CONTROL_BUCKET_VIEW_STAR_EXPECTED,
'AZURE_VM_SIZES_ENUMERATION': _AZURE_VM_SIZES_ENUMERATION,
'CREATE_AWS_VOLUME': CREATE_AWS_VOLUME,
'DESCRIBE_AWS_EC2_INSTANCES': DESCRIBE_AWS_EC2_INSTANCES,
'DESCRIBE_AWS_EC2_DEFAULT_KMS_KEY_ID': DESCRIBE_AWS_EC2_DEFAULT_KMS_KEY_ID,
'DESCRIBE_GITHUB_REPOS_PAGES': DESCRIBE_GITHUB_REPOS_PAGES,
'GET_AWS_CLOUD_CONTROL_REQUEST_LOG_GROUP': GET_AWS_CLOUD_CONTROL_REQUEST_LOG_GROUP,
'GET_AWS_CLOUD_CONTROL_REQUEST_LOG_GROUP_EXPECTED': GET_AWS_CLOUD_CONTROL_REQUEST_LOG_GROUP_EXPECTED,
'GET_AWS_CLOUD_CONTROL_VPCS_DESC': GET_AWS_CLOUD_CONTROL_VPCS_DESC,
'GET_AWS_CLOUD_CONTROL_VPCS_DESC_EXPECTED': GET_AWS_CLOUD_CONTROL_VPCS_DESC_EXPECTED,
'GET_IAM_POLICY_AGG_ASC_EXPECTED': GET_IAM_POLICY_AGG_ASC_EXPECTED,
'PG_CLIENT_SETUP_QUERIES': [ SHOW_TRANSACTION_ISOLATION_LEVEL, SELECT_HSTORE_DETAILS ],
'PG_CLIENT_SETUP_QUERIES_JSON_EXPECTED': SHOW_TRANSACTION_ISOLATION_LEVEL_JSON_EXPECTED + SELECT_HSTORE_DETAILS_JSON_EXPECTED,
'PG_CLIENT_SETUP_QUERIES_TUPLES_EXPECTED': SHOW_TRANSACTION_ISOLATION_LEVEL_TUPLES_EXPECTED + SELECT_HSTORE_DETAILS_TUPLES_EXPECTED,
'PSQL_PASSWORD': generate_password(),
'QUERY_PARSER_TEST_KEYWORD_QUOTING': _QUERY_PARSER_TEST_KEYWORD_QUOTING,
'QUERY_PARSER_TEST_POSTGRES_CASTING': _QUERY_PARSER_TEST_POSTGRES_CASTING,
'REGISTRY_GOOGLE_PROVIDER_LIST': REGISTRY_GOOGLE_PROVIDER_LIST,
'REGISTRY_GOOGLE_PROVIDER_LIST_EXPECTED': REGISTRY_GOOGLE_PROVIDER_LIST_EXPECTED,
'REGISTRY_LIST': REGISTRY_LIST,
'REGISTRY_LIST_EXPECTED': REGISTRY_LIST_EXPECTED,
'SELECT_ACCELERATOR_TYPES_DESC': SELECT_ACCELERATOR_TYPES_DESC,
'SELECT_ACCELERATOR_TYPES_DESC_EXPECTED': SELECT_ACCELERATOR_TYPES_DESC_EXPECTED,
'SELECT_ACCELERATOR_TYPES_DESC_SEQUENCE': [ SELECT_ACCELERATOR_TYPES_DESC, SELECT_ACCELERATOR_TYPES_DESC_FROM_INTEL_VIEWS, SELECT_ACCELERATOR_TYPES_DESC_FROM_INTEL_VIEWS_SUBQUERY ],
'SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_EXPECTED': SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_EXPECTED,
'SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_SIMPLE': SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_SIMPLE,
'SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_TRANSPARENT': SELECT_ANALYTICS_CACHE_GITHUB_REPOSITORIES_COLLABORATORS_TRANSPARENT,
'SELECT_AWS_CLOUD_CONTROL_EVENTS_MINIMAL': [ SELECT_AWS_CLOUD_CONTROL_EVENTS_MINIMAL ],
'SELECT_AWS_CLOUD_CONTROL_EVENTS_MINIMAL_EXPECTED': SELECT_AWS_CLOUD_CONTROL_EVENTS_MINIMAL_EXPECTED,
'SELECT_AWS_CLOUD_CONTROL_OPERATIONS_DESC': SELECT_AWS_CLOUD_CONTROL_OPERATIONS_DESC,
'SELECT_AWS_CLOUD_CONTROL_OPERATIONS_DESC_EXPECTED': SELECT_AWS_CLOUD_CONTROL_OPERATIONS_DESC_EXPECTED,
'SELECT_AWS_CLOUD_CONTROL_VPCS_DESC': SELECT_AWS_CLOUD_CONTROL_VPCS_DESC,
'SELECT_AWS_CLOUD_CONTROL_VPCS_DESC_EXPECTED': SELECT_AWS_CLOUD_CONTROL_VPCS_DESC_EXPECTED,
'SELECT_AWS_EC2_VPN_GATEWAYS_NULL': SELECT_AWS_EC2_VPN_GATEWAYS_NULL,
'SELECT_AWS_EC2_VPN_GATEWAYS_NULL_EXPECTED': SELECT_AWS_EC2_VPN_GATEWAYS_NULL_EXPECTED,