bulk_data_test_kit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/lib/bulk_data_test_kit/bulk_data_jwks.json +58 -0
  4. data/lib/bulk_data_test_kit/bulk_data_test_kit_properties.rb +20 -0
  5. data/lib/bulk_data_test_kit/bulk_export_validation_tester.rb +214 -0
  6. data/lib/bulk_data_test_kit/export_cancel_tests.rb +43 -0
  7. data/lib/bulk_data_test_kit/export_kick_off_performer.rb +26 -0
  8. data/lib/bulk_data_test_kit/export_operation_tests.rb +171 -0
  9. data/lib/bulk_data_test_kit/export_parameters_tests.rb +49 -0
  10. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_export_cancel_test.rb +35 -0
  11. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_export_kick_off_test.rb +37 -0
  12. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_export_operation_support_test.rb +46 -0
  13. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_export_tests_test_group.rb +41 -0
  14. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_group_export_test_group.rb +24 -0
  15. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_multiple_patients_test.rb +23 -0
  16. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_ndjson_download_test.rb +33 -0
  17. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_no_auth_test.rb +35 -0
  18. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_output_check_test.rb +45 -0
  19. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_patient_export_test_group.rb +24 -0
  20. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_smart_backend_services_group.rb +21 -0
  21. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_status_check_test.rb +43 -0
  22. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_system_export_test_group.rb +24 -0
  23. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_test_suite.rb +166 -0
  24. data/lib/bulk_data_test_kit/v1.0.1/bulk_data_valid_resources_test.rb +30 -0
  25. data/lib/bulk_data_test_kit/v1.0.1/group/bulk_data_group_export_cancel_group.rb +32 -0
  26. data/lib/bulk_data_test_kit/v1.0.1/group/bulk_data_group_export_group.rb +102 -0
  27. data/lib/bulk_data_test_kit/v1.0.1/group/bulk_data_group_export_validation_group.rb +51 -0
  28. data/lib/bulk_data_test_kit/v1.0.1/patient/bulk_data_patient_export_cancel_group.rb +32 -0
  29. data/lib/bulk_data_test_kit/v1.0.1/patient/bulk_data_patient_export_group.rb +108 -0
  30. data/lib/bulk_data_test_kit/v1.0.1/patient/bulk_data_patient_export_validation_group.rb +63 -0
  31. data/lib/bulk_data_test_kit/v1.0.1/system_export/bulk_data_system_export_cancel_group.rb +32 -0
  32. data/lib/bulk_data_test_kit/v1.0.1/system_export/bulk_data_system_export_group.rb +108 -0
  33. data/lib/bulk_data_test_kit/v1.0.1/system_export/bulk_data_system_export_validation_group.rb +63 -0
  34. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_export_cancel_test.rb +28 -0
  35. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_export_tests_test_group.rb +41 -0
  36. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_group_export_test_group.rb +35 -0
  37. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_outputFormat_param_test.rb +36 -0
  38. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_patient_export_test_group.rb +35 -0
  39. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_since_param_test.rb +48 -0
  40. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_system_export_test_group.rb +35 -0
  41. data/lib/bulk_data_test_kit/v2.0.0/bulk_data_test_suite.rb +165 -0
  42. data/lib/bulk_data_test_kit/v2.0.0/group/bulk_data_group_export_cancel_group.rb +15 -0
  43. data/lib/bulk_data_test_kit/v2.0.0/group/bulk_data_group_export_parameters_group.rb +40 -0
  44. data/lib/bulk_data_test_kit/v2.0.0/patient/bulk_data_patient_export_cancel_group.rb +18 -0
  45. data/lib/bulk_data_test_kit/v2.0.0/patient/bulk_data_patient_export_parameters_group.rb +37 -0
  46. data/lib/bulk_data_test_kit/v2.0.0/system_export/bulk_data_system_export_cancel_group.rb +18 -0
  47. data/lib/bulk_data_test_kit/v2.0.0/system_export/bulk_data_system_export_parameters_group.rb +37 -0
  48. data/lib/bulk_data_test_kit/version.rb +5 -0
  49. data/lib/bulk_data_test_kit.rb +4 -0
  50. metadata +289 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 35fe284d715cfa81554188cf0d1c8e5d50680581c94393621d2b787244ed02dc
