Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Never match existing asset-* entities when patch-existing=false (#1395)
<!-- Specify linked issues and REMOVE THE UNUSED LINES --> This is the first of two fixes to this area of code. There are two modes for `POST /bundle/import`: `patch-existing={true,false}`. If true, then existing entities are supposed to be detected and patched. There is a bug where `asset_mappings` and `asset_properties` are erroneously mapped onto existing assets and essentially get merged when they should be created fresh. This PR fixes this behavior for `patch-existing=false`, since no-one is using `patch-existing=true` yet and everyone is using `patch-existing=false`. The merging code was made on the faulty assumption that there can only be one asset_mapping / asset_properties per asset. There is a red test that is fixed by commit [Revert "Revert "green""](79f4978). The previous commit fails with the wrong number of results: ``` FAIL in ctia.bundle.routes-test/ (bundle-asset-relationships-test) (routes_test.clj:1504) es-store relationships are created for asset mappings/properties ... expected: (= 4 (count (filter (comp #{"created"} :result) create-results2))) actual: (not (= 4 2)) FAIL in ctia.bundle.routes-test/ (bundle-asset-relationships-test) (routes_test.clj:1506) es-store relationships are created for asset mappings/properties ... expected: (= 1 (count (filter (comp #{"exists"} :result) create-results2))) actual: (not (= 1 3)) ``` <!-- Describe your PR for reviewers. Don't forget to set correct labels (User Facing / Beta / Feature Flag) If there is UI change please add a screen capture. --> <!-- UNCOMMENT THIS SECTION IF NEEDED <a name="iroh-services-clients">[§](#iroh-services-clients)</a> IROH Services Clients ===================================================================================== Put all informations that need to be communicated to IROH Services Clients. Typically IROH-UI, ATS Integration, Orbital, etc... --> <a name="qa">[§](#qa)</a> QA ============================ <!-- Describe the steps to test your PR. 1. 2. 3. Or if no QA is needed keep it as is. --> No QA is needed. <!-- UNCOMMENT THIS SECTION IF NEEDED <a name="ops">[§](#ops)</a> Ops =============================== Specify Ops related issues and documentation - Config change needed: threatgrid/tenzin# - Migration needed: threatgrid/tenzin# - How to enable/disable that feature: (ex remove service from `bootstrap.cfg`, add scope to org) --> <!-- UNCOMMENT THIS SECTION IF NEEDED <a name="documentation">[§](#documentation)</a> Documentation ============================================================= Public Facing documentation section; - Public documentation updated needed: threatgrid/iroh-ui# See internal [doc file](./services/iroh-auth/doc/public-doc.org) --> <a name="release-notes">[§](#release-notes)</a> Release Notes ============================================================= <!-- REMOVE UNUSED LINES --> ``` intern: Never match existing asset-* entities when patch-existing=false ``` <a name="squashed-commits">[§](#squashed-commits)</a> Squashed Commits ======================================================================
- Loading branch information