diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-03 14:38:21 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-04 16:13:39 +0100 |
commit | 22fe27f0e1399deaf13b416f2d35a2e12ea0f358 (patch) | |
tree | e9452ebeca61f946f91c9241b2aa58dda0b52c25 | |
parent | c8294257727aec36017e1dea0cbbe34f1aaa625e (diff) | |
download | browser-extension-22fe27f0e1399deaf13b416f2d35a2e12ea0f358.tar.gz browser-extension-22fe27f0e1399deaf13b416f2d35a2e12ea0f358.zip |
include $schema property in internally-generated resources/mappings
-rw-r--r-- | html/payload_create.js | 3 | ||||
-rw-r--r-- | test/haketilo_test/unit/test_payload_create.py | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/html/payload_create.js b/html/payload_create.js index 7782299..ebd9236 100644 --- a/html/payload_create.js +++ b/html/payload_create.js @@ -97,6 +97,7 @@ function collect_form_data(form_ctx) const sha256 = compute_sha256(script); const resource = { + $schema: "https://hydrilla.koszko.org/schemas/api_resource_description-1.0.1.schema.json", source_name: identifier, source_copyright: [], type: "resource", @@ -104,12 +105,14 @@ function collect_form_data(form_ctx) long_name, uuid: uuidv4(), version: [1], + revision: 1, description, dependencies: [], scripts: [{file: "payload.js", sha256}] }; const mapping = { + $schema: "https://hydrilla.koszko.org/schemas/api_mapping_description-1.0.1.schema.json", source_name: identifier, source_copyright: [], type: "mapping", diff --git a/test/haketilo_test/unit/test_payload_create.py b/test/haketilo_test/unit/test_payload_create.py index 9689c37..b6befa3 100644 --- a/test/haketilo_test/unit/test_payload_create.py +++ b/test/haketilo_test/unit/test_payload_create.py @@ -45,6 +45,11 @@ sample_form_data = { 'script': sample_files['hello.js']['contents'] } +resource_schema_id, mapping_schema_id = [ + f'https://hydrilla.koszko.org/schemas/api_{t}_description-1.0.1.schema.json' + for t in ('resource', 'mapping') +] + def fill_form_with_sample_data(execute_in_page, sample_data_override={}, form_ctx='form_ctx'): form_data = sample_form_data.copy() @@ -128,12 +133,14 @@ def test_payload_create_normal_usage(driver, execute_in_page): for pat in form_data['patterns'].split('\n') if pat]) assert db_contents['resource'] == [{ + '$schema': resource_schema_id, 'source_name': localid, 'source_copyright': [], 'type': 'resource', 'identifier': localid, 'uuid': db_contents['resource'][0]['uuid'], 'version': [1], + 'revision': 1, 'description': form_data['description'], 'dependencies': [], 'long_name': long_name, @@ -145,6 +152,7 @@ def test_payload_create_normal_usage(driver, execute_in_page): assert uuidv4_re.match(db_contents['mapping'][0]['uuid']) assert db_contents['mapping'] == [{ + '$schema': mapping_schema_id, 'source_name': localid, 'source_copyright': [], 'type': 'mapping', |