4
+ data.tar.gz: 69db567ad4af83bfd3494ab56f330ed9ad2d850be0bf124f605de25e04941a6d
5
+ SHA512:
6
+ metadata.gz: e04ac154598f5efc1983c5e47bd97297ac4ccfc09ab67c97956a94741391e4ba41ce8274bd562a4387914e67d0a806f34d3d2841fd39b4917fcb11e58aacf027
7
+ data.tar.gz: 4d6ebe6ffadcd7fa4ae76e7d67b0cd2098ce5d4badc3f659ebeadc72f0ad8eebd891d68b3ea13e4084a235c66863d7db51632366e65012d31dbadcdfd0b91e26
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,58 @@
1
+ {
2
+ "keys":
3
+ [{
4
+ "kty": "EC",
5
+ "crv": "P-384",
6
+ "x": "JQKTsV6PT5Szf4QtDA1qrs0EJ1pbimQmM2SKvzOlIAqlph3h1OHmZ2i7MXahIF2C",
7
+ "y": "bRWWQRJBgDa6CTgwofYrHjVGcO-A7WNEnu4oJA5OUJPPPpczgx1g2NsfinK-D2Rw",
8
+ "use": "sig",
9
+ "key_ops": [
10
+ "verify"
11
+ ],
12
+ "ext": true,
13
+ "kid": "4b49a739d1eb115b3225f4cf9beb6d1b",
14
+ "alg": "ES384"
15
+ },
16
+ {
17
+ "kty": "EC",
18
+ "crv": "P-384",
19
+ "d": "kDkn55p7gryKk2tj6z2ij7ExUnhi0ngxXosvqa73y7epwgthFqaJwApmiXXU2yhK",
20
+ "x": "JQKTsV6PT5Szf4QtDA1qrs0EJ1pbimQmM2SKvzOlIAqlph3h1OHmZ2i7MXahIF2C",
21
+ "y": "bRWWQRJBgDa6CTgwofYrHjVGcO-A7WNEnu4oJA5OUJPPPpczgx1g2NsfinK-D2Rw",
22
+ "key_ops": [
23
+ "sign"
24
+ ],
25
+ "ext": true,
26
+ "kid": "4b49a739d1eb115b3225f4cf9beb6d1b",
27
+ "alg": "ES384"
28
+ },
29
+ {
30
+ "kty": "RSA",
31
+ "alg": "RS384",
32
+ "n": "vjbIzTqiY8K8zApeNng5ekNNIxJfXAue9BjoMrZ9Qy9m7yIA-tf6muEupEXWhq70tC7vIGLqJJ4O8m7yiH8H2qklX2mCAMg3xG3nbykY2X7JXtW9P8VIdG0sAMt5aZQnUGCgSS3n0qaooGn2LUlTGIR88Qi-4Nrao9_3Ki3UCiICeCiAE224jGCg0OlQU6qj2gEB3o-DWJFlG_dz1y-Mxo5ivaeM0vWuodjDrp-aiabJcSF_dx26sdC9dZdBKXFDq0t19I9S9AyGpGDJwzGRtWHY6LsskNHLvo8Zb5AsJ9eRZKpnh30SYBZI9WHtzU85M9WQqdScR69Vyp-6Uhfbvw",
33
+ "e": "AQAB",
34
+ "use": "sig",
35
+ "key_ops": [
36
+ "verify"
37
+ ],
38
+ "ext": true,
39
+ "kid": "b41528b6f37a9500edb8a905a595bdd7"
40
+ },
41
+ {
42
+ "kty": "RSA",
43
+ "alg": "RS384",
44
+ "n": "vjbIzTqiY8K8zApeNng5ekNNIxJfXAue9BjoMrZ9Qy9m7yIA-tf6muEupEXWhq70tC7vIGLqJJ4O8m7yiH8H2qklX2mCAMg3xG3nbykY2X7JXtW9P8VIdG0sAMt5aZQnUGCgSS3n0qaooGn2LUlTGIR88Qi-4Nrao9_3Ki3UCiICeCiAE224jGCg0OlQU6qj2gEB3o-DWJFlG_dz1y-Mxo5ivaeM0vWuodjDrp-aiabJcSF_dx26sdC9dZdBKXFDq0t19I9S9AyGpGDJwzGRtWHY6LsskNHLvo8Zb5AsJ9eRZKpnh30SYBZI9WHtzU85M9WQqdScR69Vyp-6Uhfbvw",
45
+ "e": "AQAB",
46
+ "d": "rriV9GYimi5by7TOW4xNh6_gYBHVRDBsft2OFF8qapdVHt2GNuRDDxc_B6ga6TY2Enh2MLKLTr1dD3W4FIdTCJiMerrorp07FJS7nJEMgWQDxrfgkX4_EqrhW42L5d4vypYnRXEEW6u4gzkx5uFOkdvJBIK7CsIdSaBFYhochnynNgvbKWasi4rl2hayEH8tdf3B7Z6OIH9alspBTaq3j_zJt_KkrpYEzIUb4UgALB5NTWn5YKr0Avk_asOg8YfjViQwO9ASGaWjQeJ2Rx8OEQwBMQHSDMCSWNiWmYOu9PcwSZFc1vLxqzyIM8QrQSJHCCMo_wGYgke_r0CLeONHEQ",
47
+ "p": "5hH_QApWGeobRi1n7XbMfJYohB8K3JDPa0MspfplHpJ-17JiGG2sNoBdBcpaPRf9OX48P8VqO0qrSSRAk-I-uO6OO9BHbIukXJILqnY2JmurYzbcYbt5FVbknlHRJojkF6-7sFBazpueUlOnXCw7X7Z_SkfNE4QX5Ejm2Zm5mek",
48
+ "q": "06bZz7c7K9s1-aEZsxYnLJ9eTpKlt1tIBDA_LwIh5W3w259pes2kUtimbnkyOf-V2ZIERsFCh5s-S9IOEMvAIa6M5j9GW1ILNT7AcHIUfcyFcH-FF8BU_KJdRP5PXnIXFdYcylvsdoIdchy1AaUIzyiKRCU3HBYI75hez0l_F2c",
49
+ "dp": "h_sVIXW6hCCRND48EedIX06k7conMkxIu_39ErDXOWWeoMAnKIcR5TijQnviL__QxD1vQMXezuKIMHfDz2RGbClbWdD1lhtG7wvG515tDPJQXxia0wzqOQmdoFF9S8hXAAT26vPjaAAkaEZXQaxG_4Au5elgNWu6b0wDXZN1Vpk",
50
+ "dq": "GqS0YpuUTU8JGmWXUJ4HTGy7eHSpe8134V8ZdRd1oOYYHe2RX64nc25mdR24nuh3uq3Q7_9AGsYGL5E_yAl-JD9O6WUpvDE1y_wcSYty3Os0GRdUb8r8Z9kgmKDS6Pa_xTXw5eBwgfKbNlQ6zPwzgbB-x1lP-K8lbNPni3ybDR0",
51
+ "qi": "cqQfoi0sM5Su8ZOhznmdWrDIQB28H6fBKiabgaIKkbWZV4e0nwFvLquHjPOvv4Ao8iEGU5dyhvg0n5BKYPi-4mp6M6OA1sy0NrTr7EsKSYGyu2pBq9rw4oAYTM2LXKg6K-awgUUlkc451IwxHBAe15PWCBM3kvLQeijNid0Vz5I",
52
+ "key_ops": [
53
+ "sign"
54
+ ],
55
+ "ext": true,
56
+ "kid": "b41528b6f37a9500edb8a905a595bdd7"
57
+ }]
58
+ }
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulkDataTestKit
4
+ class BulkDataTestKitProperties
5
+ ATTRIBUTES = %i[
6
+ resource_type
7
+ bulk_export_url
8
+ ].freeze
9
+
10
+ ATTRIBUTES.each { |name| attr_reader name }
11
+
12
+ def initialize(**properties)
13
+ properties.each do |key, value|
14
+ raise StandardError, "Unknown search test property: #{key}" unless ATTRIBUTES.include?(key)
15
+
16
+ instance_variable_set(:"@#{key}", value)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,214 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulkDataTestKit
4
+ module BulkExportValidationTester
5
+ attr_reader :metadata
6
+
7
+ MAX_NUM_COLLECTED_LINES = 100
8
+ MIN_RESOURCE_COUNT = 2
9
+
10
+ def resources_from_all_files
11
+ @resources_from_all_files ||= {}
12
+ end
13
+
14
+ def first_error
15
+ @first_error ||= {}
16
+ end
17
+
18
+ def patient_ids_seen
19
+ scratch[:patient_ids_seen] ||= []
20
+ end
21
+
22
+ def resource_type
23
+ @resource_type ||= ''
24
+ end
25
+
26
+ def validation_errors
27
+ @validation_errors ||= []
28
+ end
29
+
30
+ def build_headers(use_token)
31
+ headers = { accept: 'application/fhir+ndjson' }
32
+ headers.merge!({ authorization: "Bearer #{bearer_token}" }) if use_token == 'true'
33
+ headers
34
+ end
35
+
36
+ def stream_ndjson(endpoint, headers, process_chunk_line, process_response) # rubocop:disable Metrics/CyclomaticComplexity
37
+ hanging_chunk = String.new
38
+
39
+ process_body = proc { |chunk|
40
+ hanging_chunk << chunk
41
+ chunk_by_lines = hanging_chunk.lines
42
+
43
+ hanging_chunk = chunk_by_lines.pop || String.new
44
+
45
+ chunk_by_lines.each do |elem|
46
+ process_chunk_line.call(elem)
47
+ end
48
+ }
49
+
50
+ stream(process_body, endpoint, headers:)
51
+
52
+ max_redirect = 5
53
+
54
+ while [301, 302, 303, 307].include?(response[:status]) &&
55
+ request.response_header('location')&.value.present? &&
56
+ max_redirect.positive?
57
+
58
+ max_redirect -= 1
59
+
60
+ redirect_url = request.response_header('location')&.value
61
+
62
+ # handle relative redirects
63
+ redirect_url = URI.parse(endpoint).merge(redirect_url).to_s unless redirect_url.start_with?('http')
64
+
65
+ redirect_headers = headers.except(:authorization)
66
+
67
+ stream(process_body, redirect_url, headers: redirect_headers)
68
+ end
69
+
70
+ process_chunk_line.call(hanging_chunk)
71
+ process_response.call(response)
72
+ end
73
+
74
+ def check_file_request(url, bulk_requires_access_token) # rubocop:disable Metrics/CyclomaticComplexity
75
+ line_count = 0
76
+ resources = Hash.new { |h, k| h[k] = [] }
77
+
78
+ process_line = proc do |line|
79
+ next unless lines_to_validate.blank? ||
80
+ line_count < lines_to_validate.to_i ||
81
+ (@resource_type == 'Patient' && patient_ids_seen.length < MIN_RESOURCE_COUNT)
82
+
83
+ line_count += 1
84
+
85
+ begin
86
+ resource = FHIR.from_contents(line)
87
+ rescue StandardError
88
+ skip "Server response at line \"#{line_count}\" is not a processable FHIR resource."
89
+ end
90
+
91
+ assert !resource.nil?,
92
+ "Resource at line \"#{line_count}\" could not be converted to a #{@resource_type} FHIR resource"
93
+
94
+ if resource.resourceType != @resource_type
95
+ assert false, "Resource type \"#{resource.resourceType}\" at line \"#{line_count}\" does not match type " \
96
+ "defined in output \"#{@resource_type}\""
97
+ end
98
+
99
+ scratch[:patient_ids_seen] = patient_ids_seen | [resource.id] if @resource_type == 'Patient'
100
+
101
+ unless resource_is_valid?(resource:)
102
+ if first_error.key?(:line_number)
103
+ @invalid_resource_count_all += 1
104
+ @invalid_resource_count += 1
105
+ else
106
+ @invalid_resource_count_all.zero? ? @invalid_resource_count_all = 1 : @invalid_resource_count_all += 1
107
+
108
+ @invalid_resource_count = 1
109
+ first_error[:line_number] = line_count
110
+ first_error[:messages] = messages.dup
111
+ end
112
+ end
113
+ end
114
+
115
+ process_headers = proc { |response|
116
+ value = (response[:headers].find { |header| header.name.downcase == 'content-type' })&.value
117
+ unless value&.start_with?('application/fhir+ndjson')
118
+ skip "Content type must have 'application/fhir+ndjson' but found '#{value}'"
119
+ end
120
+ }
121
+
122
+ stream_ndjson(url, build_headers(bulk_requires_access_token), process_line, process_headers)
123
+ resources_from_all_files.merge!(resources) do |_key, all_resources, file_resources|
124
+ all_resources | file_resources
125
+ end
126
+ line_count
127
+ end
128
+
129
+ def process_validation_errors(resource_count)
130
+ return if @invalid_resource_count.nil? || @invalid_resource_count.zero?
131
+
132
+ first_error_message = "The line number for the first failed #{@resource_type} resource is #{first_error[:line_number]}."
133
+
134
+ messages.clear
135
+ messages.concat(first_error[:messages])
136
+
137
+ error_message = "#{@invalid_resource_count} / #{resource_count} #{@resource_type} resources failed profile validation. " \
138
+ "#{first_error_message}"
139
+
140
+ validation_errors.append(error_message)
141
+ end
142
+
143
+ def perform_bulk_export_validation(bulk_status_output: '', bulk_requires_access_token: '')
144
+ skip_if bulk_status_output.blank?, 'Could not verify this functionality when Bulk Status Output is not provided'
145
+ skip_if (bulk_requires_access_token == 'true' && bearer_token.blank?),
146
+ 'Could not verify this functionality when Bearer Token is required and not provided'
147
+
148
+ $num_messages = 0
149
+ $capped_message = false
150
+ $num_errors = 0
151
+ $capped_errors = false
152
+
153
+ assert_valid_json(bulk_status_output)
154
+
155
+ full_file_list = JSON.parse(bulk_status_output)
156
+ if full_file_list.empty?
157
+ message = 'No resource file items returned by server.'
158
+ skip message
159
+ end
160
+
161
+ @resources_from_all_files = {}
162
+
163
+ resource_types = full_file_list.map { |file| file['type'] }.uniq
164
+ all_resource_count = 0
165
+ @invalid_resource_count_all = 0
166
+ @validation_errors = []
167
+
168
+ resource_types.each do |type|
169
+ @resource_type = type
170
+ @first_error = {}
171
+ @invalid_resource_count = 0
172
+ resource_count = 0
173
+
174
+ file_list = full_file_list.select { |file| file['type'] == @resource_type }
175
+
176
+ file_list.each do |file|
177
+ count = check_file_request(file['url'], bulk_requires_access_token)
178
+ all_resource_count += count
179
+ resource_count += count
180
+ end
181
+
182
+ process_validation_errors(resource_count)
183
+ end
184
+
185
+ assert @invalid_resource_count_all.zero?,
186
+ "#{@invalid_resource_count_all} / #{all_resource_count} Resources failed validation. \n" + @validation_errors.join("\n")
187
+
188
+ pass "Successfully validated #{all_resource_count} Resources"
189
+ end
190
+
191
+ def ndjson_download_requiresAccessToken_check(bulk_data_download_url: '', bulk_requires_access_token: '')
192
+ skip_if bulk_data_download_url.blank?, 'Could not verify this functionality when no download link was provided'
193
+ skip_if bulk_requires_access_token.blank?,
194
+ 'Could not verify this functionality when requiresAccessToken is not provided'
195
+ omit_if bulk_requires_access_token == 'false',
196
+ 'Could not verify this functionality when requiresAccessToken is false'
197
+ skip_if bearer_token.blank?, 'Could not verify this functionality when Bearer Token is not provided'
198
+
199
+ get(bulk_data_download_url, headers: { accept: 'application/fhir+ndjson' })
200
+ assert_response_status([400, 401])
201
+ end
202
+
203
+ def export_multiple_patients_check
204
+ skip 'No Patient resources processed from bulk data export.' unless patient_ids_seen.present?
205
+
206
+ begin
207
+ assert patient_ids_seen.length >= BulkExportValidationTester::MIN_RESOURCE_COUNT,
208
+ 'Bulk data export did not have multiple Patient resources.'
209
+ ensure
210
+ scratch[:patient_ids_seen] = []
211
+ end
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'export_kick_off_performer'
4
+ require_relative 'bulk_data_test_kit_properties'
5
+
6
+ module BulkDataTestKit
7
+ module BulkDataExportCancelTests
8
+ extend Forwardable
9
+
10
+ def_delegators 'self.class', :properties
11
+ def_delegators 'properties',
12
+ :resource_type,
13
+ :bulk_export_url
14
+
15
+ def perform_export_cancel_test
16
+ use_token = !bearer_token.blank?
17
+ url = bulk_export_url.dup
18
+ url = bulk_export_url.gsub('[group_id]', group_id) if resource_type == 'Group'
19
+
20
+ perform_export_kick_off_request(use_token:, url:)
21
+ assert_response_status(202)
22
+ begin
23
+ request.response_header('content-location')&.value
24
+ ensure
25
+ delete_export_kick_off_request
26
+ end
27
+ end
28
+
29
+ def perform_cancelled_polling_test(bulk_cancelled_polling_url)
30
+ skip 'No polling url available' unless bulk_cancelled_polling_url.present?
31
+
32
+ get(bulk_cancelled_polling_url, headers: { authorization: "Bearer #{bearer_token}", accept: 'application/json' })
33
+
34
+ assert_response_status(404)
35
+
36
+ assert_valid_json(response[:body])
37
+ response_body = JSON.parse(response[:body])
38
+
39
+ assert response_body['resourceType'] == 'OperationOutcome', 'Server did not return an OperationOutcome'
40
+ assert_valid_resource(resource: FHIR::OperationOutcome.new(response_body))
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BulkDataTestKit
4
+ module ExportKickOffPerformer
5
+ def perform_export_kick_off_request(use_token: true, params: {}, url: '')
6
+ skip_if use_token && bearer_token.blank?, 'Could not verify this functionality when bearer token is not set'
7
+
8
+ headers = { accept: 'application/fhir+json', prefer: 'respond-async' }
9
+ headers.merge!({ authorization: "Bearer #{bearer_token}" }) if use_token
10
+
11
+ param_str = params.map { |k, v| URI.encode_www_form(k => v) }.join('&')
12
+ url.concat("?#{param_str}") unless param_str.empty?
13
+ get(url, client: :bulk_server, name: :export, headers:)
14
+ end
15
+
16
+ def delete_export_kick_off_request
17
+ polling_url = request&.response_header('content-location')&.value
18
+ assert polling_url.present?, 'Export response header did not include "Content-Location"'
19
+
20
+ headers = { accept: 'application/json', authorization: "Bearer #{bearer_token}" }
21
+
22
+ delete(polling_url, headers:)
23
+ assert_response_status(202)
24
+ end
25
+ end
26
+ end