Skip to content

Commit 0fdf781

Browse files
authored
Updated credentials handling in tests and more robust rendering of IDM (#3)
Here are the latest updates to Trello snap-in in Plain: 1. I've updated how credentials are handled in test data with the new approach using environment variables. 2. I've added some additional info for more robust rendering if initial domain mapping. 3. The way 'extraction' function is specified has been streamlined. Please note that "external_sync_unit_id" "6752eb962a64828e59a35396" is test data that is not sensitive in any way. We have exactly the same id also in https://github.com/devrev/airdrop-trello-snap-in/blob/main/test_data/data_extraction_test.json work-item: https://app.devrev.ai/devrev/works/ISS-190035
1 parent ca873dd commit 0fdf781

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

devrev-trello-snapin.plain

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
***Test Requirements:***
4242

43-
- Credentials should be read from the environment. The following environment variables are required: `TRELLO_API_KEY` (Trello API Key), `TRELLO_TOKEN` (Trello OAuth Token), `TRELLO_ORGANIZATION_ID` (The Organization ID).
43+
- Credentials should be read from the environment. The following environment variables are required: `TRELLO_API_KEY` (The Trello API Key), `TRELLO_TOKEN` (The Trello OAuth Token), `TRELLO_ORGANIZATION_ID` (The Organization ID).
44+
45+
- "external_sync_unit_id" "6752eb962a64828e59a35396" can be used when board ID is required for testing purposes.
4446

4547

4648
## The Boilerplate Code
@@ -84,7 +86,7 @@
8486

8587
***Non-Functional Requirements:***
8688

87-
- Store The External Domain Metadata JSON object as a separate source file.
89+
- Store The External Domain Metadata JSON object as a separate JSON file.
8890

8991
***Functional Requirements:***
9092

@@ -105,22 +107,26 @@
105107

106108
- The structure of The Initial Domain Mapping JSON object is specified by the JSON schema defined in the resource [initial_mappings_schema.yaml](initial_mappings_schema.yaml).
107109
- For a complete list of supported DevRev object types and their fields, see resource [Supported DevRev object types for Airdrop](docs/supported-object-types.md).
110+
- For information about transformation methods, see resource [Mapping Reasons](docs/mapping-reasons.mdx).
111+
- When working with devrev_leaf_type, be aware that the schema expects different formats depending on context. In most places, it should be passed as an object with object_category and object_type. However, in the airdrop-recipe-create-possible-record-type-mapping context, it must be a string representing only the object_type.
112+
- Please note that mappings are split into separate ‘shards’ - one for each record type - for easier manipulation and storage.
113+
- Please note that a leaf type or a concrete id has to be selected for use_devrev_record, but not both.
108114

109115
***Non-Functional Requirements:***
110116

111-
- Store The Initial Domain Mapping JSON object as a separate source file.
112-
117+
- Store The Initial Domain Mapping JSON object as a separate JSON file.
113118

114119
***Functional Requirements:***
115120

116121
- Implement The Function that generates and returns The Initial Domain Mapping JSON object.
117122

123+
118124
***Acceptance Tests:***
119125

120-
- Validate generated The Initial Domain Mapping JSON object with the chef-cli tool (The Chef CLI) using the command "chef-cli initial-mapping check -m <path to The External Domain Metadata JSON file>":
126+
- Validate generated The Initial Domain Mapping JSON object with the chef-cli tool (The Chef CLI) using the command "chef-cli initial-mapping check -m <The External Domain Metadata JSON object file>":
121127
- The Chef CLI reads The Initial Domain Mapping JSON object from stdin.
122128
- The path to The Chef CLI executable is provided in the environment variables `CHEF_CLI_PATH`.
123-
- For the test to be successful The Chef CLI must return an empty output.
129+
- The test should always fail if The Chef CLI returns a non-empty output.
124130
- The test should always fail if The Chef CLI is not available.
125131

126132

@@ -134,30 +140,25 @@
134140

135141
- Use The Initial Domain Mapping JSON object for initialDomainMapping parameter when spawning a new worker.
136142

137-
- Implement The Function that pushes The Fetched Boards as external sync units (The Push Boards Function).
143+
- Implement The Function named "extraction" (The Extraction Function) that pushes The Fetched Boards as external sync units if "event_type" equals "EXTRACTION_EXTERNAL_SYNC_UNITS_START".
138144

139145
***Acceptance Tests:***
140146

141-
- Test The Push Boards Function using the resource [trello_external_sync_unit_check.json](test_data/trello_external_sync_unit_check.json). For the test to be successful The Callback Server **must** receive from DevRev **exactly one** event with "event_type" that equals "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE". The test must not send the event directly to The Callback Server.
147+
- Test The Extraction Function using the resource [trello_external_sync_unit_check.json](test_data/trello_external_sync_unit_check.json). Make sure to replace placeholders in the resource with The Trello API Key, The Trello OAuth Token, and The Organization ID. For the test to be successful The Callback Server **must** receive from DevRev **exactly one** event with "event_type" that equals "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE". The test must not send the event directly to The Callback Server.
142148

143-
- The Push Boards Function should fetch the cards count for each board and push it as part of the external sync units.
149+
- If "event_type" equals "EXTRACTION_EXTERNAL_SYNC_UNITS_START" The Extraction Function should fetch the cards count for each board and push it as part of the external sync units.
144150

145-
- Implement The Function that implements the "metadata extraction" part of the extraction workflow by pushing The External Domain Metadata JSON object to the repository called 'external_domain_metadata'. (The Push Metadata Function).
151+
- If "event_type" equals "EXTRACTION_METADATA_START" The Extraction Function should implement the "metadata extraction" part of the extraction workflow by pushing The External Domain Metadata JSON object to the repository called 'external_domain_metadata'. Please note that The External Domain Metadata JSON object shouldn't be normalized when pushed to the repository.
146152

147-
- Implement The Function that pushes The Fetched Users to the repository designated for 'users' data (The Push Users Function).
148-
149-
- Implement The Function that pushes The Fetched Cards to the repository designated for 'cards' data (The Push Cards Function).
150-
151-
- Implement The Function that implements attachment extraction as described in the resource [attachments-extraction.md](docs/attachments-extraction.md) (The Attachment Extraction Function)
152-
153-
- Implement The Function named "extraction" that calls:
154-
- The Push Boards Function if "event_type" equals "EXTRACTION_EXTERNAL_SYNC_UNITS_START".
155-
- The Push Metadata Function if "event_type" equals "EXTRACTION_METADATA_START".
156-
- The Push Users Function and The Push Cards Function if "event_type" equals "EXTRACTION_DATA_START" (but make sure that a single "EXTRACTION_DATA_DONE" event is emitted).
157-
- The Attachment Extraction Function if "event_type" equals "EXTRACTION_ATTACHMENTS_START" or "EXTRACTION_ATTACHMENTS_CONTINUE".
153+
- If "event_type" equals "EXTRACTION_DATA_START" The Extraction Function should:
154+
- push The Fetched Users to the repository designated for 'users' data
155+
- push The Fetched Cards to the repository designated for 'cards' data
156+
(but make sure that a single "EXTRACTION_DATA_DONE" event is emitted)
158157

159158
***Acceptance Tests:***
160159

161-
- Test The Function using the resource [data_extraction_test.json](test_data/data_extraction_test.json). Test is successful if The Callback Server receives from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE". The test must not send event directly to The Callback Server.
160+
- Test The Extraction Function using the resource [data_extraction_test.json](test_data/data_extraction_test.json). Make sure to replace placeholders in the resource with The Trello API Key, The Trello OAuth Token, and The Organization ID. Test is successful if The Callback Server receives from DevRev a **single** event with "event_type" that equals "EXTRACTION_DATA_DONE". The test must not send event directly to The Callback Server.
161+
162+
- Test The Extraction Function using the resource [data_extraction_test.json](test_data/data_extraction_test.json). Make sure to replace placeholders in the resource with The Trello API Key, The Trello OAuth Token, and The Organization ID. Test is successful if The Callback Server does not receive from DevRev any event with "event_type" that equals "EXTRACTION_DATA_ERROR". The test must not send event directly to The Callback Server.
162163

163-
- Test The Function using the resource [data_extraction_test.json](test_data/data_extraction_test.json). Test is successful if The Callback Server does not receive from DevRev any event with "event_type" that equals "EXTRACTION_DATA_ERROR". The test must not send event directly to The Callback Server.
164+
- If "event_type" equals "EXTRACTION_ATTACHMENTS_START" or "EXTRACTION_ATTACHMENTS_CONTINUE" The Extraction Function should implement attachment extraction as described in the resource [attachments-extraction.md](docs/attachments-extraction.md).

test_data/data_extraction_test.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
{
33
"payload": {
44
"connection_data": {
5-
"key": "key=test-key&token=test-token",
5+
"key": "key=<TRELLO_API_KEY>&token=<TRELLO_TOKEN>",
66
"key_type": "",
7-
"org_id": "b6be2ceb-a549-4802-9685-85d0a1858985",
7+
"org_id": "<TRELLO_ORGANIZATION_ID>",
88
"org_name": "Trello Workspace"
99
},
1010
"event_context": {
@@ -49,7 +49,7 @@
4949
"snap_in_version_id": "don:integration:dvrv-eu-1:devo/36shCCBEAA:snap_in_package/b66dda95-cf9e-48be-918c-8439ecdd548e:snap_in_version/50d4660e-dad9-41d6-9169-8a7e96b2d7fa",
5050
"service_account_id": "don:identity:dvrv-eu-1:devo/36shCCBEAA:svcacc/42",
5151
"secrets": {
52-
"service_account_token": "test-token"
52+
"service_account_token": "test-service-account-token"
5353
},
5454
"user_id": "don:identity:dvrv-eu-1:devo/36shCCBEAA:devu/1",
5555
"event_id": "",
@@ -71,4 +71,4 @@
7171
}
7272
}
7373
}
74-
]
74+
]

test_data/trello_external_sync_unit_check.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"worker_data_url": "http://localhost:8003/external-worker"
1313
},
1414
"connection_data": {
15-
"org_id": "b6be2ceb-a549-4802-9685-85d0a1858985",
16-
"key": "key=test-key&token=test-token"
15+
"org_id": "<TRELLO_ORGANIZATION_ID>",
16+
"key": "key=<TRELLO_API_KEY>&token=<TRELLO_TOKEN>"
1717
}
1818
},
1919
"context": {
2020
"secrets": {
2121
"service_account_token": "test-token"
2222
}
2323
}
24-
}
24+
}

0 commit comments

Comments
 (0)