|
| 1 | +(ns cmr.system-int-test.search.collection-cloud-hosted-search-test |
| 2 | + "Integration tests for searching for records that are cloud hosted" |
| 3 | + (:require |
| 4 | + [clojure.test :refer :all] |
| 5 | + [cmr.common.util :as util] |
| 6 | + [cmr.mock-echo.client.echo-util :as echo] |
| 7 | + [cmr.indexer.data.concepts.tag :as itag] |
| 8 | + [cmr.system-int-test.data2.core :as data2] |
| 9 | + [cmr.system-int-test.data2.umm-spec-collection :as data-umm-c] |
| 10 | + [cmr.system-int-test.system :as system] |
| 11 | + [cmr.system-int-test.utils.index-util :as index] |
| 12 | + [cmr.system-int-test.utils.ingest-util :as ingest] |
| 13 | + [cmr.system-int-test.utils.search-util :as search] |
| 14 | + [cmr.system-int-test.utils.tag-util :as tags])) |
| 15 | + |
| 16 | +(use-fixtures :each (join-fixtures |
| 17 | + [(ingest/reset-fixture {"provguid1" "PROV1"}) |
| 18 | + tags/grant-all-tag-fixture])) |
| 19 | + |
| 20 | +(defn- create-direct-dist-info |
| 21 | + "Create a Direct Distribution" |
| 22 | + [] |
| 23 | + {:DirectDistributionInformation {:Region "us-east-1" |
| 24 | + :S3CredentialsAPIEndpoint "https://example.org" |
| 25 | + :S3CredentialsAPIDocumentationURL "https://example.org"}}) |
| 26 | + |
| 27 | +(deftest search-collections-that-are-cloud-hosted |
| 28 | + (let [coll1 (data2/ingest-umm-spec-collection "PROV1" (data-umm-c/collection 1 {})) |
| 29 | + coll2 (data2/ingest-umm-spec-collection "PROV1" (data-umm-c/collection 2 {})) |
| 30 | + coll3 (data2/ingest-umm-spec-collection "PROV1" (data-umm-c/collection 3 (create-direct-dist-info)))] |
| 31 | + (index/wait-until-indexed) |
| 32 | + |
| 33 | + (testing "Search by the cloud_hosted flag only" |
| 34 | + (util/are3 |
| 35 | + [expected items] |
| 36 | + (data2/refs-match? items (search/find-refs :collection {:cloud-hosted expected})) |
| 37 | + "Found using metadata" true [coll3] |
| 38 | + "Not found" false [coll1 coll2])) |
| 39 | + |
| 40 | + (testing "Search for collections tagged as cloud hosted" |
| 41 | + (let [user1-token (echo/login (system/context) "user1") |
| 42 | + tag1 (tags/make-tag {:tag-key itag/earthdata-cloud-s3-tag}) |
| 43 | + tag_record (tags/save-tag user1-token tag1 [coll1])] |
| 44 | + (index/wait-until-indexed) |
| 45 | + |
| 46 | + (util/are3 |
| 47 | + [expected items] |
| 48 | + (is (data2/refs-match? items (search/find-refs :collection {:cloud-hosted expected}))) |
| 49 | + "Found using metadata or tags" true [coll1 coll3] |
| 50 | + "Not found" false [coll2]))))) |
0 commit comments