From 8722e02df688323febb4bded2f0924e548a90cd6 Mon Sep 17 00:00:00 2001
From: Georgi Michev <georgi.michev@vereign.com>
Date: Thu, 21 Dec 2023 16:54:59 +0200
Subject: [PATCH] Add Content Access tests

Signed-off-by: Georgi Michev <georgi.michev@vereign.com>
---
 src/main/resources/REST/json/Cache.json       |  12 ++
 .../features/tsa/cache/v1/cache/GET.feature   | 132 ++++++++++++++++++
 2 files changed, 144 insertions(+)

diff --git a/src/main/resources/REST/json/Cache.json b/src/main/resources/REST/json/Cache.json
index 2a9def97..081b4119 100644
--- a/src/main/resources/REST/json/Cache.json
+++ b/src/main/resources/REST/json/Cache.json
@@ -6,5 +6,17 @@
   },
   "default_set": {
     "msg": "default"
+  },
+  "content_access_01": {
+    "key": "value 01",
+    "data": "data value 01"
+  },
+  "content_access_02": {
+    "key": "value 02",
+    "data": "data value 02"
+  },
+  "content_access_03": {
+    "key": "value 03",
+    "data": "data value 03"
   }
 }
\ No newline at end of file
diff --git a/src/test/resources/features/tsa/cache/v1/cache/GET.feature b/src/test/resources/features/tsa/cache/v1/cache/GET.feature
index e25bfd9d..56717145 100644
--- a/src/test/resources/features/tsa/cache/v1/cache/GET.feature
+++ b/src/test/resources/features/tsa/cache/v1/cache/GET.feature
@@ -24,6 +24,138 @@ Feature: API -TSA - Cache - v1/cache GET
     Then the status code should be {200}
     And the field {msg} has the value {successful setting the cache}
 
+  @phase2 @IDM.TSA.E1.00020
+  Scenario: TSA - Get merged Content Access - Positive
+    # Set the first cache record
+    When I load the REST request {Cache.json} with profile {content_access_01}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Set the second cache record
+    And I load the REST request {Cache.json} with profile {content_access_02}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {02} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Set the third cache record
+    And I load the REST request {Cache.json} with profile {content_access_03}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {03} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Get the merged cache result
+    And I load value {merge} into current request HEADER {x-cache-flatten-strategy}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01,02,03} into current request HEADER {x-cache-scope}
+    And I send the Cache GET request via TSA Cache API
+    Then the status code should be {200}
+    And the field {data_1} has the value {data value 01}
+    And the field {data_2} has the value {data value 02}
+    And the field {data_3} has the value {data value 03}
+    And the field {key_1} has the value {value 01}
+    And the field {key_2} has the value {value 02}
+    And the field {key_3} has the value {value 03}
+
+  @phase2 @IDM.TSA.E1.00020
+  Scenario: TSA - Get the first cache from merged - Content Access - Positive
+    # Set the first cache record
+    When I load the REST request {Cache.json} with profile {content_access_01}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Set the second cache record
+    And I load the REST request {Cache.json} with profile {content_access_02}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {02} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Get the merged cache result and show just the first one
+    And I load value {first} into current request HEADER {x-cache-flatten-strategy}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01,02} into current request HEADER {x-cache-scope}
+    And I send the Cache GET request via TSA Cache API
+    Then the status code should be {200}
+    And the field {data} has the value {data value 01}
+    And the field {key} has the value {value 01}
+
+  @phase2 @IDM.TSA.E1.00020
+  Scenario: TSA - Get the last cache from merged - Content Access - Positive
+    # Set the first cache record
+    When I load the REST request {Cache.json} with profile {content_access_01}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Set the second cache record
+    And I load the REST request {Cache.json} with profile {content_access_02}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {02} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Get the merged cache result and show just the last one
+    And I load value {last} into current request HEADER {x-cache-flatten-strategy}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01,02} into current request HEADER {x-cache-scope}
+    And I send the Cache GET request via TSA Cache API
+    Then the status code should be {200}
+    And the field {data} has the value {data value 02}
+    And the field {key} has the value {value 02}
+
+  @phase2 @IDM.TSA.E1.00020
+  Scenario: TSA - Get existing and non existing cache - Content Access - Positive
+    # Set the cache record
+    When I load the REST request {Cache.json} with profile {content_access_01}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01} into current request HEADER {x-cache-scope}
+    And I load value {10} into current request HEADER {x-cache-ttl}
+    And I send the Cache POST request via TSA Cache API
+    And the status code should be {201}
+    Then I clear the request body
+    And I clear ALL headers
+    # Get the merged cache result
+    When I load value {merge} into current request HEADER {x-cache-flatten-strategy}
+    And I load value {did:web:example.com} into current request HEADER {x-cache-key}
+    And I load value {Login} into current request HEADER {x-cache-namespace}
+    And I load value {01, nonExisting} into current request HEADER {x-cache-scope}
+    And I send the Cache GET request via TSA Cache API
+    Then the status code should be {200}
+    And the field {data} has the value {data value 01}
+    And the field {key} has the value {value 01}
+
   @negative
   Scenario: TSA - Setting 10 seconds time to live and verifying it expires - Negative
     When I load the REST request {Cache.json} with profile {successful_set}
-- 
GitLab