mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(servicecatalog): return persisted record details from write actions (#7052)
* fix(servicecatalog): return persisted record details from write actions * test(servicecatalog): remove update record timing delay
This commit is contained in:
1 parent
76b7eed371
commit
0eafa78bba
3 files changed
+85
-49
No files matched your search
+70
@@ -12,6 +12,7 @@ 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;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
/**
|
||||
* Wire-level tests for {@code DescribeProvisionedProduct},
|
||||
@@ -120,6 +121,75 @@ class ServiceCatalogProvisionedProductLifecycleConsumerTest {
|
||||
.body("RecordDetail.RecordType", equalTo("UPDATE_PROVISIONED_PRODUCT"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProvisionedProduct_returnsTheDescribedRecordDetail() throws Exception {
|
||||
String productId = createProduct("ab-update-record-detail-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
String provisionedId = importProvisionedProduct(productId, artifactId, "ab-update-record-detail-pp");
|
||||
|
||||
Response updated = call("UpdateProvisionedProduct", "{\"ProvisionedProductId\":\"" + provisionedId
|
||||
+ "\",\"UpdateToken\":\"tok-update-record-detail\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
JsonNode updateRecord = objectMapper.readTree(updated.asString()).path("RecordDetail");
|
||||
String recordId = updateRecord.path("RecordId").asText();
|
||||
Response described = call("DescribeRecord", "{\"Id\":\"" + recordId + "\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
JsonNode describedRecord = objectMapper.readTree(described.asString()).path("RecordDetail");
|
||||
|
||||
assertEquals(describedRecord.path("CreatedTime"), updateRecord.path("CreatedTime"));
|
||||
assertEquals("UPDATE_PROVISIONED_PRODUCT", updateRecord.path("RecordType").asText());
|
||||
assertFalse(describedRecord.has("Type"));
|
||||
assertEquals(describedRecord, updateRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
void provisionAndImportReturnTheirDescribedRecordDetails() throws Exception {
|
||||
String productId = createProduct("ab-record-response-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
|
||||
Response provisioned = call("ProvisionProduct", "{\"ProductId\":\"" + productId
|
||||
+ "\",\"ProvisioningArtifactId\":\"" + artifactId
|
||||
+ "\",\"ProvisionedProductName\":\"ab-record-response-provisioned\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
assertMatchesDescribeRecord(provisioned);
|
||||
|
||||
Response imported = call("ImportAsProvisionedProduct", "{\"ProductId\":\"" + productId
|
||||
+ "\",\"ProvisioningArtifactId\":\"" + artifactId
|
||||
+ "\",\"ProvisionedProductName\":\"ab-record-response-imported\","
|
||||
+ "\"PhysicalId\":\"phys-ab-record-response-imported\","
|
||||
+ "\"IdempotencyToken\":\"tok-record-response-imported\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
assertMatchesDescribeRecord(imported);
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceActionAndTerminateReturnTheirDescribedRecordDetails() throws Exception {
|
||||
String productId = createProduct("ab-record-action-product");
|
||||
String artifactId = firstArtifactId(productId);
|
||||
String provisionedId = importProvisionedProduct(productId, artifactId, "ab-record-action-pp");
|
||||
|
||||
Response action = call("ExecuteProvisionedProductServiceAction", "{\"ProvisionedProductId\":\""
|
||||
+ provisionedId + "\",\"ServiceActionId\":\"sa-anything\","
|
||||
+ "\"ExecuteToken\":\"tok-record-action\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
assertMatchesDescribeRecord(action);
|
||||
|
||||
Response terminated = call("TerminateProvisionedProduct", "{\"ProvisionedProductId\":\""
|
||||
+ provisionedId + "\",\"TerminateToken\":\"tok-record-termination\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
assertMatchesDescribeRecord(terminated);
|
||||
}
|
||||
|
||||
private void assertMatchesDescribeRecord(Response response) throws Exception {
|
||||
JsonNode record = objectMapper.readTree(response.asString()).path("RecordDetail");
|
||||
String recordId = record.path("RecordId").asText();
|
||||
Response described = call("DescribeRecord", "{\"Id\":\"" + recordId + "\"}")
|
||||
.then().statusCode(200).extract().response();
|
||||
JsonNode describedRecord = objectMapper.readTree(described.asString()).path("RecordDetail");
|
||||
assertFalse(describedRecord.has("Type"));
|
||||
assertEquals(describedRecord, record);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProvisionedProduct_unknownProduct_returnsResourceNotFound() {
|
||||
call("UpdateProvisionedProduct", "{\"ProvisionedProductId\":\"pp-doesnotexist\","
|
||||
|
||||
Reference in new issue
Block a user