mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(servicecatalog): expose stored record history (#7022)
* fix(servicecatalog): expose stored record history * fix(servicecatalog): align termination record timestamp
This commit is contained in:
1 parent
1cafa71e3d
commit
886cbcd201
5 files changed
+198
-51
No files matched your search
@@ -72,7 +72,7 @@ The existing seeded Control Tower portfolio participates in pagination.
|
||||
| `DescribeProvisionedProduct` | Return a provisioned product's details. |
|
||||
| `DescribeProvisionedProductPlan` | Return a provisioned product plan's identity fields; no `Status` or `ResourceChanges` is reported. |
|
||||
| `DescribeProvisioningParameters` | Return the provisioning parameters recorded on the product at creation; the response is empty if none were supplied. |
|
||||
| `DescribeRecord` | Look up a record by id; `ProvisionProduct` and `ExecuteProvisionedProductPlan` return a `RecordId` they never persist, so those are not found. |
|
||||
| `DescribeRecord` | Look up a persisted record by id, including `ProvisionProduct` records; `ExecuteProvisionedProductPlan` returns an ID that is not persisted. |
|
||||
| `DescribeServiceActionExecutionParameters` | Return a service action's execution parameters; always an empty list. |
|
||||
| `DisableAWSOrganizationsAccess` | Accept the disable request without persisting any state. |
|
||||
| `DisassociateBudgetFromResource` | Remove a budget-name association from a resource. |
|
||||
@@ -93,7 +93,7 @@ The existing seeded Control Tower portfolio participates in pagination.
|
||||
| `ListPrincipalsForPortfolio` | List the principals associated with a portfolio. |
|
||||
| `ListProvisionedProductPlans` | List provisioned product plans with offset-based pagination; `PageSize` is capped at 20. |
|
||||
| `ListProvisioningArtifactsForServiceAction` | List provisioning artifacts for a service action; always an empty list. |
|
||||
| `ListRecordHistory` | Synthesise one `SUCCEEDED` record per stored provisioned product; the entries carry no `RecordId` and the real record store is not consulted. |
|
||||
| `ListRecordHistory` | List stored records, newest first, with their `RecordId`; older products without a stored creation record retain a synthetic history entry. Request filters and pagination are ignored. |
|
||||
| `ListResourcesForTagOption` | List the resources a TagOption is attached to. |
|
||||
| `ListServiceActions` | List every service action in the account, without context scoping. |
|
||||
| `ListServiceActionsForProvisioningArtifact` | List service actions for a provisioning artifact; always an empty list. |
|
||||
@@ -201,16 +201,14 @@ When the resolved product is the Account Factory product, `ProvisionProduct` cre
|
||||
find anything from an executed plan.
|
||||
- **`GetProvisionedProductOutputs` always returns an empty `Outputs` list.** No CloudFormation
|
||||
stack outputs are modelled or persisted for any provisioned product.
|
||||
- **Two operations return a `RecordId` they never persist.** `ImportAsProvisionedProduct`,
|
||||
`ExecuteProvisionedProductServiceAction`, `UpdateProvisionedProduct`,
|
||||
- **`ExecuteProvisionedProductPlan` returns a `RecordId` it never persists.** `ProvisionProduct`,
|
||||
`ImportAsProvisionedProduct`, `ExecuteProvisionedProductServiceAction`, `UpdateProvisionedProduct`,
|
||||
`UpdateProvisionedProductProperties` and `TerminateProvisionedProduct` all store a record
|
||||
that `DescribeRecord` can later find. `ProvisionProduct` and `ExecuteProvisionedProductPlan`
|
||||
mint a `RecordId` for their response only, so looking either one up afterwards raises
|
||||
`ResourceNotFoundException`.
|
||||
- **`ListRecordHistory` does not read the record store.** It synthesises one `SUCCEEDED`
|
||||
entry per stored provisioned product, so the entries carry no `RecordId` and cannot be fed
|
||||
back into `DescribeRecord`, and records from operations that persisted one never appear.
|
||||
Request filters and pagination are ignored.
|
||||
that `DescribeRecord` can later find. `ExecuteProvisionedProductPlan` mints an ID for its
|
||||
response only, so looking it up afterwards raises `ResourceNotFoundException`.
|
||||
- **`ListRecordHistory` ignores request filters and pagination.** It returns stored records in
|
||||
reverse chronological order. Products persisted before records were stored still appear as
|
||||
synthetic entries without a `RecordId`; those entries cannot be used with `DescribeRecord`.
|
||||
- **`ListServiceActionsForProvisioningArtifact` always returns an empty list.** It validates
|
||||
that the product and provisioning artifact exist and then returns no summaries, even when
|
||||
associations for that artifact were stored (the inverse case,
|
||||
|
||||
+22
-12
@@ -14,7 +14,6 @@ import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ApplicationScoped
|
||||
public class ServiceCatalogJsonHandler {
|
||||
@@ -207,10 +206,10 @@ public class ServiceCatalogJsonHandler {
|
||||
private Response provisionProduct(JsonNode request, String region, String accountId) {
|
||||
ObjectNode detail = service.provisionProduct(request, region, accountId);
|
||||
ObjectNode record = objectMapper.createObjectNode();
|
||||
record.put("RecordId", "rec-" + UUID.randomUUID().toString().replace("-", "").substring(0, 16));
|
||||
record.put("RecordId", detail.path("RecordId").asText());
|
||||
record.put("ProvisionedProductId", detail.path("Id").asText());
|
||||
record.put("Status", "SUCCEEDED");
|
||||
record.put("CreatedTime", System.currentTimeMillis() / 1000.0);
|
||||
record.put("CreatedTime", detail.path("CreatedTime").asDouble());
|
||||
return Response.ok(objectMapper.createObjectNode().set("RecordDetail", record)).build();
|
||||
}
|
||||
|
||||
@@ -695,15 +694,26 @@ public class ServiceCatalogJsonHandler {
|
||||
private Response listRecordHistory() {
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode details = response.putArray("RecordDetails");
|
||||
service.listRecordHistory().forEach(product -> {
|
||||
service.listRecordHistory().forEach(source -> {
|
||||
ObjectNode record = objectMapper.createObjectNode();
|
||||
record.put("ProvisionedProductId", product.path("Id").asText());
|
||||
record.put("ProvisionedProductName", product.path("Name").asText());
|
||||
record.put("ProvisionedProductType", product.path("Type").asText());
|
||||
record.put("ProductId", product.path("ProductId").asText());
|
||||
record.put("ProvisioningArtifactId", product.path("ProvisioningArtifactId").asText());
|
||||
record.put("CreatedTime", product.path("CreatedTime").asDouble());
|
||||
record.put("Status", "SUCCEEDED");
|
||||
boolean storedRecord = source.hasNonNull("RecordId");
|
||||
record.put("ProvisionedProductId", source.path(storedRecord ? "ProvisionedProductId" : "Id").asText());
|
||||
record.put("ProvisionedProductName", source.path(storedRecord ? "ProvisionedProductName" : "Name").asText());
|
||||
String productType = source.path(storedRecord ? "ProvisionedProductType" : "Type").asText(null);
|
||||
if (productType != null) {
|
||||
record.put("ProvisionedProductType", productType);
|
||||
}
|
||||
record.put("ProductId", source.path("ProductId").asText());
|
||||
record.put("ProvisioningArtifactId", source.path("ProvisioningArtifactId").asText());
|
||||
record.put("CreatedTime", source.path("CreatedTime").asDouble());
|
||||
record.put("Status", storedRecord ? source.path("Status").asText() : "SUCCEEDED");
|
||||
if (storedRecord) {
|
||||
record.put("RecordId", source.path("RecordId").asText());
|
||||
record.put("RecordType", source.path("RecordType").asText());
|
||||
if (source.hasNonNull("UpdatedTime")) {
|
||||
record.put("UpdatedTime", source.path("UpdatedTime").asDouble());
|
||||
}
|
||||
}
|
||||
details.add(record);
|
||||
});
|
||||
return Response.ok(response).build();
|
||||
@@ -886,7 +896,7 @@ public class ServiceCatalogJsonHandler {
|
||||
record.put("ProductId", product.path("ProductId").asText());
|
||||
record.put("ProvisioningArtifactId", product.path("ProvisioningArtifactId").asText());
|
||||
record.put("Status", "SUCCEEDED");
|
||||
record.put("CreatedTime", product.path("CreatedTime").asDouble(0.0));
|
||||
record.put("CreatedTime", product.path("UpdatedTime").asDouble(0.0));
|
||||
record.put("UpdatedTime", product.path("UpdatedTime").asDouble(0.0));
|
||||
record.put("RecordType", "TERMINATE_PROVISIONED_PRODUCT");
|
||||
return Response.ok(objectMapper.createObjectNode().set("RecordDetail", record)).build();
|
||||
|
||||
+59
-4
@@ -18,10 +18,13 @@ import jakarta.inject.Inject;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.StreamSupport;
|
||||
@@ -211,7 +214,7 @@ public class ServiceCatalogService implements PassedRoleLookup {
|
||||
.filter(candidate -> name.equals(text(candidate, "Name")))
|
||||
.findFirst().orElse(null);
|
||||
if (existing != null) {
|
||||
return existing.deepCopy();
|
||||
return provisionedProductWithRecord(existing);
|
||||
}
|
||||
String provisionedId = id("pp");
|
||||
ObjectNode provisioned = objectMapper.createObjectNode();
|
||||
@@ -230,7 +233,34 @@ public class ServiceCatalogService implements PassedRoleLookup {
|
||||
provisioned.put("ProvisioningArtifactId", artifactId);
|
||||
provisioned.put("CreatedTime", Instant.now().toEpochMilli() / 1000.0);
|
||||
provisionedProductStore.put(provisionedId, provisioned);
|
||||
return provisioned.deepCopy();
|
||||
return provisionedProductWithRecord(provisioned);
|
||||
}
|
||||
|
||||
private synchronized ObjectNode provisionedProductWithRecord(ObjectNode product) {
|
||||
String provisionedId = text(product, "Id");
|
||||
String recordType = "IMPORTED".equals(text(product, "Type")) ? "IMPORT" : "PROVISION_PRODUCT";
|
||||
ObjectNode record = associationStore.scan(key -> true).stream()
|
||||
.filter(candidate -> "RECORD".equals(text(candidate, "Type"))
|
||||
&& recordType.equals(text(candidate, "RecordType"))
|
||||
&& provisionedId.equals(text(candidate, "ProvisionedProductId")))
|
||||
.findFirst().orElse(null);
|
||||
if (record == null) {
|
||||
String recordId = id("rec");
|
||||
record = objectMapper.createObjectNode();
|
||||
record.put("Type", "RECORD");
|
||||
record.put("RecordId", recordId);
|
||||
record.put("ProvisionedProductId", provisionedId);
|
||||
record.put("ProvisionedProductName", text(product, "Name"));
|
||||
record.put("ProductId", text(product, "ProductId"));
|
||||
record.put("ProvisioningArtifactId", text(product, "ProvisioningArtifactId"));
|
||||
record.put("RecordType", recordType);
|
||||
record.put("Status", "SUCCEEDED");
|
||||
record.put("CreatedTime", product.path("CreatedTime").asDouble());
|
||||
associationStore.put(recordId, record);
|
||||
}
|
||||
ObjectNode result = product.deepCopy();
|
||||
result.put("RecordId", text(record, "RecordId"));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1269,7 +1299,32 @@ public class ServiceCatalogService implements PassedRoleLookup {
|
||||
}
|
||||
|
||||
public List<ObjectNode> listRecordHistory() {
|
||||
return provisionedProductStore.scan(key -> true).stream().map(ObjectNode::deepCopy).toList();
|
||||
List<ObjectNode> history = new ArrayList<>();
|
||||
Set<String> productsWithCreationRecord = new HashSet<>();
|
||||
for (ObjectNode stored : associationStore.scan(key -> true)) {
|
||||
if (!"RECORD".equals(text(stored, "Type"))) {
|
||||
continue;
|
||||
}
|
||||
ObjectNode record = stored.deepCopy();
|
||||
String provisionedId = text(record, "ProvisionedProductId");
|
||||
if ("IMPORT".equals(text(record, "RecordType"))
|
||||
|| "PROVISION_PRODUCT".equals(text(record, "RecordType"))) {
|
||||
productsWithCreationRecord.add(provisionedId);
|
||||
}
|
||||
provisionedProductStore.get(provisionedId).ifPresent(product ->
|
||||
record.put("ProvisionedProductType", text(product, "Type")));
|
||||
history.add(record);
|
||||
}
|
||||
provisionedProductStore.scan(key -> true).stream()
|
||||
.filter(product -> !productsWithCreationRecord.contains(text(product, "Id")))
|
||||
.map(ObjectNode::deepCopy)
|
||||
.forEach(history::add);
|
||||
history.sort(Comparator
|
||||
.comparingDouble((ObjectNode entry) -> Math.max(entry.path("CreatedTime").asDouble(),
|
||||
entry.path("UpdatedTime").asDouble()))
|
||||
.reversed()
|
||||
.thenComparing(entry -> entry.path("RecordId").asText(entry.path("Id").asText())));
|
||||
return history;
|
||||
}
|
||||
|
||||
public List<ObjectNode> listResourcesForTagOption(String tagOptionId, String resourceType) {
|
||||
@@ -1548,7 +1603,7 @@ public class ServiceCatalogService implements PassedRoleLookup {
|
||||
record.put("ProvisioningArtifactId", text(product, "ProvisioningArtifactId"));
|
||||
record.put("RecordType", "TERMINATE_PROVISIONED_PRODUCT");
|
||||
record.put("Status", "SUCCEEDED");
|
||||
record.put("CreatedTime", product.get("CreatedTime").asDouble());
|
||||
record.put("CreatedTime", product.get("UpdatedTime").asDouble());
|
||||
record.put("UpdatedTime", product.get("UpdatedTime").asDouble());
|
||||
associationStore.put(recordId, record);
|
||||
|
||||
|
||||
+27
-7
@@ -1,13 +1,17 @@
|
||||
package io.github.hectorvent.floci.services.servicecatalog;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Wire-level tests for {@code DescribeProvisionedProduct},
|
||||
@@ -32,6 +36,9 @@ class ServiceCatalogProvisionedProductLifecycleConsumerTest {
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/servicecatalog/aws4_request";
|
||||
|
||||
@Inject
|
||||
ObjectMapper objectMapper;
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
@@ -155,29 +162,42 @@ class ServiceCatalogProvisionedProductLifecycleConsumerTest {
|
||||
// ---------- TerminateProvisionedProduct ----------
|
||||
|
||||
@Test
|
||||
void terminateProvisionedProduct_marksTerminatedAndReturnsDescribableRecord() {
|
||||
void terminateProvisionedProduct_marksTerminatedAndReturnsDescribableRecord() throws Exception {
|
||||
String productId = createProduct("ab-terminate-pp-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
String provisionedId = importProvisionedProduct(productId, artifactId, "ab-terminate-pp");
|
||||
Response originalProduct = call("DescribeProvisionedProduct", "{\"Id\":\"" + provisionedId + "\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
double originalCreatedTime = objectMapper.readTree(originalProduct.asString())
|
||||
.path("ProvisionedProductDetail").path("CreatedTime").asDouble();
|
||||
|
||||
String recordId = call("TerminateProvisionedProduct", "{\"ProvisionedProductId\":\""
|
||||
Thread.sleep(25);
|
||||
Response terminated = call("TerminateProvisionedProduct", "{\"ProvisionedProductId\":\""
|
||||
+ provisionedId + "\",\"TerminateToken\":\"tok-terminate-pp\"}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("RecordDetail.ProvisionedProductId", equalTo(provisionedId))
|
||||
.body("RecordDetail.Status", equalTo("SUCCEEDED"))
|
||||
.body("RecordDetail.RecordType", equalTo("TERMINATE_PROVISIONED_PRODUCT"))
|
||||
.extract().path("RecordDetail.RecordId");
|
||||
.extract().response();
|
||||
JsonNode terminationRecord = objectMapper.readTree(terminated.asString()).path("RecordDetail");
|
||||
String recordId = terminationRecord.path("RecordId").asText();
|
||||
|
||||
call("DescribeProvisionedProduct", "{\"Id\":\"" + provisionedId + "\"}")
|
||||
Response terminatedProduct = call("DescribeProvisionedProduct", "{\"Id\":\"" + provisionedId + "\"}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ProvisionedProductDetail.Status", equalTo("TERMINATED"));
|
||||
.body("ProvisionedProductDetail.Status", equalTo("TERMINATED"))
|
||||
.extract().response();
|
||||
assertEquals(originalCreatedTime, objectMapper.readTree(terminatedProduct.asString())
|
||||
.path("ProvisionedProductDetail").path("CreatedTime").asDouble());
|
||||
|
||||
call("DescribeRecord", "{\"Id\":\"" + recordId + "\"}")
|
||||
Response described = call("DescribeRecord", "{\"Id\":\"" + recordId + "\"}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("RecordDetail.RecordType", equalTo("TERMINATE_PROVISIONED_PRODUCT"));
|
||||
.body("RecordDetail.RecordType", equalTo("TERMINATE_PROVISIONED_PRODUCT"))
|
||||
.extract().response();
|
||||
JsonNode describedRecord = objectMapper.readTree(described.asString()).path("RecordDetail");
|
||||
assertEquals(describedRecord.path("CreatedTime").asDouble(), terminationRecord.path("CreatedTime").asDouble());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+81
-17
@@ -1,33 +1,33 @@
|
||||
package io.github.hectorvent.floci.services.servicecatalog;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import jakarta.inject.Inject;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Wire-level tests for {@code DescribeRecord}, {@code ListRecordHistory},
|
||||
* {@code ListResourcesForTagOption}, {@code ListStackInstancesForProvisionedProduct}
|
||||
* and {@code ListServiceActionsForProvisioningArtifact}.
|
||||
*
|
||||
* <p>New class, not appended to an existing one, so falsifiability isolates per
|
||||
* operation (CS-001). {@code describeRecord} looked up records via a
|
||||
* {@code Type: "RECORD"} association row that nothing ever wrote — every
|
||||
* record-producing operation generated a throwaway random {@code RecordId} in the
|
||||
* handler layer and discarded it, so {@code DescribeRecord} 404'd unconditionally.
|
||||
* Fixed for {@code ImportAsProvisionedProduct}'s path (the one this session already
|
||||
* covers): the service now persists a {@code RECORD} row and returns its id, and the
|
||||
* handler uses that id instead of generating its own. Other record-producing
|
||||
* operations (e.g. {@code ExecuteProvisionedProductServiceAction},
|
||||
* {@code TerminateProvisionedProduct}) still generate unpersisted record ids and
|
||||
* remain undescribable — documented as a limitation, not fixed here (out of this
|
||||
* op-family's scope; same fix pattern applies when those ops are tested).
|
||||
* <p>Record tests use the AWS JSON wire path so the returned IDs can be checked
|
||||
* against both history and {@code DescribeRecord}.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class ServiceCatalogRecordAndResourceQueryConsumerTest {
|
||||
@@ -36,6 +36,9 @@ class ServiceCatalogRecordAndResourceQueryConsumerTest {
|
||||
private static final String AUTH_HEADER =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/servicecatalog/aws4_request";
|
||||
|
||||
@Inject
|
||||
StorageFactory storageFactory;
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
@@ -97,20 +100,81 @@ class ServiceCatalogRecordAndResourceQueryConsumerTest {
|
||||
// ---------- ListRecordHistory ----------
|
||||
|
||||
@Test
|
||||
void listRecordHistory_includesImportedProduct() {
|
||||
void listRecordHistory_includesEachRecordForProvisionedProduct() {
|
||||
String productId = createProduct("ab-record-history-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
String provisionedId = call("ImportAsProvisionedProduct", "{\"ProductId\":\"" + productId
|
||||
Response imported = call("ImportAsProvisionedProduct", "{\"ProductId\":\"" + productId
|
||||
+ "\",\"ProvisioningArtifactId\":\"" + artifactId + "\",\"ProvisionedProductName\":\""
|
||||
+ "ab-record-history-pp\",\"PhysicalId\":\"phys-ab-record-history\","
|
||||
+ "\"IdempotencyToken\":\"tok-ab-record-history\"}")
|
||||
.then().statusCode(200)
|
||||
.extract().path("RecordDetail.ProvisionedProductId");
|
||||
.then().statusCode(200).extract().response();
|
||||
String provisionedId = imported.path("RecordDetail.ProvisionedProductId");
|
||||
String importedRecordId = imported.path("RecordDetail.RecordId");
|
||||
String updatedRecordId = call("UpdateProvisionedProduct", "{\"ProvisionedProductId\":\""
|
||||
+ provisionedId + "\",\"UpdateToken\":\"tok-ab-record-history-update\"}")
|
||||
.then().statusCode(200).extract().path("RecordDetail.RecordId");
|
||||
|
||||
call("ListRecordHistory", "{}")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("RecordDetails.ProvisionedProductId", hasItem(provisionedId));
|
||||
.body("RecordDetails.findAll { it.ProvisionedProductId == '" + provisionedId
|
||||
+ "' }.RecordId", containsInAnyOrder(importedRecordId, updatedRecordId))
|
||||
.body("RecordDetails.findAll { it.ProvisionedProductId == '" + provisionedId
|
||||
+ "' }.RecordType", containsInAnyOrder("IMPORT", "UPDATE_PROVISIONED_PRODUCT"))
|
||||
.body("RecordDetails.find { it.RecordId == '" + importedRecordId + "' }.Type", nullValue());
|
||||
|
||||
call("DescribeRecord", "{\"Id\":\"" + importedRecordId + "\"}")
|
||||
.then().statusCode(200).body("RecordDetail.RecordId", equalTo(importedRecordId));
|
||||
call("DescribeRecord", "{\"Id\":\"" + updatedRecordId + "\"}")
|
||||
.then().statusCode(200).body("RecordDetail.RecordId", equalTo(updatedRecordId));
|
||||
}
|
||||
|
||||
@Test
|
||||
void provisionProductRecordIsStableAndListed() {
|
||||
String productId = createProduct("ab-provision-history-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
String request = "{\"ProductId\":\"" + productId + "\",\"ProvisioningArtifactId\":\"" + artifactId
|
||||
+ "\",\"ProvisionedProductName\":\"ab-provision-history-pp\"}";
|
||||
String recordId = call("ProvisionProduct", request)
|
||||
.then().statusCode(200).extract().path("RecordDetail.RecordId");
|
||||
call("ProvisionProduct", request)
|
||||
.then().statusCode(200).body("RecordDetail.RecordId", equalTo(recordId));
|
||||
call("ListRecordHistory", "{}")
|
||||
.then().statusCode(200)
|
||||
.body("RecordDetails.findAll { it.RecordId == '" + recordId + "' }.size()", equalTo(1))
|
||||
.body("RecordDetails.find { it.RecordId == '" + recordId + "' }.RecordType",
|
||||
equalTo("PROVISION_PRODUCT"));
|
||||
call("DescribeRecord", "{\"Id\":\"" + recordId + "\"}")
|
||||
.then().statusCode(200).body("RecordDetail.RecordId", equalTo(recordId));
|
||||
}
|
||||
|
||||
@Test
|
||||
void legacyProductWithOnlyUpdateRecordRetainsSyntheticCreationHistory() {
|
||||
String productId = createProduct("ab-legacy-history-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
Response imported = call("ImportAsProvisionedProduct", "{\"ProductId\":\"" + productId
|
||||
+ "\",\"ProvisioningArtifactId\":\"" + artifactId + "\",\"ProvisionedProductName\":\""
|
||||
+ "ab-legacy-history-pp\",\"PhysicalId\":\"phys-ab-legacy-history\","
|
||||
+ "\"IdempotencyToken\":\"tok-ab-legacy-history\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
String provisionedId = imported.path("RecordDetail.ProvisionedProductId");
|
||||
String importedRecordId = imported.path("RecordDetail.RecordId");
|
||||
AccountAwareStorageBackend<ObjectNode> records = storageFactory.create("servicecatalog",
|
||||
"servicecatalog-associations.json", new TypeReference<Map<String, ObjectNode>>() {});
|
||||
assertEquals(1, records.deleteAllAccountsMatching(
|
||||
record -> importedRecordId.equals(record.path("RecordId").asText())));
|
||||
|
||||
String updatedRecordId = call("UpdateProvisionedProduct", "{\"ProvisionedProductId\":\""
|
||||
+ provisionedId + "\",\"UpdateToken\":\"tok-ab-legacy-history-update\"}")
|
||||
.then().statusCode(200).extract().path("RecordDetail.RecordId");
|
||||
call("ListRecordHistory", "{}")
|
||||
.then().statusCode(200)
|
||||
.body("RecordDetails.findAll { it.ProvisionedProductId == '" + provisionedId
|
||||
+ "' }.size()", equalTo(2))
|
||||
.body("RecordDetails.find { it.ProvisionedProductId == '" + provisionedId
|
||||
+ "' && !it.RecordId }.Status", equalTo("SUCCEEDED"))
|
||||
.body("RecordDetails.find { it.RecordId == '" + updatedRecordId + "' }.RecordType",
|
||||
equalTo("UPDATE_PROVISIONED_PRODUCT"));
|
||||
}
|
||||
|
||||
// ---------- ListResourcesForTagOption ----------
|
||||
|
||||
Reference in new issue
Block a user